aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-02-08 13:51:54 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-02-09 15:50:40 +0400
commitb9116c579a6e99cae5393912fc9ed28674f5d3e5 (patch)
tree9b2a165b839154cca60f2efd626c26dd6b3a9d71 /src/input.rs
parentd8dcadc5b279c11e8cb8d1b0b064cc2b62c04099 (diff)
downloadniri-b9116c579a6e99cae5393912fc9ed28674f5d3e5.tar.gz
niri-b9116c579a6e99cae5393912fc9ed28674f5d3e5.tar.bz2
niri-b9116c579a6e99cae5393912fc9ed28674f5d3e5.zip
Implement idle-notify and idle-inhibit
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/input.rs b/src/input.rs
index 387969f3..30d8e100 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -49,9 +49,24 @@ impl State {
// here.
self.niri.layout.advance_animations(get_monotonic_time());
- // Power on monitors if they were off.
- if should_activate_monitors(&event) {
- self.niri.activate_monitors(&mut self.backend);
+ if self.niri.monitors_active {
+ // Notify the idle-notifier of activity.
+ if should_notify_activity(&event) {
+ self.niri
+ .idle_notifier_state
+ .notify_activity(&self.niri.seat);
+ }
+ } else {
+ // Power on monitors if they were off.
+ if should_activate_monitors(&event) {
+ self.niri.activate_monitors(&mut self.backend);
+
+ // Notify the idle-notifier of activity only if we're also powering on the
+ // monitors.
+ self.niri
+ .idle_notifier_state
+ .notify_activity(&self.niri.seat);
+ }
}
let hide_hotkey_overlay =
@@ -1497,6 +1512,13 @@ fn should_hide_exit_confirm_dialog<I: InputBackend>(event: &InputEvent<I>) -> bo
}
}
+fn should_notify_activity<I: InputBackend>(event: &InputEvent<I>) -> bool {
+ match event {
+ InputEvent::DeviceAdded { .. } | InputEvent::DeviceRemoved { .. } => false,
+ _ => true,
+ }
+}
+
fn allowed_when_locked(action: &Action) -> bool {
matches!(
action,