Commit 1c5b3e0e1655e94ffafc21d4b1c6087e5217c40b

Sam Lantinga 2021-10-15T18:12:18

Don't center the mouse when gaining focus unless we're using relative mode warping This is necessary now that we actually change the mouse position when calling SDL_WarpMouseInWindow() in relative mode.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 07c7aa5..371a6e5 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -2897,7 +2897,9 @@ SDL_OnWindowFocusGained(SDL_Window * window)
 
     if (mouse && mouse->relative_mode) {
         SDL_SetMouseFocus(window);
-        SDL_WarpMouseInWindow(window, window->w/2, window->h/2);
+        if (mouse->relative_mode_warp) {
+            SDL_WarpMouseInWindow(window, window->w/2, window->h/2);
+        }
     }
 
     SDL_UpdateWindowGrab(window);