ref: 1843d641566a080f2751348e0ca9a54694e1f348
parent: 0bcc7170871b2966ace33603eb34f9268a8eb53c
parent: c47a715ed8f0fb958a9ece5750f75856f252caa6
author: Fabian Greffrath <fabian@greffrath.com>
date: Wed May 31 04:16:00 EDT 2017
Merge pull request #913 from chocolate-doom/last_resize_time video: apply windows self-resizing only after a 500 ms delay
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -188,6 +188,8 @@
// Window resize state.
static boolean need_resize = false;
+static unsigned int last_resize_time;
+#define RESIZE_DELAY 500
// Gamma correction level to use
@@ -319,7 +321,7 @@
static void HandleWindowEvent(SDL_WindowEvent *event)
{
- int i, flags;
+ int i;
switch (event->event)
{
@@ -335,18 +337,7 @@
case SDL_WINDOWEVENT_RESIZED:
need_resize = true;
- // When the window is resized (we're not in fullscreen mode),
- // save the new window size.
- flags = SDL_GetWindowFlags(screen);
- if ((flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == 0)
- {
- 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;
// Don't render the screen when the window is minimized:
@@ -721,9 +712,29 @@
if (need_resize)
{
- CreateUpscaledTexture(false);
- need_resize = false;
- palette_to_set = true;
+ if (SDL_GetTicks() > last_resize_time + RESIZE_DELAY)
+ {
+ int flags;
+ // When the window is resized (we're not in fullscreen mode),
+ // save the new window size.
+ flags = SDL_GetWindowFlags(screen);
+ if ((flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == 0)
+ {
+ 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);
+ }
+ CreateUpscaledTexture(false);
+ need_resize = false;
+ palette_to_set = true;
+ }
+ else
+ {
+ return;
+ }
}
UpdateGrab();