From dca2c5f94fd0f35ef1c6583cc59bb9ba1b6bdbd4 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 6 Dec 2021 23:46:01 +0100 Subject: [PATCH] Require SDL >= 2.0.5 Icon loading uses SDL_CreateRGBSurfaceWithFormatFrom(), available since SDL 2.0.5 (in 2016). Refs #2862 --- app/meson.build | 2 +- app/src/compat.h | 9 --------- app/src/scrcpy.c | 2 -- app/src/screen.c | 12 +----------- 4 files changed, 2 insertions(+), 23 deletions(-) diff --git a/app/meson.build b/app/meson.build index 7d9c2b5c..1907812d 100644 --- a/app/meson.build +++ b/app/meson.build @@ -87,7 +87,7 @@ if not get_option('crossbuild_windows') dependency('libavformat'), dependency('libavcodec'), dependency('libavutil'), - dependency('sdl2'), + dependency('sdl2', version: '>= 2.0.5'), ] if v4l2_support diff --git a/app/src/compat.h b/app/src/compat.h index 3ab56049..311d617d 100644 --- a/app/src/compat.h +++ b/app/src/compat.h @@ -35,15 +35,6 @@ # define SCRCPY_LAVF_HAS_AVFORMATCONTEXT_URL #endif -#if SDL_VERSION_ATLEAST(2, 0, 5) -// -# define SCRCPY_SDL_HAS_HINT_MOUSE_FOCUS_CLICKTHROUGH -// -# define SCRCPY_SDL_HAS_GET_DISPLAY_USABLE_BOUNDS -// -# define SCRCPY_SDL_HAS_WINDOW_ALWAYS_ON_TOP -#endif - #if SDL_VERSION_ATLEAST(2, 0, 6) // # define SCRCPY_SDL_HAS_HINT_TOUCH_MOUSE_EVENTS diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 99317ffc..9c2bd03b 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -94,12 +94,10 @@ sdl_set_hints(const char *render_driver) { LOGW("Could not enable linear filtering"); } -#ifdef SCRCPY_SDL_HAS_HINT_MOUSE_FOCUS_CLICKTHROUGH // Handle a click to gain focus as any other click if (!SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1")) { LOGW("Could not enable mouse focus clickthrough"); } -#endif #ifdef SCRCPY_SDL_HAS_HINT_TOUCH_MOUSE_EVENTS // Disable synthetic mouse events from touch events diff --git a/app/src/screen.c b/app/src/screen.c index 34a2d5d9..c72fdf44 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -64,12 +64,7 @@ set_window_size(struct screen *screen, struct sc_size new_size) { static bool get_preferred_display_bounds(struct sc_size *bounds) { SDL_Rect rect; -#ifdef SCRCPY_SDL_HAS_GET_DISPLAY_USABLE_BOUNDS -# define GET_DISPLAY_BOUNDS(i, r) SDL_GetDisplayUsableBounds((i), (r)) -#else -# define GET_DISPLAY_BOUNDS(i, r) SDL_GetDisplayBounds((i), (r)) -#endif - if (GET_DISPLAY_BOUNDS(0, &rect)) { + if (SDL_GetDisplayUsableBounds(0, &rect)) { LOGW("Could not get display usable bounds: %s", SDL_GetError()); return false; } @@ -394,12 +389,7 @@ screen_init(struct screen *screen, const struct screen_params *params) { | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; if (params->always_on_top) { -#ifdef SCRCPY_SDL_HAS_WINDOW_ALWAYS_ON_TOP window_flags |= SDL_WINDOW_ALWAYS_ON_TOP; -#else - LOGW("The 'always on top' flag is not available " - "(compile with SDL >= 2.0.5 to enable it)"); -#endif } if (params->window_borderless) { window_flags |= SDL_WINDOW_BORDERLESS;