From 969519b5d8b163e61d74e9c1a7e525a2d11bc7e6 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 22 Mar 2024 11:11:45 +0400 Subject: input: Generalize bound_action() to Trigger --- src/input.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index e6598719..0c106e20 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1696,13 +1696,14 @@ fn action( _ => (), } - bound_action(bindings, comp_mod, raw, mods) + let trigger = Trigger::Keysym(raw?); + bound_action(bindings, comp_mod, trigger, mods) } fn bound_action( bindings: &Binds, comp_mod: CompositorMod, - raw: Option, + trigger: Trigger, mods: ModifiersState, ) -> Option { // Handle configured binds. @@ -1728,10 +1729,8 @@ fn bound_action( modifiers |= Modifiers::COMPOSITOR; } - let raw = raw?; - for bind in &bindings.0 { - if bind.key.trigger != Trigger::Keysym(raw) { + if bind.key.trigger != trigger { continue; } @@ -2072,7 +2071,7 @@ mod tests { bound_action( &bindings, CompositorMod::Super, - Some(Keysym::q), + Trigger::Keysym(Keysym::q), ModifiersState { logo: true, ..Default::default() @@ -2084,7 +2083,7 @@ mod tests { bound_action( &bindings, CompositorMod::Super, - Some(Keysym::q), + Trigger::Keysym(Keysym::q), ModifiersState::default(), ), None, @@ -2094,7 +2093,7 @@ mod tests { bound_action( &bindings, CompositorMod::Super, - Some(Keysym::h), + Trigger::Keysym(Keysym::h), ModifiersState { logo: true, ..Default::default() @@ -2106,7 +2105,7 @@ mod tests { bound_action( &bindings, CompositorMod::Super, - Some(Keysym::h), + Trigger::Keysym(Keysym::h), ModifiersState::default(), ), None, @@ -2116,7 +2115,7 @@ mod tests { bound_action( &bindings, CompositorMod::Super, - Some(Keysym::j), + Trigger::Keysym(Keysym::j), ModifiersState { logo: true, ..Default::default() @@ -2128,7 +2127,7 @@ mod tests { bound_action( &bindings, CompositorMod::Super, - Some(Keysym::j), + Trigger::Keysym(Keysym::j), ModifiersState::default(), ), Some(Action::FocusWindowDown) @@ -2138,7 +2137,7 @@ mod tests { bound_action( &bindings, CompositorMod::Super, - Some(Keysym::k), + Trigger::Keysym(Keysym::k), ModifiersState { logo: true, ..Default::default() @@ -2150,7 +2149,7 @@ mod tests { bound_action( &bindings, CompositorMod::Super, - Some(Keysym::k), + Trigger::Keysym(Keysym::k), ModifiersState::default(), ), None, @@ -2160,7 +2159,7 @@ mod tests { bound_action( &bindings, CompositorMod::Super, - Some(Keysym::l), + Trigger::Keysym(Keysym::l), ModifiersState { logo: true, alt: true, @@ -2173,7 +2172,7 @@ mod tests { bound_action( &bindings, CompositorMod::Super, - Some(Keysym::l), + Trigger::Keysym(Keysym::l), ModifiersState { logo: true, ..Default::default() -- cgit