Fix lost MouseButtonUp events when releasing mouse outside window (Linux/X11)#1018
Open
TheRedDeveloper wants to merge 1 commit into
Open
Fix lost MouseButtonUp events when releasing mouse outside window (Linux/X11)#1018TheRedDeveloper wants to merge 1 commit into
TheRedDeveloper wants to merge 1 commit into
Conversation
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.
Problem
On Linux (X11), macroquad was unconditionally calling
miniquad::window::set_cursor_grab(false)every frame inStage::updatewhen the cursor wasn't explicitly grabbed.This is problematic because miniquad's X11 implementation calls
XUngrabPointerwheneverset_cursor_grabis called. This cancels X11's "implicit passive grab" where it automatically routes events to the window when a mouse button is held down, even if the cursor leaves the window.As a result, dragging the mouse outside the window and releasing it would result in the application never receiving the MouseButtonUp event, getting stuck in a "pressed" state.
Solution
Contextto trackprevious_cursor_grabbedstate.cursor_grabbedistrue, we continue to callset_cursor_grab(true)every frame (maintaining existing functionality).cursor_grabbedisfalse, we only callset_cursor_grab(false)once, when the state transitions fromtruetofalse.After all, the
set_cursor_grab(true)needs to happen every frame to assert that the cursor is grabbed, butset_cursor_grab(false)needs to happen only once.Hope this helps!