Skip to content

Display and control your Android device

Use "always on top" only for SDL >= 2.0.5

Romain Vimont1c1fe5ec5317
diff --git a/app/src/compat.h b/app/src/compat.h
index 4f709af6..fd68d61a 100644
--- a/app/src/compat.h
+++ b/app/src/compat.h
@@ -39,6 +39,8 @@
# define SCRCPY_SDL_HAS_HINT_MOUSE_FOCUS_CLICKTHROUGH
// <https://wiki.libsdl.org/SDL_GetDisplayUsableBounds>
# define SCRCPY_SDL_HAS_GET_DISPLAY_USABLE_BOUNDS
+// <https://wiki.libsdl.org/SDL_WindowFlags>
+# define SCRCPY_SDL_HAS_WINDOW_ALWAYS_ON_TOP
#endif
#endif
diff --git a/app/src/screen.c b/app/src/screen.c
index 4e9752c2..1632e27f 100644
--- a/app/src/screen.c
+++ b/app/src/screen.c
@@ -157,7 +157,12 @@ SDL_bool screen_init_rendering(struct screen *screen,
window_flags |= SDL_WINDOW_ALLOW_HIGHDPI;
#endif
if (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
}
screen->window = SDL_CreateWindow(device_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,