Repository navigation
fix(sdl): keep the mouse captured when the pointer leaves the window - #1251
Merged
Merged
Conversation
SDL's Wayland back end sends a window LEAVE in the same millisecond the relative mouse mode is turned on, and the handler released the capture there: the click that captured the mouse released it again before the first motion. On GNOME Wayland the native mouse look turned nothing, and the mouse buttons bound on the Controls page did nothing. Windows releases the capture on WM_KILLFOCUS alone (host/display.c): the capture goes with the window's focus, not with the pointer. Do the same here; ptr_in still ends, so the Insert menu's hover state is right. Tested on Fedora 44, GNOME 50.6 Wayland, GTX 1650 (driver 615.78.08): before, the capture was gone in under a millisecond of the click; after, the native camera and the mouse-bound buttons work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On Linux/Wayland (GNOME/Mutter), a click in the window turns the relative mouse mode on and SDL sends a
window
LEAVEin the same millisecond.host/posix/display_sdl.creleased the capture on that event, so themouse was free again after ~0 ms: with
Mouse camera = Nativethe camera turned nothing, and the mouse buttonsbound on the Insert menu's Controls page did nothing.
The capture now stays while the window has the focus, as it does on Windows.
Why this is a port bug, not a feature
host/display.c(Windows) releases the capture onWM_KILLFOCUSalone: the capture follows the window's focus,not the pointer. The SDL port also released on the window's leave event, and on Wayland that event is not "the
pointer went out"; it is part of turning relative mode on.
Change
host/posix/display_sdl.c:HOS_SDL_EV_MOUSE_LEAVEno longer callsmouse_capture(0); it still clearsptr_in,so the Insert menu's hover state stays right.
Testing
main.mouse-bound buttons did not work.
the mouse; the Insert menu still gets a free pointer and its clicks.
and both still release on focus loss.
Notes
I can split this into an issue first if you prefer to track it there. No game files are involved.