foxygit / doom Log in
commit 1c5c9b248a2080152ccf7f2f17f830b541987257
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Thu May 18 15:14:09 2017 +0200
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Thu May 18 15:14:09 2017 +0200

    video: apply windows self-resizing only after a 500 ms delay

    This hopefully reduced the flicker experienced with certain window
    managers on certain display servers when the window is manually
    resized and then resizes itself again to match the right aspect ratio.

    Fixes #856
---
 src/i_video.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index 4a7a2df0..163b0522 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -188,6 +188,7 @@ static boolean window_focused = true;
 // Window resize state.

 static boolean need_resize = false;
+static unsigned int last_resize_time;

 // Gamma correction level to use

@@ -342,10 +343,7 @@ static void HandleWindowEvent(SDL_WindowEvent *event)
             {
                 SDL_GetWindowSize(screen, &window_width, &window_height);

-                // Adjust the window by resizing again so that the window
-                // is the right aspect ratio.
-                AdjustWindowSize();
-                SDL_SetWindowSize(screen, window_width, window_height);
+                last_resize_time = SDL_GetTicks();
             }
             break;

@@ -719,8 +717,13 @@ void I_FinishUpdate (void)
     if (noblit)
         return;

-    if (need_resize)
+    if (need_resize && SDL_GetTicks() > last_resize_time + 500)
     {
+        // Adjust the window by resizing again so that the window
+        // is the right aspect ratio.
+        AdjustWindowSize();
+        SDL_SetWindowSize(screen, window_width, window_height);
+
         CreateUpscaledTexture(false);
         need_resize = false;
         palette_to_set = true;