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

Automatically capture mouse on windows on mouse down #695

Merged
merged 3 commits into from
Mar 21, 2020

Conversation

teddemunnik
Copy link
Contributor

This pull requests adds functionality on windows to automatically capture mouse when the first mouse button down event is received, and holds the capture until the last mouse button is released, as proposed by @raphlinus in #457. This seemed like the best solution, since the standard behavior on Cocoa is to capture all mouse buttons.

Note that there is one windows specific edge case that still needs to be handled by the app, which is dealing with another app stealing mouse capture. Ideally we should expose this event outside of druid-shell to allow the app to do similar processing to mouse up, for example releasing the scroll bar.

self.captured_mouse_buttons &= !(1 << (button as u32));
if self.captured_mouse_buttons == 0 {
unsafe {
ReleaseCapture();
Copy link
Member

Choose a reason for hiding this comment

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

ReleaseCapture can return FALSE in case of error. Let's add some error logging here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, added a warn! there :)

Copy link
Member

@xStrom xStrom left a comment

Choose a reason for hiding this comment

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

Thanks for this improvement!

@xStrom xStrom merged commit 821dc39 into linebender:master Mar 21, 2020
@teddemunnik teddemunnik deleted the windows_mouse_capture branch April 9, 2020 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants