mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 05:21:31 +11:00
Send modifiers first
This commit is contained in:
parent
a7a8ff0bbb
commit
e17977d7c7
|
@ -134,7 +134,7 @@ impl<T> EventLoopWindowTarget<T> {
|
||||||
let modifiers = self.modifiers.clone();
|
let modifiers = self.modifiers.clone();
|
||||||
canvas.on_keyboard_press(
|
canvas.on_keyboard_press(
|
||||||
move |physical_key, logical_key, text, location, repeat, active_modifiers| {
|
move |physical_key, logical_key, text, location, repeat, active_modifiers| {
|
||||||
let modifiers_changed = (modifiers.get() != active_modifiers).then(|| {
|
let modifiers = (modifiers.get() != active_modifiers).then(|| {
|
||||||
modifiers.set(active_modifiers);
|
modifiers.set(active_modifiers);
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
window_id: RootWindowId(id),
|
window_id: RootWindowId(id),
|
||||||
|
@ -142,25 +142,22 @@ impl<T> EventLoopWindowTarget<T> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
runner.send_events(
|
runner.send_events(modifiers.into_iter().chain(iter::once(Event::WindowEvent {
|
||||||
iter::once(Event::WindowEvent {
|
window_id: RootWindowId(id),
|
||||||
window_id: RootWindowId(id),
|
event: WindowEvent::KeyboardInput {
|
||||||
event: WindowEvent::KeyboardInput {
|
device_id: RootDeviceId(unsafe { DeviceId::dummy() }),
|
||||||
device_id: RootDeviceId(unsafe { DeviceId::dummy() }),
|
event: KeyEvent {
|
||||||
event: KeyEvent {
|
physical_key,
|
||||||
physical_key,
|
logical_key,
|
||||||
logical_key,
|
text,
|
||||||
text,
|
location,
|
||||||
location,
|
state: ElementState::Pressed,
|
||||||
state: ElementState::Pressed,
|
repeat,
|
||||||
repeat,
|
platform_specific: KeyEventExtra,
|
||||||
platform_specific: KeyEventExtra,
|
|
||||||
},
|
|
||||||
is_synthetic: false,
|
|
||||||
},
|
},
|
||||||
})
|
is_synthetic: false,
|
||||||
.chain(modifiers_changed),
|
},
|
||||||
);
|
})));
|
||||||
},
|
},
|
||||||
prevent_default,
|
prevent_default,
|
||||||
);
|
);
|
||||||
|
@ -169,7 +166,7 @@ impl<T> EventLoopWindowTarget<T> {
|
||||||
let modifiers = self.modifiers.clone();
|
let modifiers = self.modifiers.clone();
|
||||||
canvas.on_keyboard_release(
|
canvas.on_keyboard_release(
|
||||||
move |physical_key, logical_key, text, location, repeat, active_modifiers| {
|
move |physical_key, logical_key, text, location, repeat, active_modifiers| {
|
||||||
let modifiers_changed = (modifiers.get() != active_modifiers).then(|| {
|
let modifiers = (modifiers.get() != active_modifiers).then(|| {
|
||||||
modifiers.set(active_modifiers);
|
modifiers.set(active_modifiers);
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
window_id: RootWindowId(id),
|
window_id: RootWindowId(id),
|
||||||
|
@ -177,25 +174,22 @@ impl<T> EventLoopWindowTarget<T> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
runner.send_events(
|
runner.send_events(modifiers.into_iter().chain(iter::once(Event::WindowEvent {
|
||||||
iter::once(Event::WindowEvent {
|
window_id: RootWindowId(id),
|
||||||
window_id: RootWindowId(id),
|
event: WindowEvent::KeyboardInput {
|
||||||
event: WindowEvent::KeyboardInput {
|
device_id: RootDeviceId(unsafe { DeviceId::dummy() }),
|
||||||
device_id: RootDeviceId(unsafe { DeviceId::dummy() }),
|
event: KeyEvent {
|
||||||
event: KeyEvent {
|
physical_key,
|
||||||
physical_key,
|
logical_key,
|
||||||
logical_key,
|
text,
|
||||||
text,
|
location,
|
||||||
location,
|
state: ElementState::Released,
|
||||||
state: ElementState::Released,
|
repeat,
|
||||||
repeat,
|
platform_specific: KeyEventExtra,
|
||||||
platform_specific: KeyEventExtra,
|
|
||||||
},
|
|
||||||
is_synthetic: false,
|
|
||||||
},
|
},
|
||||||
})
|
is_synthetic: false,
|
||||||
.chain(modifiers_changed),
|
},
|
||||||
)
|
})))
|
||||||
},
|
},
|
||||||
prevent_default,
|
prevent_default,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue