Fix Xbox link error from IsRectEmpty

(cherry picked from commit 376a3cd100a3d59e887496c75a1ac49ab4a2d8ec)
This commit is contained in:
Caleb Cornett 2023-05-20 13:09:46 -04:00 committed by Sam Lantinga
parent 1ee9a437f9
commit 2001a891c4
4 changed files with 12 additions and 4 deletions

View file

@ -333,6 +333,11 @@ void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect)
winrect->bottom = sdlrect->y + sdlrect->h - 1; winrect->bottom = sdlrect->y + sdlrect->h - 1;
} }
BOOL WIN_IsRectEmpty(const RECT *rect)
{
/* Calculating this manually because UWP and Xbox do not support Win32 IsRectEmpty. */
return (rect->right <= rect->left) || (rect->bottom <= rect->top);
}
#endif /* defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) */ #endif /* defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) */
/* /*

View file

@ -153,6 +153,9 @@ extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect); extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect); extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
/* Returns SDL_TRUE if the rect is empty */
extern BOOL WIN_IsRectEmpty(const RECT *rect);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1217,7 +1217,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
break; break;
} }
if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) { if (!GetClientRect(hwnd, &rect) || WIN_IsRectEmpty(&rect)) {
break; break;
} }
ClientToScreen(hwnd, (LPPOINT)&rect); ClientToScreen(hwnd, (LPPOINT)&rect);
@ -1349,7 +1349,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT rect; RECT rect;
float x, y; float x, y;
if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) { if (!GetClientRect(hwnd, &rect) || WIN_IsRectEmpty(&rect)) {
if (inputs) { if (inputs) {
SDL_small_free(inputs, isstack); SDL_small_free(inputs, isstack);
} }

View file

@ -779,7 +779,7 @@ void WIN_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h)
HWND hwnd = data->hwnd; HWND hwnd = data->hwnd;
RECT rect; RECT rect;
if (GetClientRect(hwnd, &rect) && !IsRectEmpty(&rect)) { if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) {
*w = rect.right; *w = rect.right;
*h = rect.bottom; *h = rect.bottom;
} else { } else {
@ -1340,7 +1340,7 @@ void WIN_UpdateClipCursor(SDL_Window *window)
} }
} }
if (SDL_memcmp(&rect, &clipped_rect, sizeof(rect)) != 0) { if (SDL_memcmp(&rect, &clipped_rect, sizeof(rect)) != 0) {
if (!IsRectEmpty(&rect)) { if (!WIN_IsRectEmpty(&rect)) {
if (ClipCursor(&rect)) { if (ClipCursor(&rect)) {
data->cursor_clipped_rect = rect; data->cursor_clipped_rect = rect;
} }