From b9116c579a6e99cae5393912fc9ed28674f5d3e5 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 8 Feb 2024 13:51:54 +0400 Subject: Implement idle-notify and idle-inhibit --- src/input.rs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/input.rs') 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(event: &InputEvent) -> bo } } +fn should_notify_activity(event: &InputEvent) -> bool { + match event { + InputEvent::DeviceAdded { .. } | InputEvent::DeviceRemoved { .. } => false, + _ => true, + } +} + fn allowed_when_locked(action: &Action) -> bool { matches!( action, -- cgit