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
This commit is contained in:
Sam Lantinga
2023-03-09 10:31:39 -08:00
parent bb59f46cbe
commit 2ca727aec6
2 changed files with 4 additions and 5 deletions

View File

@@ -792,12 +792,12 @@ void 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->last_pixel_w;
*h = window->last_pixel_h;
}
}