From f75c0e32048c5462a8c698194f85c0beb2a3102d Mon Sep 17 00:00:00 2001
From: expikr <[EMAIL REDACTED]>
Date: Thu, 6 Jul 2023 00:58:09 +0800
Subject: [PATCH] center cursor to client area (excludes titlebar thickness)
(cherry picked from commit a7326b9396662c1e248dd530f6985f24e0ea337e)
---
src/video/windows/SDL_windowswindow.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 1d128f7ddabc..27f5223ce99e 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -1293,7 +1293,9 @@ void WIN_UpdateClipCursor(SDL_Window *window)
(window->mouse_rect.w > 0 && window->mouse_rect.h > 0)) &&
(window->flags & SDL_WINDOW_INPUT_FOCUS)) {
if (mouse->relative_mode && !mouse->relative_mode_warp && data->mouse_relative_mode_center) {
- if (GetWindowRect(data->hwnd, &rect)) {
+ if (GetClientRect(data->hwnd, &rect)) { /* RECT( left , top , right , bottom ) */
+ ClientToScreen(data->hwnd, (LPPOINT)&rect); /* POINT( left , top ) */
+ ClientToScreen(data->hwnd, (LPPOINT)&rect + 1); /* POINT( right , bottom ) */
/* WIN_WarpCursor() jitters by +1, and remote desktop warp wobble is +/- 1 */
LONG remote_desktop_adjustment = GetSystemMetrics(SM_REMOTESESSION) ? 2 : 0;
LONG cx, cy;