aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/input.rs b/src/input.rs
index 595be712..f82de8a0 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -57,6 +57,13 @@ impl State {
let hide_hotkey_overlay =
self.niri.hotkey_overlay.is_open() && should_hide_hotkey_overlay(&event);
+ let hide_exit_confirm_dialog = self
+ .niri
+ .exit_confirm_dialog
+ .as_ref()
+ .map_or(false, |d| d.is_open())
+ && should_hide_exit_confirm_dialog(&event);
+
use InputEvent::*;
match event {
DeviceAdded { device } => self.on_device_added(device),
@@ -91,6 +98,12 @@ impl State {
if hide_hotkey_overlay && self.niri.hotkey_overlay.hide() {
self.niri.queue_redraw_all();
}
+
+ if let Some(dialog) = &mut self.niri.exit_confirm_dialog {
+ if hide_exit_confirm_dialog && dialog.hide() {
+ self.niri.queue_redraw_all();
+ }
+ }
}
pub fn process_libinput_event(&mut self, event: &mut InputEvent<LibinputInputBackend>) {
@@ -204,6 +217,13 @@ impl State {
let key_code = event.key_code();
let modified = keysym.modified_sym();
let raw = keysym.raw_latin_sym_or_raw_current_sym();
+
+ if let Some(dialog) = &this.niri.exit_confirm_dialog {
+ if dialog.is_open() && pressed && raw == Some(Keysym::Return) {
+ this.niri.stop_signal.stop();
+ }
+ }
+
should_intercept_key(
&mut this.niri.suppressed_keys,
bindings,
@@ -232,8 +252,14 @@ impl State {
match action {
Action::Quit => {
- info!("quitting because quit bind was pressed");
- self.niri.stop_signal.stop()
+ if let Some(dialog) = &mut self.niri.exit_confirm_dialog {
+ if dialog.show() {
+ self.niri.queue_redraw_all();
+ }
+ } else {
+ info!("quitting because quit bind was pressed");
+ self.niri.stop_signal.stop()
+ }
}
Action::ChangeVt(vt) => {
self.backend.change_vt(vt);
@@ -1401,6 +1427,21 @@ fn should_hide_hotkey_overlay<I: InputBackend>(event: &InputEvent<I>) -> bool {
}
}
+fn should_hide_exit_confirm_dialog<I: InputBackend>(event: &InputEvent<I>) -> bool {
+ match event {
+ InputEvent::Keyboard { event } if event.state() == KeyState::Pressed => true,
+ InputEvent::PointerButton { .. }
+ | InputEvent::PointerAxis { .. }
+ | InputEvent::GestureSwipeBegin { .. }
+ | InputEvent::GesturePinchBegin { .. }
+ | InputEvent::TouchDown { .. }
+ | InputEvent::TouchMotion { .. }
+ | InputEvent::TabletToolTip { .. }
+ | InputEvent::TabletToolButton { .. } => true,
+ _ => false,
+ }
+}
+
fn allowed_when_locked(action: &Action) -> bool {
matches!(
action,