From ee5dc41f0071c9177304b3697d5b4c21c5734fd4 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Tue, 18 Apr 2023 07:22:59 +0200 Subject: [PATCH] fix(linux): clear shortcuts instead of replacing it (#724) --- .changes/clear-shortuts-linux.md | 5 +++++ src/platform_impl/linux/global_shortcut.rs | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changes/clear-shortuts-linux.md 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(()) }