From 077714964535b51cfbffc651fdef3eba269f9273 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 11 Oct 2023 08:10:04 +0400 Subject: input: Exclude more events from powering on monitors --- src/input.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index 9f59c06e..6b6baa34 100644 --- a/src/input.rs +++ b/src/input.rs @@ -93,6 +93,27 @@ fn action( Action::None } +fn should_activate_monitors(event: &InputEvent) -> bool { + match event { + InputEvent::Keyboard { event } if event.state() == KeyState::Pressed => true, + InputEvent::PointerMotion { .. } + | InputEvent::PointerMotionAbsolute { .. } + | InputEvent::PointerButton { .. } + | InputEvent::PointerAxis { .. } + | InputEvent::GestureSwipeBegin { .. } + | InputEvent::GesturePinchBegin { .. } + | InputEvent::GestureHoldBegin { .. } + | InputEvent::TouchDown { .. } + | InputEvent::TouchMotion { .. } + | InputEvent::TabletToolAxis { .. } + | InputEvent::TabletToolProximity { .. } + | InputEvent::TabletToolTip { .. } + | InputEvent::TabletToolButton { .. } => true, + // Ignore events like device additions and removals, key releases, gesture ends. + _ => false, + } +} + impl State { pub fn process_input_event(&mut self, event: InputEvent) { let _span = tracy_client::span!("process_input_event"); @@ -104,9 +125,7 @@ impl State { self.niri.layout.advance_animations(get_monotonic_time()); // Power on monitors if they were off. - // HACK: ignore key releases so that the power-off-monitors bind can work. - if !matches!(&event, InputEvent::Keyboard { event } if event.state() == KeyState::Released) - { + if should_activate_monitors(&event) { self.niri.activate_monitors(&self.backend); } -- cgit