From 2ab250d1a102e2ada7146b6611d00bb549a596c9 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Sun, 12 Apr 2020 01:16:14 +0200 Subject: [PATCH] Update minimum window size It's necessary for usecase when game changes resolution while in game. We don't want to resize the window in such case, just change minimum size (SDL might decide to update the window size in the result, if new resolution is higher than current window size). --- src/gui/sdlmain.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index d24eab6b..0008c793 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -632,10 +632,6 @@ static SDL_Window *SetWindowMode(SCREEN_TYPES screen_type, if (resizable) { SDL_AddEventWatch(watch_sdl_events, sdl.window); SDL_SetWindowResizable(sdl.window, SDL_TRUE); - const int w = iround(sdl.draw.width * sdl.draw.scalex); - const int h = iround(sdl.draw.height * sdl.draw.scaley); - SDL_SetWindowMinimumSize(sdl.window, w, h); - sdl.desktop.window.resizable = true; } else { sdl.desktop.window.resizable = false; @@ -678,6 +674,13 @@ static SDL_Window *SetWindowMode(SCREEN_TYPES screen_type, } // Maybe some requested fullscreen resolution is unsupported? finish: + + if (sdl.desktop.window.resizable && !sdl.desktop.switching_fullscreen) { + const int w = iround(sdl.draw.width * sdl.draw.scalex); + const int h = iround(sdl.draw.height * sdl.draw.scaley); + SDL_SetWindowMinimumSize(sdl.window, w, h); + } + HandleVideoResize(width, height); sdl.update_display_contents = true; return sdl.window;