From 3b60c62f82668ac023ac534791b52b829fbbb8b8 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Sun, 7 Sep 2025 12:58:23 +0200 Subject: [PATCH] seat: properly destroy physical devices when changing keymap --- src/ifs/wl_seat.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ifs/wl_seat.rs b/src/ifs/wl_seat.rs index bce5bcb2..5af33bdd 100644 --- a/src/ifs/wl_seat.rs +++ b/src/ifs/wl_seat.rs @@ -523,14 +523,22 @@ impl WlSeatGlobal { false } - pub fn set_seat_keymap(&self, keymap: &Rc) { + pub fn set_seat_keymap(self: &Rc, keymap: &Rc) { self.seat_kb_map.set(keymap.clone()); let new = self.get_kb_state(keymap); let old = self.seat_kb_state.set(new.clone()); if rc_eq(&old, &new) { return; } - self.kb_devices.lock().retain(|_, p| p.has_custom_map.get()); + let mut to_destroy = vec![]; + for (id, s) in self.kb_devices.lock().iter() { + if !s.has_custom_map.get() { + to_destroy.push(*id); + } + } + for dev in to_destroy { + self.destroy_physical_keyboard(dev); + } { let new = &*new.borrow(); self.modifiers_listener.attach(&new.kb_state.mods_changed);