mirror of https://github.com/encounter/SDL.git
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.
This commit is contained in:
parent
4359a47b3e
commit
8fb95034e8
|
@ -819,10 +819,9 @@ SDL_SetRelativeMouseMode(SDL_bool enabled)
|
||||||
mouse->scale_accum_y = 0.0f;
|
mouse->scale_accum_y = 0.0f;
|
||||||
|
|
||||||
if (enabled && focusWindow) {
|
if (enabled && focusWindow) {
|
||||||
/* Center it in the focused window to prevent clicks from going through
|
|
||||||
* to background windows.
|
|
||||||
*/
|
|
||||||
SDL_SetMouseFocus(focusWindow);
|
SDL_SetMouseFocus(focusWindow);
|
||||||
|
|
||||||
|
if (mouse->relative_mode_warp)
|
||||||
SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2);
|
SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue