Skip to content

Commit

Permalink
fix(linux): clear shortcuts instead of replacing it (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Apr 18, 2023
1 parent 9f271f1 commit ee5dc41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/clear-shortuts-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": "patch"
---

On Linux, fix `ShortcutManager::unregister_all` making `ShortcutManager::register` succeed but no events are triggered.
5 changes: 3 additions & 2 deletions src/platform_impl/linux/global_shortcut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down

0 comments on commit ee5dc41

Please sign in to comment.