From db30f8e61b8f03437ed2d6d152e3c0582e1fedb2 Mon Sep 17 00:00:00 2001 From: Schmarni Date: Tue, 6 May 2025 00:31:01 +0200 Subject: [PATCH] fix(wayland): fix keyboard holding onto surfaces without causing visual or functional issues Signed-off-by: Schmarni --- src/wayland/seat.rs | 6 ++++++ src/wayland/xdg_shell.rs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/wayland/seat.rs b/src/wayland/seat.rs index b525f33..d8d85f2 100644 --- a/src/wayland/seat.rs +++ b/src/wayland/seat.rs @@ -108,6 +108,12 @@ impl SeatWrapper { touches: Mutex::new(FxHashMap::default()), } } + pub fn unfocus_internal_state(&self, surface: &WlSurface) { + let Some(state) = self.wayland_state.upgrade() else { + return; + }; + self.unfocus(surface, &mut state.lock()); + } pub fn unfocus(&self, surface: &WlSurface, state: &mut WaylandState) { let pointer = self.seat.get_pointer().unwrap(); if pointer.current_focus() == Some(surface.clone()) { diff --git a/src/wayland/xdg_shell.rs b/src/wayland/xdg_shell.rs index e50561b..70d6656 100644 --- a/src/wayland/xdg_shell.rs +++ b/src/wayland/xdg_shell.rs @@ -472,6 +472,7 @@ impl Backend for XdgBackend { fn close_toplevel(&self) { if let Some(toplevel) = self.toplevel.lock().clone() { + self.seat.unfocus_internal_state(toplevel.wl_surface()); toplevel.send_close(); } }