From 89349f2f3df431ecee1f87d6609b4ae38aa28930 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 10 Aug 2023 17:23:38 +0400 Subject: input: Only do events on key press --- src/input.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index b7704221..ca08c379 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,6 +1,6 @@ use smithay::backend::input::{ AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent, - KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent, + KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent, }; use smithay::input::keyboard::{keysyms, FilterResult}; use smithay::input::pointer::{AxisFrame, ButtonEvent, MotionEvent, RelativeMotionEvent}; @@ -34,13 +34,22 @@ impl Niri { event.state(), serial, time, - |_, mods, keysym| match keysym.modified_sym() { - keysyms::KEY_E if mods.logo => FilterResult::Intercept(InputAction::Quit), - keysym @ keysyms::KEY_XF86Switch_VT_1..=keysyms::KEY_XF86Switch_VT_12 => { - let vt = (keysym - keysyms::KEY_XF86Switch_VT_1 + 1) as i32; - FilterResult::Intercept(InputAction::ChangeVt(vt)) + |_, mods, keysym| { + if event.state() == KeyState::Pressed { + match keysym.modified_sym() { + keysyms::KEY_E if mods.logo => { + FilterResult::Intercept(InputAction::Quit) + } + keysym @ keysyms::KEY_XF86Switch_VT_1 + ..=keysyms::KEY_XF86Switch_VT_12 => { + let vt = (keysym - keysyms::KEY_XF86Switch_VT_1 + 1) as i32; + FilterResult::Intercept(InputAction::ChangeVt(vt)) + } + _ => FilterResult::Forward, + } + } else { + FilterResult::Forward } - _ => FilterResult::Forward, }, ); -- cgit