-
Notifications
You must be signed in to change notification settings - Fork 941
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
Focused issue when creating multiple new windows at once. #1077
Comments
This is unfortunate. I think it would make sense if on all platforms, a lost focus on the old window then a got focus on the new window were both issued, in that order. @murarth Do you know what's the current behavior on x11?
I think that would be in scope. |
I've just tested on x11, and happily it does what you'd expect: New window WindowId(X(WindowId(48234497))) (although I did notice that I had to move the mouse to get the focus messages to appear?) |
What version of winit did you test? Master might have this delay fixed. |
I was building from master. |
I'm getting the same result as @hardiesoft for window creation events. However, I'm unable to reproduce any delay in events. Also, I'm getting another interesting thing: When switching windows using Alt-Tab, I'll get this:
|
From what I've seen, Winit is just reporting the focus events received from the underlying OS on all platforms. Since this seems to be consistently broken everywhere, it'd probably make sense to write some platform-agnostic code that processes the platform's focus events and makes sure Winit outputs events in a predictable way. |
Looks like this is also related to alacritty/alacritty#3139 Basically, the main issue is that winit is not consistent on whether windows are created with the focus or not. My suggestion would be to standardize towards "By default windows are created unfocused, and winit inserts a |
This was fixed for a long time. |
I have noticed different behavior of when the WindowEvent::Focused(bool) event is dispatched, depending whether you are on Windows or MacOS.
I've modified the multiwindow example here to illustrate these differences:
On running the example on windows I get the following output:
New window WindowId(WindowId(0x40e7a))
New window WindowId(WindowId(0x30edc))
Lost focus: WindowId(WindowId(0x40e7a))
On macos, I get:
New window WindowId(Id(140494821671056))
New window WindowId(Id(140494818628096))
Got focus: WindowId(Id(140494818628096))
The windows example seems more wrong than the macos example, since we never get an event for the second window that gained focus when the first window lost it.
Depending on your point of view though, the macos example could also be wrong if we're aiming for consistency with the model that each window gains focus when it is created, and loses it when another one is created afterwards.
I'm happy to put together a PR for this issue, but I'd first like to start some discussion around what the correct behavior should be.
As an aside, I also think winit is missing an APIs to programmatically set window focus and to control stacking order of windows. If it's agreed that those pieces of functionality are in scope for winit, then I'll write up issues for them.
The text was updated successfully, but these errors were encountered: