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

main
Sam Lantinga 2022-05-18 10:09:24 -07:00
parent 0ffd985972
commit 06aca7edaa
3 changed files with 5 additions and 2 deletions

View File

@ -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_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ignore_relative_mode)
{ {
SDL_Mouse *mouse = SDL_GetMouse(); SDL_Mouse *mouse = SDL_GetMouse();

View File

@ -152,6 +152,9 @@ extern int SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, U
/* Send a mouse wheel event */ /* Send a mouse wheel event */
extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction); 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 */ /* Shutdown the mouse subsystem */
extern void SDL_MouseQuit(void); extern void SDL_MouseQuit(void);

View File

@ -3038,7 +3038,7 @@ SDL_OnWindowFocusGained(SDL_Window * window)
if (mouse && mouse->relative_mode) { if (mouse && mouse->relative_mode) {
SDL_SetMouseFocus(window); SDL_SetMouseFocus(window);
if (mouse->relative_mode_warp) { 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);
} }
} }