-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Handle winit's WindowEvent::ModifiersChanged
#13357
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
base: main
Are you sure you want to change the base?
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
WindowEvent::ModifiersChanged
crates/bevy_winit/src/lib.rs
Outdated
// Send a `KeyboardInput` event if this key is not a modifier. | ||
let keyboard_event = converters::convert_keyboard_input(event, window); | ||
let mod_keys = [Key::Alt, Key::Control, Key::Shift, Key::Super]; | ||
if !mod_keys.contains(&keyboard_event.logical_key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to make this re-sending conditional? Don't we want to retain the old behavior on all other platforms (which don't send ModifiersChanged
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh sorry I didn't realize ModifiersChanged
isn't triggered on other platforms. Windows looks to be working again in
c25df8f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I left the conditional re-sending on MacOS to avoid duplicating events - WindowEvent::KeyboardInput
and ModifiersChanged
seem to be triggered at the same time except with the native overlay scenario
this feels like it should be fixed in Winit rather than in Bevy in the issue you mention this works correctly with winit example, so I would prefer more investigation done before doing that many platform-specific things there |
I totally agree 👍 (unless winit does have a reason) What I saw in that example is winit does provide the input events, just in this alternative way. It feels weird for them to provide a |
I got some more information from Not 100% sure I understand but it does sound like we'd still want to handle |
Looking at the code, it's not clear to me why this change is macOS specific. Do these modifiers not also exist on all operating systems? |
It looks like this special handling is only needed on MacOS because of their native overlays (stuff like screenshot and the UI I showed in my issue). It feels like the biggest subtle platform difference I've seen with Winit 🤔 |
@matthunz would there be a problem with using this new code on all platforms? I understand that they probably don't do much with it, but it would be nicer if all platforms were handled equally imo. |
@janhohenheim Not sure how it'd affect other platforms 🤔 it might be fine, or even required if maybe GTK or Windows have similar issues? I only know of those OS overlays for Mac so far though |
I see that @alice-i-cecile wanted to "retain the old behavior on all other platforms". This sounds like an increase in maintenance cost to be, but I must admit that I have no clue about |
Objective
KeyboardInput
events not being triggered by MacOS native overlays #13356Solution
WindowEvent::KeyboardInput
toModifiersChanged
. Currently these are the only events triggered when MacOS native overlays interrupt the app.Testing
Works for me on MacOS sonoma 😄 no breaking changes that I can see