fix(wayland): fix keyboard holding onto surfaces without causing visual or functional issues

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-05-06 00:31:01 +02:00
committed by Nova
parent 0a005b9864
commit db30f8e61b
2 changed files with 7 additions and 0 deletions

View File

@@ -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()) {

View File

@@ -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();
}
}