Winit: No mouse events when unfocused on macOS

Created on 20 Jun 2019  路  4Comments  路  Source: rust-windowing/winit

This has been reported to Alacritty in https://github.com/jwilm/alacritty/issues/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 https://github.com/rust-windowing/winit/issues/883, but it might still make sense to report motions above the unfocused window, since I'm pretty sure other platforms do that?

macOS needs investigation bug

Most helpful comment

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

All 4 comments

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

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

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexheretic picture alexheretic  路  4Comments

k0nserv picture k0nserv  路  3Comments

hobogenized picture hobogenized  路  3Comments

tomaka picture tomaka  路  3Comments

coderhwz picture coderhwz  路  3Comments