Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0ead07f61 |
@@ -116,6 +116,9 @@ conf.set('DEFAULT_LOCK_VIDEO_ORIENTATION', '-1') # -1: unlocked
|
|||||||
# overridden by option --bit-rate
|
# overridden by option --bit-rate
|
||||||
conf.set('DEFAULT_BIT_RATE', '8000000') # 8Mbps
|
conf.set('DEFAULT_BIT_RATE', '8000000') # 8Mbps
|
||||||
|
|
||||||
|
# enable High DPI support
|
||||||
|
conf.set('HIDPI_SUPPORT', get_option('hidpi_support'))
|
||||||
|
|
||||||
# disable console on Windows
|
# disable console on Windows
|
||||||
conf.set('WINDOWS_NOCONSOLE', get_option('windows_noconsole'))
|
conf.set('WINDOWS_NOCONSOLE', get_option('windows_noconsole'))
|
||||||
|
|
||||||
|
|||||||
+1
-7
@@ -128,7 +128,6 @@ enum event_result {
|
|||||||
EVENT_RESULT_CONTINUE,
|
EVENT_RESULT_CONTINUE,
|
||||||
EVENT_RESULT_STOPPED_BY_USER,
|
EVENT_RESULT_STOPPED_BY_USER,
|
||||||
EVENT_RESULT_STOPPED_BY_EOS,
|
EVENT_RESULT_STOPPED_BY_EOS,
|
||||||
EVENT_RESULT_STOPPED_BY_ERROR,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum event_result
|
static enum event_result
|
||||||
@@ -151,9 +150,7 @@ handle_event(SDL_Event *event, bool control) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
if (!screen_handle_window_event(&screen, &event->window)) {
|
screen_handle_window_event(&screen, &event->window);
|
||||||
return EVENT_RESULT_STOPPED_BY_ERROR;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
if (!control) {
|
if (!control) {
|
||||||
@@ -225,9 +222,6 @@ event_loop(bool display, bool control) {
|
|||||||
case EVENT_RESULT_STOPPED_BY_EOS:
|
case EVENT_RESULT_STOPPED_BY_EOS:
|
||||||
LOGW("Device disconnected");
|
LOGW("Device disconnected");
|
||||||
return false;
|
return false;
|
||||||
case EVENT_RESULT_STOPPED_BY_ERROR:
|
|
||||||
LOGC("Stopping due to unrecoverable error");
|
|
||||||
return false;
|
|
||||||
case EVENT_RESULT_CONTINUE:
|
case EVENT_RESULT_CONTINUE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-72
@@ -217,9 +217,10 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
|
|
||||||
struct size window_size =
|
struct size window_size =
|
||||||
get_initial_optimal_size(content_size, window_width, window_height);
|
get_initial_optimal_size(content_size, window_width, window_height);
|
||||||
uint32_t window_flags = SDL_WINDOW_HIDDEN
|
uint32_t window_flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
|
||||||
| SDL_WINDOW_RESIZABLE
|
#ifdef HIDPI_SUPPORT
|
||||||
| SDL_WINDOW_ALLOW_HIGHDPI;
|
window_flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
|
#endif
|
||||||
if (always_on_top) {
|
if (always_on_top) {
|
||||||
#ifdef SCRCPY_SDL_HAS_WINDOW_ALWAYS_ON_TOP
|
#ifdef SCRCPY_SDL_HAS_WINDOW_ALWAYS_ON_TOP
|
||||||
window_flags |= SDL_WINDOW_ALWAYS_ON_TOP;
|
window_flags |= SDL_WINDOW_ALWAYS_ON_TOP;
|
||||||
@@ -264,7 +265,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// starts with "opengl"
|
// stats with "opengl"
|
||||||
screen->use_opengl = renderer_name && !strncmp(renderer_name, "opengl", 6);
|
screen->use_opengl = renderer_name && !strncmp(renderer_name, "opengl", 6);
|
||||||
if (screen->use_opengl) {
|
if (screen->use_opengl) {
|
||||||
struct sc_opengl *gl = &screen->gl;
|
struct sc_opengl *gl = &screen->gl;
|
||||||
@@ -309,11 +310,6 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
|
|
||||||
screen->windowed_window_size = window_size;
|
screen->windowed_window_size = window_size;
|
||||||
|
|
||||||
struct scale_ratio *rw = &screen->scale.w;
|
|
||||||
struct scale_ratio *rh = &screen->scale.h;
|
|
||||||
SDL_GetWindowSize(screen->window, &rw->window, &rh->window);
|
|
||||||
SDL_GL_GetDrawableSize(screen->window, &rw->drawable, &rh->drawable);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,74 +519,24 @@ screen_resize_to_pixel_perfect(struct screen *screen) {
|
|||||||
content_size.height);
|
content_size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static void
|
||||||
screen_fix_hidpi(struct screen *screen) {
|
screen_reset_logical_size(struct screen *screen) {
|
||||||
// If the scale ratio has changed, recreate the renderer to fix HiDPI issues
|
// Re-apply the current logical size.
|
||||||
// <https://github.com/Genymobile/scrcpy/issues/15>
|
if (SDL_RenderSetLogicalSize(screen->renderer, screen->content_size.width,
|
||||||
|
screen->content_size.height)) {
|
||||||
int ww, wh, dw, dh;
|
LOGE("Could not reset renderer logical size: %s", SDL_GetError());
|
||||||
SDL_GetWindowSize(screen->window, &ww, &wh);
|
|
||||||
SDL_GL_GetDrawableSize(screen->window, &dw, &dh);
|
|
||||||
|
|
||||||
struct scale_ratio *rw = &screen->scale.w;
|
|
||||||
struct scale_ratio *rh = &screen->scale.h;
|
|
||||||
|
|
||||||
if (ww * rw->drawable == dw * rw->window &&
|
|
||||||
wh * rh->drawable == dh * rh->window) {
|
|
||||||
// same ratio, both horizontally and vertically, nothing to do
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the current scale
|
|
||||||
rw->window = ww;
|
|
||||||
rh->window = wh;
|
|
||||||
rw->drawable = dw;
|
|
||||||
rh->drawable = dh;
|
|
||||||
|
|
||||||
if (screen->texture) {
|
|
||||||
SDL_DestroyTexture(screen->texture);
|
|
||||||
}
|
|
||||||
if (screen->renderer) {
|
|
||||||
SDL_DestroyRenderer(screen->renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
screen->renderer = SDL_CreateRenderer(screen->window, -1,
|
|
||||||
SDL_RENDERER_ACCELERATED);
|
|
||||||
if (!screen->renderer) {
|
|
||||||
LOGC("Could not create renderer: %s", SDL_GetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct size content_size = screen->content_size;
|
|
||||||
if (SDL_RenderSetLogicalSize(screen->renderer, content_size.width,
|
|
||||||
content_size.height)) {
|
|
||||||
LOGE("Could not set renderer logical size: %s", SDL_GetError());
|
|
||||||
SDL_DestroyRenderer(screen->renderer);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME this is wrong, we must update the last frame to the new texture,
|
|
||||||
// but we don't have it anymore!
|
|
||||||
screen->texture = create_texture(screen);
|
|
||||||
if (!screen->texture) {
|
|
||||||
LOGC("Could not create texture: %s", SDL_GetError());
|
|
||||||
SDL_DestroyRenderer(screen->renderer);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGD("Renderer and texture reset");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
screen_handle_window_event(struct screen *screen,
|
screen_handle_window_event(struct screen *screen,
|
||||||
const SDL_WindowEvent *event) {
|
const SDL_WindowEvent *event) {
|
||||||
switch (event->event) {
|
switch (event->event) {
|
||||||
case SDL_WINDOWEVENT_EXPOSED:
|
case SDL_WINDOWEVENT_EXPOSED:
|
||||||
if (!screen_fix_hidpi(screen)) {
|
// Re-apply the current logical size, in case the window has been
|
||||||
// unrecoverable
|
// moved to a screen with a different HiDPI scaling
|
||||||
return false;
|
// <https://github.com/Genymobile/scrcpy/issues/15>
|
||||||
}
|
screen_reset_logical_size(screen);
|
||||||
screen_render(screen);
|
screen_render(screen);
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
@@ -626,8 +572,6 @@ screen_handle_window_event(struct screen *screen,
|
|||||||
apply_windowed_size(screen);
|
apply_windowed_size(screen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct point
|
struct point
|
||||||
|
|||||||
+1
-22
@@ -13,11 +13,6 @@
|
|||||||
|
|
||||||
struct video_buffer;
|
struct video_buffer;
|
||||||
|
|
||||||
struct scale_ratio {
|
|
||||||
int window;
|
|
||||||
int drawable;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct screen {
|
struct screen {
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
SDL_Renderer *renderer;
|
SDL_Renderer *renderer;
|
||||||
@@ -38,11 +33,6 @@ struct screen {
|
|||||||
bool maximized;
|
bool maximized;
|
||||||
bool no_window;
|
bool no_window;
|
||||||
bool mipmaps;
|
bool mipmaps;
|
||||||
|
|
||||||
struct {
|
|
||||||
struct scale_ratio w;
|
|
||||||
struct scale_ratio h;
|
|
||||||
} scale;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCREEN_INITIALIZER { \
|
#define SCREEN_INITIALIZER { \
|
||||||
@@ -73,16 +63,6 @@ struct screen {
|
|||||||
.maximized = false, \
|
.maximized = false, \
|
||||||
.no_window = false, \
|
.no_window = false, \
|
||||||
.mipmaps = false, \
|
.mipmaps = false, \
|
||||||
.scale = { \
|
|
||||||
.w = { \
|
|
||||||
.window = 0, \
|
|
||||||
.drawable = 0, \
|
|
||||||
}, \
|
|
||||||
.h = { \
|
|
||||||
.window = 0, \
|
|
||||||
.drawable = 0, \
|
|
||||||
}, \
|
|
||||||
} \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize default values
|
// initialize default values
|
||||||
@@ -131,8 +111,7 @@ void
|
|||||||
screen_set_rotation(struct screen *screen, unsigned rotation);
|
screen_set_rotation(struct screen *screen, unsigned rotation);
|
||||||
|
|
||||||
// react to window events
|
// react to window events
|
||||||
// return true on success, false on unrecoverable error
|
void
|
||||||
bool
|
|
||||||
screen_handle_window_event(struct screen *screen, const SDL_WindowEvent *event);
|
screen_handle_window_event(struct screen *screen, const SDL_WindowEvent *event);
|
||||||
|
|
||||||
// convert point from window coordinates to frame coordinates
|
// convert point from window coordinates to frame coordinates
|
||||||
|
|||||||
@@ -4,5 +4,6 @@ option('crossbuild_windows', type: 'boolean', value: false, description: 'Build
|
|||||||
option('windows_noconsole', type: 'boolean', value: false, description: 'Disable console on Windows (pass -mwindows flag)')
|
option('windows_noconsole', type: 'boolean', value: false, description: 'Disable console on Windows (pass -mwindows flag)')
|
||||||
option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server')
|
option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server')
|
||||||
option('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')
|
option('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')
|
||||||
|
option('hidpi_support', type: 'boolean', value: true, description: 'Enable High DPI support')
|
||||||
option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached')
|
option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached')
|
||||||
option('server_debugger_method', type: 'combo', choices: ['old', 'new'], value: 'new', description: 'Select the debugger method (Android < 9: "old", Android >= 9: "new")')
|
option('server_debugger_method', type: 'combo', choices: ['old', 'new'], value: 'new', description: 'Select the debugger method (Android < 9: "old", Android >= 9: "new")')
|
||||||
|
|||||||
Reference in New Issue
Block a user