From f214984e185afb9606e184aa494d44f3b58f4e31 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff <timfelgentreff@gmail.com> Date: Sun, 13 Dec 2020 19:13:31 +0100 Subject: [PATCH] make resizing of window when changing resolution smarter --- src/video/video.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/video/video.cpp b/src/video/video.cpp index 02d11c83e..01cd05428 100644 --- a/src/video/video.cpp +++ b/src/video/video.cpp @@ -267,10 +267,16 @@ void CVideo::ClearScreen() bool CVideo::ResizeScreen(int w, int h) { if (!(SDL_GetWindowFlags(TheWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP) - && Video.Width == Video.WindowWidth - && Video.Height == Video.WindowHeight) { - // if initially window was the same size as res, keep it that way - SDL_SetWindowSize(TheWindow, w, h); + && Width == WindowWidth + && Height == WindowHeight) { + // if initially window was the same size as res, keep it that way, unless we've resized + int ww, wh; + SDL_GetWindowSize(TheWindow, &ww, &wh); + if (ww == Width && wh == Height) { + WindowWidth = w; + WindowHeight = h; + SDL_SetWindowSize(TheWindow, w, h); + } } Width = w; Height = h;