SDL: SDL_SetWindowDisplayMode(): If already fullscreen, adjust window size

From 0eb6f79190d6ad1c620930d054379bee3f476a2b Mon Sep 17 00:00:00 2001
From: Daniel Gibson <[EMAIL REDACTED]>
Date: Fri, 21 May 2021 13:48:14 +0200
Subject: [PATCH] SDL_SetWindowDisplayMode(): If already fullscreen, adjust
 window size

Otherwise only the display resolution is changed, but the SDL window size
(and for example the window-surface size) aren't adjusted accordingly
and thus don't fill the whole screen.
See #3313
---
 src/video/SDL_video.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 5027562c8..25b8aeb8c 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1163,6 +1163,12 @@ SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode)
         SDL_DisplayMode fullscreen_mode;
         if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
             SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
+            /* make sure the window size (and internals like window-surface size) are adjusted */
+            if (window->w != fullscreen_mode.w || window->h != fullscreen_mode.h) {
+                window->w = fullscreen_mode.w;
+                window->h = fullscreen_mode.h;
+                SDL_OnWindowResized(window);
+            }
         }
     }
     return 0;