From a444637b18f8f0f54a33162c4e476439374e9950 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Tue, 13 Jun 2023 23:16:46 +0200 Subject: [PATCH] Revert "Send modifiers first" This reverts commit e17977d7c79153f11fa9fd9887f53215d1c6d925. --- .../web/event_loop/window_target.rs | 70 ++++++++++--------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/src/platform_impl/web/event_loop/window_target.rs b/src/platform_impl/web/event_loop/window_target.rs index c3c91076..d39de982 100644 --- a/src/platform_impl/web/event_loop/window_target.rs +++ b/src/platform_impl/web/event_loop/window_target.rs @@ -134,7 +134,7 @@ impl EventLoopWindowTarget { let modifiers = self.modifiers.clone(); canvas.on_keyboard_press( move |physical_key, logical_key, text, location, repeat, active_modifiers| { - let modifiers = (modifiers.get() != active_modifiers).then(|| { + let modifiers_changed = (modifiers.get() != active_modifiers).then(|| { modifiers.set(active_modifiers); Event::WindowEvent { window_id: RootWindowId(id), @@ -142,22 +142,25 @@ impl EventLoopWindowTarget { } }); - runner.send_events(modifiers.into_iter().chain(iter::once(Event::WindowEvent { - window_id: RootWindowId(id), - event: WindowEvent::KeyboardInput { - device_id: RootDeviceId(unsafe { DeviceId::dummy() }), - event: KeyEvent { - physical_key, - logical_key, - text, - location, - state: ElementState::Pressed, - repeat, - platform_specific: KeyEventExtra, + runner.send_events( + iter::once(Event::WindowEvent { + window_id: RootWindowId(id), + event: WindowEvent::KeyboardInput { + device_id: RootDeviceId(unsafe { DeviceId::dummy() }), + event: KeyEvent { + physical_key, + logical_key, + text, + location, + state: ElementState::Pressed, + repeat, + platform_specific: KeyEventExtra, + }, + is_synthetic: false, }, - is_synthetic: false, - }, - }))); + }) + .chain(modifiers_changed), + ); }, prevent_default, ); @@ -166,7 +169,7 @@ impl EventLoopWindowTarget { let modifiers = self.modifiers.clone(); canvas.on_keyboard_release( move |physical_key, logical_key, text, location, repeat, active_modifiers| { - let modifiers = (modifiers.get() != active_modifiers).then(|| { + let modifiers_changed = (modifiers.get() != active_modifiers).then(|| { modifiers.set(active_modifiers); Event::WindowEvent { window_id: RootWindowId(id), @@ -174,22 +177,25 @@ impl EventLoopWindowTarget { } }); - runner.send_events(modifiers.into_iter().chain(iter::once(Event::WindowEvent { - window_id: RootWindowId(id), - event: WindowEvent::KeyboardInput { - device_id: RootDeviceId(unsafe { DeviceId::dummy() }), - event: KeyEvent { - physical_key, - logical_key, - text, - location, - state: ElementState::Released, - repeat, - platform_specific: KeyEventExtra, + runner.send_events( + iter::once(Event::WindowEvent { + window_id: RootWindowId(id), + event: WindowEvent::KeyboardInput { + device_id: RootDeviceId(unsafe { DeviceId::dummy() }), + event: KeyEvent { + physical_key, + logical_key, + text, + location, + state: ElementState::Released, + repeat, + platform_specific: KeyEventExtra, + }, + is_synthetic: false, }, - is_synthetic: false, - }, - }))) + }) + .chain(modifiers_changed), + ) }, prevent_default, );