Skip to content

Commit

Permalink
If the client rect is empty, use the last known window size
Browse files Browse the repository at this point in the history
This happens on Windows 11 with fullscreen desktop windows when the desktop is brought up with the Windows+D shortcut.

Fixes #7419
  • Loading branch information
slouken committed Mar 9, 2023
1 parent bb59f46 commit 2ca727a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/video/windows/SDL_windowsevents.c
Expand Up @@ -1395,8 +1395,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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/video/windows/SDL_windowswindow.c
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 2ca727a

Please sign in to comment.