diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-02-09 16:23:05 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-02-09 16:23:05 +0400 |
| commit | 573dca10cc3edeb28f607c1830ff32d223cea240 (patch) | |
| tree | c1770d1a5821adc4bf7a1c220de8f2288c4c3ad9 /src | |
| parent | 577fba82e540d549ac2f2441a638e1d23d1f100d (diff) | |
| download | niri-573dca10cc3edeb28f607c1830ff32d223cea240.tar.gz niri-573dca10cc3edeb28f607c1830ff32d223cea240.tar.bz2 niri-573dca10cc3edeb28f607c1830ff32d223cea240.zip | |
input: Fix handling of binds with compositor mod but no explicit Mod
Diffstat (limited to 'src')
| -rw-r--r-- | src/input.rs | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/src/input.rs b/src/input.rs index 77424d35..2ebbf434 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1445,14 +1445,12 @@ fn bound_action( modifiers |= Modifiers::SUPER; } - let (mod_down, mut comp_mod) = match comp_mod { + let (mod_down, comp_mod) = match comp_mod { CompositorMod::Super => (mods.logo, Modifiers::SUPER), CompositorMod::Alt => (mods.alt, Modifiers::ALT), }; if mod_down { modifiers |= Modifiers::COMPOSITOR; - } else { - comp_mod = Modifiers::empty(); } let raw = raw?; @@ -1462,7 +1460,14 @@ fn bound_action( continue; } - if bind.key.modifiers | comp_mod == modifiers { + let mut bind_modifiers = bind.key.modifiers; + if bind_modifiers.contains(Modifiers::COMPOSITOR) { + bind_modifiers |= comp_mod; + } else if bind_modifiers.contains(comp_mod) { + bind_modifiers |= Modifiers::COMPOSITOR; + } + + if bind_modifiers == modifiers { return bind.actions.first().cloned(); } } @@ -1792,18 +1797,18 @@ mod tests { None, ); - // assert_eq!( - // bound_action( - // &bindings, - // CompositorMod::Super, - // Some(Keysym::h), - // ModifiersState { - // logo: true, - // ..Default::default() - // } - // ), - // Some(Action::FocusColumnLeft) - // ); + assert_eq!( + bound_action( + &bindings, + CompositorMod::Super, + Some(Keysym::h), + ModifiersState { + logo: true, + ..Default::default() + } + ), + Some(Action::FocusColumnLeft) + ); assert_eq!( bound_action( &bindings, @@ -1858,19 +1863,19 @@ mod tests { None, ); - // assert_eq!( - // bound_action( - // &bindings, - // CompositorMod::Super, - // Some(Keysym::l), - // ModifiersState { - // logo: true, - // alt: true, - // ..Default::default() - // } - // ), - // Some(Action::FocusColumnRight) - // ); + assert_eq!( + bound_action( + &bindings, + CompositorMod::Super, + Some(Keysym::l), + ModifiersState { + logo: true, + alt: true, + ..Default::default() + } + ), + Some(Action::FocusColumnRight) + ); assert_eq!( bound_action( &bindings, |
