Browse Source

center cursor to client area (excludes titlebar thickness)

expikr 2 years ago
parent
commit
a7326b9396
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/video/windows/SDL_windowswindow.c

+ 3 - 1
src/video/windows/SDL_windowswindow.c

@@ -1320,7 +1320,9 @@ void WIN_UpdateClipCursor(SDL_Window *window)
          (window->mouse_rect.w > 0 && window->mouse_rect.h > 0)) &&
          (window->mouse_rect.w > 0 && window->mouse_rect.h > 0)) &&
         (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
         (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
         if (mouse->relative_mode && !mouse->relative_mode_warp && data->mouse_relative_mode_center) {
         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 */
                 /* WIN_WarpCursor() jitters by +1, and remote desktop warp wobble is +/- 1 */
                 LONG remote_desktop_adjustment = GetSystemMetrics(SM_REMOTESESSION) ? 2 : 0;
                 LONG remote_desktop_adjustment = GetSystemMetrics(SM_REMOTESESSION) ? 2 : 0;
                 LONG cx, cy;
                 LONG cx, cy;