Commit 06aca7edaa84b6e16cb96fe0543e2ddc1772e867

Sam Lantinga 2022-05-18T10:09:24

Fixed warping back into the window when gaining focus with warp relative mode enabled

diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index e6ad530..80da27a 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -866,7 +866,7 @@ SDL_GetGlobalMouseState(int *x, int *y)
     }
 }
 
-static void
+void
 SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode)
 {
     SDL_Mouse *mouse = SDL_GetMouse();
diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h
index f06934b..70c3208 100644
--- a/src/events/SDL_mouse_c.h
+++ b/src/events/SDL_mouse_c.h
@@ -152,6 +152,9 @@ extern int SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, U
 /* Send a mouse wheel event */
 extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction);
 
+/* Warp the mouse within the window, potentially overriding relative mode */
+extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode);
+
 /* Shutdown the mouse subsystem */
 extern void SDL_MouseQuit(void);
 
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index cf3d54c..78ae8f6 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -3038,7 +3038,7 @@ SDL_OnWindowFocusGained(SDL_Window * window)
     if (mouse && mouse->relative_mode) {
         SDL_SetMouseFocus(window);
         if (mouse->relative_mode_warp) {
-            SDL_WarpMouseInWindow(window, window->w/2, window->h/2);
+            SDL_PerformWarpMouseInWindow(window, window->w/2, window->h/2, SDL_TRUE);
         }
     }