Fixed warping back into the window when gaining focus with warp relative mode enabled
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
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);
}
}