diff --git a/.changes/clear-shortuts-linux.md b/.changes/clear-shortuts-linux.md new file mode 100644 index 000000000..c0d8199a1 --- /dev/null +++ b/.changes/clear-shortuts-linux.md @@ -0,0 +1,5 @@ +--- +"tao": "patch" +--- + +On Linux, fix `ShortcutManager::unregister_all` making `ShortcutManager::register` succeed but no events are triggered. diff --git a/src/platform_impl/linux/global_shortcut.rs b/src/platform_impl/linux/global_shortcut.rs index 892c40553..b51892412 100644 --- a/src/platform_impl/linux/global_shortcut.rs +++ b/src/platform_impl/linux/global_shortcut.rs @@ -231,13 +231,14 @@ impl ShortcutManager { } pub(crate) fn unregister_all(&mut self) -> Result<(), ShortcutManagerError> { - for (found_id, _) in self.shortcuts.lock().unwrap().iter() { + let mut shortcuts = self.shortcuts.lock().unwrap(); + for (found_id, _) in shortcuts.iter() { self .method_sender .send(HotkeyMessage::UnregisterHotkey(*found_id)) .map_err(|_| ShortcutManagerError::InvalidAccelerator("Channel error".into()))?; } - self.shortcuts = ListenerMap::default(); + shortcuts.clear(); Ok(()) }