From b74d1a5247122531cf39a197ab8ac11a27b57b49 Mon Sep 17 00:00:00 2001 From: Yamagi Date: Sat, 26 Oct 2024 17:28:31 +0200 Subject: [PATCH] Fix window flag handling with SDL3. These are two problems breaking the window flags for renderers which don't use OpenGL or enforce their own flags: * In SDL 3 the window flags were increased from 32 bit to 64 bit. SDL 3.1.3 introduced a new type SDL_WindowFlags for them. Use it to represent the window flags. This is currently a noop, becaue SDL 3 doesn't have any flags above 32 bit yet. This might require another breakage of the renderer API in the future, because currently renderers pass a 32 bit flags thing to the client. * `SDL_SetNumberProperty()` got a new type `SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER` to represent the flags. It must be used, otherwise strange things happen. Closes #1156. --- src/client/vid/glimp_sdl3.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/client/vid/glimp_sdl3.c b/src/client/vid/glimp_sdl3.c index 78c884dc..2b3cc687 100644 --- a/src/client/vid/glimp_sdl3.c +++ b/src/client/vid/glimp_sdl3.c @@ -99,7 +99,7 @@ ClearDisplayIndices(void) } static qboolean -CreateSDLWindow(int flags, int fullscreen, int w, int h) +CreateSDLWindow(SDL_WindowFlags flags, int fullscreen, int w, int h) { if (SDL_WINDOWPOS_ISUNDEFINED(last_position_x) || SDL_WINDOWPOS_ISUNDEFINED(last_position_y) || last_position_x < 0 ||last_position_y < 24) { @@ -121,10 +121,7 @@ CreateSDLWindow(int flags, int fullscreen, int w, int h) SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, last_position_y); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, w); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, h); - SDL_SetNumberProperty(props, "flags", flags); - - if (flags & SDL_WINDOW_OPENGL) - SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, true); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER, flags); window = SDL_CreateWindowWithProperties(props); SDL_DestroyProperties(props); @@ -457,7 +454,7 @@ GLimp_Shutdown(void) * compositor might scale us. */ static int -Glimp_DetermineHighDPISupport(int flags) +Glimp_DetermineHighDPISupport(SDL_WindowFlags flags) { /* Make sure that high dpi is never set when we don't want it. */ flags &= ~SDL_WINDOW_HIGH_PIXEL_DENSITY; @@ -484,11 +481,11 @@ Glimp_DetermineHighDPISupport(int flags) qboolean GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight) { - int flags; + SDL_WindowFlags flags; + SDL_WindowFlags fs_flag = 0; int curWidth, curHeight; int width = *pwidth; int height = *pheight; - unsigned int fs_flag = 0; if (fullscreen == FULLSCREEN_EXCLUSIVE || fullscreen == FULLSCREEN_DESKTOP) {