From 18d9fabe9f718b9efd693c51d4ded99f91e6f3bd Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 30 Nov 2019 13:30:37 -0800 Subject: [PATCH] window: wayland: don't lose keystrokes after clicking titlebar --- window/src/os/wayland/keyboard.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/window/src/os/wayland/keyboard.rs b/window/src/os/wayland/keyboard.rs index a30fd2461..262c24247 100644 --- a/window/src/os/wayland/keyboard.rs +++ b/window/src/os/wayland/keyboard.rs @@ -19,8 +19,17 @@ struct Inner { impl Inner { fn handle_event(&mut self, evt: KbEvent) { + // Track the most recently entered window surface. + // We manually filter to the keys of surface_to_window_id + // because we may have auxilliary surfaces on our connection + // that were created by the window decorations and we don't + // want to suppress keyboard input if the user clicked in + // the titlebar. if let KbEvent::Enter { surface, .. } = &evt { - self.active_surface_id = surface.as_ref().id(); + let id = surface.as_ref().id(); + if self.surface_to_window_id.contains_key(&id) { + self.active_surface_id = id; + } } if let Some(event) = KeyboardEvent::from_event(evt) {