aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-01-18 19:20:46 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-01-18 20:32:44 +0400
commit011c91c98a76880744d35afa763c20db074d9c90 (patch)
tree035410f1a48769b3dd7f78417d673adcc81eb8aa /src/input.rs
parentedafa139f6296ec8b23906978f4798338877f28d (diff)
downloadniri-011c91c98a76880744d35afa763c20db074d9c90.tar.gz
niri-011c91c98a76880744d35afa763c20db074d9c90.tar.bz2
niri-011c91c98a76880744d35afa763c20db074d9c90.zip
Add an important hotkeys overlay
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/input.rs b/src/input.rs
index 293bda93..595be712 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -54,6 +54,9 @@ impl State {
self.niri.activate_monitors(&self.backend);
}
+ let hide_hotkey_overlay =
+ self.niri.hotkey_overlay.is_open() && should_hide_hotkey_overlay(&event);
+
use InputEvent::*;
match event {
DeviceAdded { device } => self.on_device_added(device),
@@ -82,6 +85,12 @@ impl State {
TouchFrame { .. } => (),
Special(_) => (),
}
+
+ // Do this last so that screenshot still gets it.
+ // FIXME: do this in a less cursed fashion somehow.
+ if hide_hotkey_overlay && self.niri.hotkey_overlay.hide() {
+ self.niri.queue_redraw_all();
+ }
}
pub fn process_libinput_event(&mut self, event: &mut InputEvent<LibinputInputBackend>) {
@@ -557,6 +566,11 @@ impl State {
Action::SetWindowHeight(change) => {
self.niri.layout.set_window_height(change);
}
+ Action::ShowHotkeyOverlay => {
+ if self.niri.hotkey_overlay.show() {
+ self.niri.queue_redraw_all();
+ }
+ }
}
}
@@ -1372,6 +1386,21 @@ fn should_activate_monitors<I: InputBackend>(event: &InputEvent<I>) -> bool {
}
}
+fn should_hide_hotkey_overlay<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,