forge
Explore
Log in

Don't you dare go Hollow

input: Fix handling of binds with compositor mod but no explicit Mod

Browse files at this commit

573dca10cc3edeb28f607c1830ff32d223cea240Ivan MolodetskikhParent: 577fba8
src/input.rsmodified+34 -29
@@ -1445,14 +1445,12 @@ fn bound_action(
14451445 modifiers |= Modifiers::SUPER;
14461446 }
14471447
1448- let (mod_down, mut comp_mod) = match comp_mod {
1448+ let (mod_down, comp_mod) = match comp_mod {
14491449 CompositorMod::Super => (mods.logo, Modifiers::SUPER),
14501450 CompositorMod::Alt => (mods.alt, Modifiers::ALT),
14511451 };
14521452 if mod_down {
14531453 modifiers |= Modifiers::COMPOSITOR;
1454- } else {
1455- comp_mod = Modifiers::empty();
14561454 }
14571455
14581456 let raw = raw?;
@@ -1462,7 +1460,14 @@ fn bound_action(
14621460 continue;
14631461 }
14641462
1465- if bind.key.modifiers | comp_mod == modifiers {
1463+ let mut bind_modifiers = bind.key.modifiers;
1464+ if bind_modifiers.contains(Modifiers::COMPOSITOR) {
1465+ bind_modifiers |= comp_mod;
1466+ } else if bind_modifiers.contains(comp_mod) {
1467+ bind_modifiers |= Modifiers::COMPOSITOR;
1468+ }
1469+
1470+ if bind_modifiers == modifiers {
14661471 return bind.actions.first().cloned();
14671472 }
14681473 }
@@ -1792,18 +1797,18 @@ mod tests {
17921797 None,
17931798 );
17941799
1795- // assert_eq!(
1796- // bound_action(
1797- // &bindings,
1798- // CompositorMod::Super,
1799- // Some(Keysym::h),
1800- // ModifiersState {
1801- // logo: true,
1802- // ..Default::default()
1803- // }
1804- // ),
1805- // Some(Action::FocusColumnLeft)
1806- // );
1800+ assert_eq!(
1801+ bound_action(
1802+ &bindings,
1803+ CompositorMod::Super,
1804+ Some(Keysym::h),
1805+ ModifiersState {
1806+ logo: true,
1807+ ..Default::default()
1808+ }
1809+ ),
1810+ Some(Action::FocusColumnLeft)
1811+ );
18071812 assert_eq!(
18081813 bound_action(
18091814 &bindings,
@@ -1858,19 +1863,19 @@ mod tests {
18581863 None,
18591864 );
18601865
1861- // assert_eq!(
1862- // bound_action(
1863- // &bindings,
1864- // CompositorMod::Super,
1865- // Some(Keysym::l),
1866- // ModifiersState {
1867- // logo: true,
1868- // alt: true,
1869- // ..Default::default()
1870- // }
1871- // ),
1872- // Some(Action::FocusColumnRight)
1873- // );
1866+ assert_eq!(
1867+ bound_action(
1868+ &bindings,
1869+ CompositorMod::Super,
1870+ Some(Keysym::l),
1871+ ModifiersState {
1872+ logo: true,
1873+ alt: true,
1874+ ..Default::default()
1875+ }
1876+ ),
1877+ Some(Action::FocusColumnRight)
1878+ );
18741879 assert_eq!(
18751880 bound_action(
18761881 &bindings,