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

Report mouse motion before click #1490

Merged
merged 3 commits into from
Apr 26, 2020

Conversation

chrisduerr
Copy link
Contributor

This fixes an issue on macOS where a mouse click would be generated,
without ever getting a mouse motion to the position before the click.
This leads to the application thinking the mouse click occurred at a
position other than the actual mouse location.

This happens due to mouse motion above the window not automatically
giving focus to the window, unless it is actually clicked, making it
possible to move the window without motion events.

Fixes #942.

@ryanisaacg ryanisaacg added DS - macos C - waiting on maintainer A maintainer must review this code labels Mar 3, 2020
chrisduerr added a commit to chrisduerr/winit that referenced this pull request Mar 7, 2020
There are two PRs I'm aware of that should be relatively trivial to get
merged, which would fix some issues. Other than those, I don't think it
makes sense to wait on anything.

 - Fix Windows crash: rust-windowing#1459
 - Fix macOS mouse reports: rust-windowing#1490

While rust-windowing#1459 seems pretty essential to actually make winit run, rust-windowing#1490 is
much less important and can probably be ignored if there aren't any
resources to merge it.
Osspial pushed a commit that referenced this pull request Mar 9, 2020
There are two PRs I'm aware of that should be relatively trivial to get
merged, which would fix some issues. Other than those, I don't think it
makes sense to wait on anything.

 - Fix Windows crash: #1459
 - Fix macOS mouse reports: #1490

While #1459 seems pretty essential to actually make winit run, #1490 is
much less important and can probably be ignored if there aren't any
resources to merge it.
@SergeevPavel
Copy link

Could we also trigger mouse motion before mouse wheel event?

This fixes an issue on macOS where a mouse click would be generated,
without ever getting a mouse motion to the position before the click.
This leads to the application thinking the mouse click occurred at a
position other than the actual mouse location.

This happens due to mouse motion above the window not automatically
giving focus to the window, unless it is actually clicked, making it
possible to move the window without motion events.

Fixes rust-windowing#942.
@chrisduerr
Copy link
Contributor Author

I've added it for pressure change and scroll too, since that makes some sense.

@chrisduerr
Copy link
Contributor Author

Test failure on Windows should be unrelated to this macOS PR.

@ryanisaacg
Copy link
Contributor

I merged master into this branch which should solve the CI conflicts and get this ready for a merge.

@QuentinPerez
Copy link

QuentinPerez commented Apr 25, 2020

I have the same issue thank you for the patch, I was wondering if we could add x and y in the mouseClick event instead of doing magic like saving the last x,y sent by the last Mouse::CursorMoved ?

@ryanisaacg
Copy link
Contributor

@QuentinPerez Do you mean in the external Winit API?

@QuentinPerez
Copy link

QuentinPerez commented Apr 25, 2020

Yes, like

position: PhysicalPosition<f64>,
but for
MouseInput {
don't know if it's the best way to do things.

I'm using iced and I would like to draw a point when I click on the canvas but for that, I need to store the last position received by CursorMoved to know where I can draw on the MouseInput event.

@ryanisaacg
Copy link
Contributor

@QuentinPerez That discussion is probably best for a meta-issue on the tracker, like this previous issue.. This PR is fixing an internal bug regarding emitting the CursorMoved on macOS, specifically.

@ryanisaacg ryanisaacg merged commit 26775fa into rust-windowing:master Apr 26, 2020
@chrisduerr chrisduerr deleted the move-on-click branch April 26, 2020 20:46
kunalarya pushed a commit to kunalarya/winit that referenced this pull request Sep 11, 2020
* Report mouse motion before click

This fixes an issue on macOS where a mouse click would be generated,
without ever getting a mouse motion to the position before the click.
This leads to the application thinking the mouse click occurred at a
position other than the actual mouse location.

This happens due to mouse motion above the window not automatically
giving focus to the window, unless it is actually clicked, making it
possible to move the window without motion events.

Fixes rust-windowing#942.

* Add additional mouse motion events

Co-authored-by: Ryan Goldstein <ryan@ryanisaacg.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - waiting on maintainer A maintainer must review this code DS - macos
Development

Successfully merging this pull request may close these issues.

No mouse events when unfocused on macOS
4 participants