shithub: choc

Download patch

ref: 1c5c9b248a2080152ccf7f2f17f830b541987257
parent: 0bcc7170871b2966ace33603eb34f9268a8eb53c
author: Fabian Greffrath <fabian@greffrath.com>
date: Thu May 18 11:14:09 EDT 2017

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

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -188,6 +188,7 @@
 // Window resize state.
 
 static boolean need_resize = false;
+static unsigned int last_resize_time;
 
 // Gamma correction level to use
 
@@ -342,10 +343,7 @@
             {
                 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 @@
     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;