SDL: If the client rect is empty, use the last known window size (596a5)

From 596a594714590c0b3bdbd878c553abb868de317c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 9 Mar 2023 10:31:39 -0800
Subject: [PATCH] If the client rect is empty, use the last known window size

This happens on Windows 11 with fullscreen desktop windows when the desktop is brought up with the Windows+D shortcut.

Fixes https://github.com/libsdl-org/SDL/issues/7419

(cherry picked from commit 2ca727aec6f5f264620f80999beb5ef77eefec4a)
(cherry picked from commit 46d143376a55817c240a58f226ca944581d414cf)
---
 src/video/windows/SDL_windowsevents.c | 3 +--
 src/video/windows/SDL_windowswindow.c | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index d7d7e7aa2fc4..695c55cf15e3 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -1317,8 +1317,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                 RECT rect;
                 float x, y;
 
-                if (!GetClientRect(hwnd, &rect) ||
-                    (rect.right == rect.left && rect.bottom == rect.top)) {
+                if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) {
                     if (inputs) {
                         SDL_small_free(inputs, isstack);
                     }
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index ba00a8319a8f..f014247ff0bd 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -790,12 +790,12 @@ WIN_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h)
     HWND hwnd = data->hwnd;
     RECT rect;
 
-    if (GetClientRect(hwnd, &rect)) {
+    if (GetClientRect(hwnd, &rect) && !IsRectEmpty(&rect)) {
         *w = rect.right;
         *h = rect.bottom;
     } else {
-        *w = 0;
-        *h = 0;
+        *w = window->w;
+        *h = window->h;
     }
 }