Skip to content

Commit ba415ee

Browse files
authored
Merge pull request #183 from unsecretised/hotkey-reload-fix
fix hotkeys not being registered on config reload
2 parents 52b6949 + 9b81631 commit ba415ee

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/app/tile.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{app::apps::App, platform::default_app_paths};
1010

1111
use arboard::Clipboard;
1212
use global_hotkey::hotkey::HotKey;
13-
use global_hotkey::{GlobalHotKeyEvent, HotKeyState};
13+
use global_hotkey::{GlobalHotKeyEvent, GlobalHotKeyManager, HotKeyState};
1414

1515
use iced::futures::SinkExt;
1616
use iced::futures::channel::mpsc::{Sender, channel};
@@ -136,6 +136,14 @@ pub struct Hotkeys {
136136
pub clipboard_hotkey: HotKey,
137137
}
138138

139+
impl Hotkeys {
140+
pub fn register(&self) {
141+
let manager = GlobalHotKeyManager::new().unwrap();
142+
manager.register(self.toggle).ok();
143+
manager.register(self.clipboard_hotkey).ok();
144+
}
145+
}
146+
139147
impl Tile {
140148
/// This returns the theme of the window
141149
pub fn theme(&self, _: window::Id) -> Option<Theme> {

src/app/tile/update.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
278278
.unwrap_or(tile.hotkeys.clipboard_hotkey),
279279
};
280280

281+
tile.hotkeys.register();
282+
281283
tile.theme = new_config.theme.to_owned().into();
282284
tile.config = new_config;
283285
tile.options = AppIndex::from_apps(new_options);

0 commit comments

Comments
 (0)