SDL: Fixed minimized window detection when handling WM_WINDOWPOSCHANGED (3739d)

From 3739dda6bd777f76ec5c89eb4ea1eaa8be87fb23 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 19 Aug 2022 17:28:31 -0700
Subject: [PATCH] Fixed minimized window detection when handling
 WM_WINDOWPOSCHANGED

When minimizing a window, we get this sequence of events:
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_NCCALCSIZE
WM_WINDOWPOSCHANGED - IsIconic() is true
WM_MOVE
WM_SIZE - SDL sees minimized state here

When restoring a window, we get this sequence of events:
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_NCCALCSIZE
WM_NCPAINT
WM_ERASEBKGND
WM_WINDOWPOSCHANGED - IsIconic() is false
WM_MOVE
WM_SIZE - SDL sees restored state here

On Windows 10 a minimized window has a non-empty client rect, so we were delivering a minimized size before SDL knows that the window is minimized, and then ignoring the restored size when handling the restore message.

The fix is to use IsIconic() which returns the correct window state when WM_WINDOWPOSCHANGED is actually delivered.
---
 src/video/windows/SDL_windowsevents.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index e2b95ad4ec6..60a563e1890 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -1169,7 +1169,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
             }
 
             /* When the window is minimized it's resized to the dock icon size, ignore this */
-            if ((data->window->flags & SDL_WINDOW_MINIMIZED) != 0) {
+            if (IsIconic(hwnd)) {
                 break;
             }