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

No mouse events when unfocused on macOS #942

Closed
chrisduerr opened this issue Jun 20, 2019 · 4 comments · Fixed by #1490
Closed

No mouse events when unfocused on macOS #942

chrisduerr opened this issue Jun 20, 2019 · 4 comments · Fixed by #1490
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos

Comments

@chrisduerr
Copy link
Contributor

This has been reported to Alacritty in alacritty/alacritty#2475.

It looks like winit does not report mouse movements inside the window if it is currently unfocused. This makes it difficult to track mouse click positions since the mouse can "teleport" into position without being able to track it.

If this is an intentional design decision, I think that there's no way around reporting mouse position on click events, since a click might come in without any previous motion events at all.

This could be resolved with #883, but it might still make sense to report motions above the unfocused window, since I'm pretty sure other platforms do that?

@Osspial
Copy link
Contributor

Osspial commented Jun 20, 2019

I'm pretty sure this is unintentional. Windows, at least, does indeed report mouse motion above unfocused windows.

@goddessfreya
Copy link
Contributor

And X11 reports everything, including keyboard events to other programs (RIP security).

chrisduerr added a commit to chrisduerr/winit that referenced this issue Mar 1, 2020
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 added a commit to chrisduerr/winit that referenced this issue Mar 1, 2020
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 added a commit to chrisduerr/winit that referenced this issue Mar 26, 2020
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.
ryanisaacg added a commit that referenced this issue Apr 26, 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 #942.

* Add additional mouse motion events

Co-authored-by: Ryan Goldstein <[email protected]>
@SergeevPavel
Copy link

What if I want to change something in my window after just mouse move? E.g. highlight item on hover. It will work on unfocused window on linux but will not on macos. So I think this issue need more general fix.

@chrisduerr
Copy link
Contributor Author

I don't think there's any intention to report mouse reports on unfocused windows on all platforms.

In fact, some platforms like Wayland will do their best to prevent you from getting that information.

If you want the user to interact with the window in any way, it has to be focused.

kunalarya pushed a commit to kunalarya/winit that referenced this issue 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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos
Development

Successfully merging a pull request may close this issue.

5 participants