aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hotkey_overlay.rs25
-rw-r--r--src/input.rs21
2 files changed, 31 insertions, 15 deletions
diff --git a/src/hotkey_overlay.rs b/src/hotkey_overlay.rs
index 15a46706..bfb263f4 100644
--- a/src/hotkey_overlay.rs
+++ b/src/hotkey_overlay.rs
@@ -155,13 +155,26 @@ fn render(config: &Config, comp_mod: CompositorMod, scale: i32) -> anyhow::Resul
let binds = &config.binds.0;
// Collect actions that we want to show.
- let mut actions = vec![
- &Action::ShowHotkeyOverlay,
- &Action::Quit,
- &Action::CloseWindow,
- ];
+ let mut actions = vec![&Action::ShowHotkeyOverlay];
+
+ // Prefer Quit(false) if found, otherwise try Quit(true), and if there's neither, fall back to
+ // Quit(false).
+ if binds
+ .iter()
+ .any(|bind| bind.actions.first() == Some(&Action::Quit(false)))
+ {
+ actions.push(&Action::Quit(false));
+ } else if binds
+ .iter()
+ .any(|bind| bind.actions.first() == Some(&Action::Quit(true)))
+ {
+ actions.push(&Action::Quit(true));
+ } else {
+ actions.push(&Action::Quit(false));
+ }
actions.extend(&[
+ &Action::CloseWindow,
&Action::FocusColumnLeft,
&Action::FocusColumnRight,
&Action::MoveColumnLeft,
@@ -365,7 +378,7 @@ fn render(config: &Config, comp_mod: CompositorMod, scale: i32) -> anyhow::Resul
fn action_name(action: &Action) -> String {
match action {
- Action::Quit => String::from("Exit niri"),
+ Action::Quit(_) => String::from("Exit niri"),
Action::ShowHotkeyOverlay => String::from("Show Important Hotkeys"),
Action::CloseWindow => String::from("Close Focused Window"),
Action::FocusColumnLeft => String::from("Focus Column to the Left"),
diff --git a/src/input.rs b/src/input.rs
index e941c57c..6c49ecdd 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -284,15 +284,18 @@ impl State {
}
match action {
- Action::Quit => {
- if let Some(dialog) = &mut self.niri.exit_confirm_dialog {
- if dialog.show() {
- self.niri.queue_redraw_all();
+ Action::Quit(skip_confirmation) => {
+ if !skip_confirmation {
+ if let Some(dialog) = &mut self.niri.exit_confirm_dialog {
+ if dialog.show() {
+ self.niri.queue_redraw_all();
+ }
+ return;
}
- } else {
- info!("quitting because quit bind was pressed");
- self.niri.stop_signal.stop()
}
+
+ info!("quitting as requested");
+ self.niri.stop_signal.stop()
}
Action::ChangeVt(vt) => {
self.backend.change_vt(vt);
@@ -1542,7 +1545,7 @@ fn should_notify_activity<I: InputBackend>(event: &InputEvent<I>) -> bool {
fn allowed_when_locked(action: &Action) -> bool {
matches!(
action,
- Action::Quit
+ Action::Quit(_)
| Action::ChangeVt(_)
| Action::Suspend
| Action::PowerOffMonitors
@@ -1553,7 +1556,7 @@ fn allowed_when_locked(action: &Action) -> bool {
fn allowed_during_screenshot(action: &Action) -> bool {
matches!(
action,
- Action::Quit | Action::ChangeVt(_) | Action::Suspend | Action::PowerOffMonitors
+ Action::Quit(_) | Action::ChangeVt(_) | Action::Suspend | Action::PowerOffMonitors
)
}