diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-11 08:10:04 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-11 08:10:04 +0400 |
| commit | 077714964535b51cfbffc651fdef3eba269f9273 (patch) | |
| tree | 6a999120f68052a24c610a4eb1078775717f56aa /src/input.rs | |
| parent | 71ae8dd0dabec4d7c1d25a4f7b2c274b50734513 (diff) | |
| download | niri-077714964535b51cfbffc651fdef3eba269f9273.tar.gz niri-077714964535b51cfbffc651fdef3eba269f9273.tar.bz2 niri-077714964535b51cfbffc651fdef3eba269f9273.zip | |
input: Exclude more events from powering on monitors
Diffstat (limited to 'src/input.rs')
| -rw-r--r-- | src/input.rs | 25 |
1 files changed, 22 insertions, 3 deletions
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<I: InputBackend>(event: &InputEvent<I>) -> 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<I: InputBackend>(&mut self, event: InputEvent<I>) { 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); } |
