From 3722275cfaf7a2324164d194c44138771210e1d0 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Tue, 11 Jun 2024 11:00:26 +0200 Subject: [PATCH] linux/x11: Only create ModifiersChanged event if they changed (#12879) I noticed that when I use my mouse wheel, we get a ton of the `XkbStateNotify` events, but the modifiers don't change, so we add a ton of useless input events for the window. Release Notes: - N/A --- crates/gpui/src/platform/linux/x11/client.rs | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index bd3d3e3e6b..b91f9e165c 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -524,15 +524,20 @@ impl X11Client { 0, event.locked_group.into(), ); - let modifiers = Modifiers::from_xkb(&state.xkb); - let focused_window_id = state.focused_window?; - state.modifiers = modifiers; - drop(state); - let focused_window = self.get_window(focused_window_id)?; - focused_window.handle_input(PlatformInput::ModifiersChanged( - ModifiersChangedEvent { modifiers }, - )); + let modifiers = Modifiers::from_xkb(&state.xkb); + if state.modifiers == modifiers { + drop(state); + } else { + let focused_window_id = state.focused_window?; + state.modifiers = modifiers; + drop(state); + + let focused_window = self.get_window(focused_window_id)?; + focused_window.handle_input(PlatformInput::ModifiersChanged( + ModifiersChangedEvent { modifiers }, + )); + } } Event::KeyPress(event) => { let window = self.get_window(event.event)?;