From 8fb95034e84ded56bceb6b12d36a2864222582a4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 2 Apr 2021 12:52:21 +0900 Subject: [PATCH] Avoid warping the cursor to the center of the window when not in relative_warp_mode When relative mode is enabled and not using warp mode, the cursor is being clipped to the window. Therefore there is no reason to restore the cursor position to the center. Avoiding the warp to center simplifies mouse position event flow, as we are no longer potentially receiving mouse events for the automated movement of the cursor and can be (mostly) assured that an incoming event from the windowing system is that of external means. --- src/events/SDL_mouse.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 67cf22ab0..a776bcca8 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -819,11 +819,10 @@ SDL_SetRelativeMouseMode(SDL_bool enabled) mouse->scale_accum_y = 0.0f; if (enabled && focusWindow) { - /* Center it in the focused window to prevent clicks from going through - * to background windows. - */ SDL_SetMouseFocus(focusWindow); - SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2); + + if (mouse->relative_mode_warp) + SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2); } if (mouse->focus) {