Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,18 +715,25 @@ impl App {
_ => Message::None,
}),
iced::output_events().map(Message::OutputEvent),
listen_with(move |evt, _, _| match evt {
iced::event::Event::Keyboard(keyboard::Event::KeyPressed { key, .. }) => {
debug!("Keyboard event received: {key:?}");
if matches!(key, keyboard::Key::Named(keyboard::key::Named::Escape)) {
debug!("ESC key pressed, closing all menus");
Some(Message::CloseAllMenus)
} else {
None
// Only listen while Escape can close a menu; an idle listener
// subscription still receives every interaction event and would
// overflow iced's fixed-size event channel for nothing.
if self.general_config.enable_esc_key && self.outputs.menu_is_open() {
listen_with(|evt, _, _| match evt {
iced::event::Event::Keyboard(keyboard::Event::KeyPressed { key, .. }) => {
debug!("Keyboard event received: {key:?}");
if matches!(key, keyboard::Key::Named(keyboard::key::Named::Escape)) {
debug!("ESC key pressed, closing all menus");
Some(Message::CloseAllMenus)
} else {
None
}
}
}
_ => None,
}),
_ => None,
})
} else {
Subscription::none()
},
Subscription::run(|| match signal_hook_tokio::Signals::new([libc::SIGUSR1]) {
Ok(signals) => signals
.filter_map(|sig| {
Expand Down