Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS][X11] Release mouse capture when dialog shown #16205

Merged
merged 3 commits into from
Jul 3, 2024

Conversation

grokys
Copy link
Member

@grokys grokys commented Jul 2, 2024

What does the pull request do?

As described in #14525, mouse capture is released on Windows when a dialog is shown, but not on macOS. The issue doesn't mention it but we have the same problem on X11 too.

The fix for this is implemented in managed code. This is because:

  • macOS has no concept of "mouse capture" so there's no event we can listen to there to know when to release capture
  • X11 does have the concept but we don't use XGrabPointer currently, and the GrabNotify event which notifies of a pointer capture release isn't available on all X11 implementations anyway

The fix is implemented in WindowImpl.SetEnabled(false) as this is the point on Windows where WM_CANCELMODE is raised to inform us to release mouse capture: by doing it like this we match Windows' behavior.

Also added an integration test.

Fixed issues

Fixes #14525

Comment on lines +1327 to +1328
_mouse.PlatformCaptureLost();
_touch.PlatformCaptureLost();
Copy link
Member

@maxkatz6 maxkatz6 Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every day I am considering rewriting PointerDevice more and more. There are zero reasons to keep them separated.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0049724-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@grokys grokys added this pull request to the merge queue Jul 3, 2024
Merged via the queue into master with commit ae44889 Jul 3, 2024
12 checks passed
@grokys grokys deleted the fixes/14525-pointer-release branch July 3, 2024 09:51
Gillibald pushed a commit to Gillibald/Avalonia that referenced this pull request Jul 29, 2024
* Added integration test for AvaloniaUI#14525.

* Release mouse capture when dialog shown.

Fixes AvaloniaUI#14525.

* Release X11 pointer capture when dialog shown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pointer release not observed on Mac if pointer press opened a modal window
3 participants