sdl12-compat: SDL_SetVideoMode: do window resize twice to workaround SDL2 (x11?) issue.

From c7d6a9c8e1f0c8e8dfdbff764198c8060805d722 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 2 Dec 2021 10:23:48 -0500
Subject: [PATCH] SDL_SetVideoMode: do window resize twice to workaround SDL2
 (x11?) issue.

It looks like at the moment SDL2/x11 misbehaves if you resize a fullscreen
window with SDL_SetWindowSize and then make it not fullscreen with
SDL_SetWindowFullscreen; it doesn't appear to accept the new window size
when it leaves fullscreen mode. But a second SDL_SetWindowSize() at this
point appears to be accepted.

I believe this to be an SDL2 issue, but the workaround is easy enough, that
we'll keep this for older SDLs even if a newer release fixes the issue.

Fixes #148.
---
 src/SDL12_compat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 6dc9b7e..289bbbb 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -5073,6 +5073,8 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
     } else {  /* resize it */
         SDL20_SetWindowSize(VideoWindow20, width, height);
         SDL20_SetWindowFullscreen(VideoWindow20, fullscreen_flags20);
+        /* This second SetWindowSize is a workaround for an SDL2 bug, see https://github.com/libsdl-org/sdl12-compat/issues/148 */
+        SDL20_SetWindowSize(VideoWindow20, width, height);
         SDL20_SetWindowBordered(VideoWindow20, (flags12 & SDL12_NOFRAME) ? SDL_FALSE : SDL_TRUE);
         SDL20_SetWindowResizable(VideoWindow20, (flags12 & SDL12_RESIZABLE) ? SDL_TRUE : SDL_FALSE);
     }