Fix Xbox link error from IsRectEmpty (cherry picked from commit 376a3cd100a3d59e887496c75a1ac49ab4a2d8ec)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c
index a2f0d53..682aaf1 100644
--- a/src/core/windows/SDL_windows.c
+++ b/src/core/windows/SDL_windows.c
@@ -333,6 +333,11 @@ void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect)
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__) */
/*
diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h
index ffea8c6..ac6def6 100644
--- a/src/core/windows/SDL_windows.h
+++ b/src/core/windows/SDL_windows.h
@@ -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 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++ */
#ifdef __cplusplus
}
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 95a6f8d..180c1a8 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -1217,7 +1217,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
}
- if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) {
+ if (!GetClientRect(hwnd, &rect) || WIN_IsRectEmpty(&rect)) {
break;
}
ClientToScreen(hwnd, (LPPOINT)&rect);
@@ -1349,7 +1349,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT rect;
float x, y;
- if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) {
+ if (!GetClientRect(hwnd, &rect) || WIN_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 82a4282..796b2a5 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -779,7 +779,7 @@ void WIN_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h)
HWND hwnd = data->hwnd;
RECT rect;
- if (GetClientRect(hwnd, &rect) && !IsRectEmpty(&rect)) {
+ if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) {
*w = rect.right;
*h = rect.bottom;
} else {
@@ -1340,7 +1340,7 @@ void WIN_UpdateClipCursor(SDL_Window *window)
}
}
if (SDL_memcmp(&rect, &clipped_rect, sizeof(rect)) != 0) {
- if (!IsRectEmpty(&rect)) {
+ if (!WIN_IsRectEmpty(&rect)) {
if (ClipCursor(&rect)) {
data->cursor_clipped_rect = rect;
}