From fffeedffdab2ed6ada1aceb3d2ab7b7f4a396917 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 7 Mar 2018 10:53:39 +0100 Subject: [PATCH] Expose High DPI support configuration flag The High DPI support is enabled by default, so that the renderer use the full definition of High DPI screens. However, there are still mouse coordinates problems on some MacOS having High DPI support (but not all), so expose a way to disable it. --- app/meson.build | 3 +++ app/src/screen.c | 6 +++++- meson_options.txt | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/meson.build b/app/meson.build index e62a60f7..33282b23 100644 --- a/app/meson.build +++ b/app/meson.build @@ -80,6 +80,9 @@ conf.set('DEFAULT_BIT_RATE', '8000000') # 8Mbps # SKIP_FRAMES improves latency at the cost of framerate conf.set('SKIP_FRAMES', get_option('skip_frames')) +# enable High DPI support +conf.set('HIDPI_SUPPORT', get_option('hidpi_support')) + configure_file(configuration: conf, output: 'config.h') executable('scrcpy', src, dependencies: dependencies, install: true) diff --git a/app/src/screen.c b/app/src/screen.c index 9c827738..c6838946 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -140,8 +140,12 @@ SDL_bool screen_init_rendering(struct screen *screen, const char *device_name, s screen->frame_size = frame_size; struct size window_size = get_initial_optimal_size(frame_size); + Uint32 window_flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE; +#ifdef HIDPI_SUPPORT + window_flags |= SDL_WINDOW_ALLOW_HIGHDPI; +#endif screen->window = SDL_CreateWindow(device_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - window_size.width, window_size.height, SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE); + window_size.width, window_size.height, window_flags); if (!screen->window) { LOGC("Could not create window: %s", SDL_GetError()); return SDL_FALSE; diff --git a/meson_options.txt b/meson_options.txt index ce3fdb49..b154bd97 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,3 +3,4 @@ option('build_server', type: 'boolean', value: true, description: 'Build the ser option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server') option('override_server_path', type: 'string', description: 'Hardcoded path to find the server at runtime') option('skip_frames', type: 'boolean', value: true, description: 'Always display the most recent frame') +option('hidpi_support', type: 'boolean', value: true, description: 'Enable High DPI support')