SDL: video: Save pending window events when a window is hidden by the window manager

From ae4484f4e5dc2d9820b6ad2f1c34fc33cf04cf0d Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Sun, 3 Mar 2024 17:55:47 -0500
Subject: [PATCH] video: Save pending window events when a window is hidden by
 the window manager

The window manager might hide/unmap the window when it is minimized, in which case the fullscreen and maximized flags must be preserved as pending flags so the window will be restored to the proper state when shown/mapped on restoration.
---
 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 e998b0eb478a8..e52e80d2a90fe 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -3456,6 +3456,12 @@ void SDL_OnWindowShown(SDL_Window *window)
 
 void SDL_OnWindowHidden(SDL_Window *window)
 {
+    /* Store the maximized and fullscreen flags for restoration later, in case
+     * this was initiated by the window manager due to the window being unmapped
+     * when minimized.
+     */
+    window->pending_flags = (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED));
+
     /* The window is already hidden at this point, so just change the mode back if necessary. */
     SDL_UpdateFullscreenMode(window, SDL_FALSE, SDL_FALSE);
 }