input: Fix handling of binds with compositor mod but no explicit Mod
Browse files at this commit573dca10cc3edeb28f607c1830ff32d223cea240Parent: 577fba81 changed file +34 -29
- src/input.rs +34 -29
src/input.rsmodified+34 -29
| @@ -1445,14 +1445,12 @@ fn bound_action( | |||
| 1445 | modifiers |= Modifiers::SUPER; | 1445 | modifiers |= Modifiers::SUPER; |
| 1446 | } | 1446 | } |
| 1447 | 1447 | ||
| 1448 | - let (mod_down, mut comp_mod) = match comp_mod { | 1448 | + let (mod_down, comp_mod) = match comp_mod { |
| 1449 | CompositorMod::Super => (mods.logo, Modifiers::SUPER), | 1449 | CompositorMod::Super => (mods.logo, Modifiers::SUPER), |
| 1450 | CompositorMod::Alt => (mods.alt, Modifiers::ALT), | 1450 | CompositorMod::Alt => (mods.alt, Modifiers::ALT), |
| 1451 | }; | 1451 | }; |
| 1452 | if mod_down { | 1452 | if mod_down { |
| 1453 | modifiers |= Modifiers::COMPOSITOR; | 1453 | modifiers |= Modifiers::COMPOSITOR; |
| 1454 | - } else { | ||
| 1455 | - comp_mod = Modifiers::empty(); | ||
| 1456 | } | 1454 | } |
| 1457 | 1455 | ||
| 1458 | let raw = raw?; | 1456 | let raw = raw?; |
| @@ -1462,7 +1460,14 @@ fn bound_action( | |||
| 1462 | continue; | 1460 | continue; |
| 1463 | } | 1461 | } |
| 1464 | 1462 | ||
| 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 { | ||
| 1466 | return bind.actions.first().cloned(); | 1471 | return bind.actions.first().cloned(); |
| 1467 | } | 1472 | } |
| 1468 | } | 1473 | } |
| @@ -1792,18 +1797,18 @@ mod tests { | |||
| 1792 | None, | 1797 | None, |
| 1793 | ); | 1798 | ); |
| 1794 | 1799 | ||
| 1795 | - // assert_eq!( | 1800 | + assert_eq!( |
| 1796 | - // bound_action( | 1801 | + bound_action( |
| 1797 | - // &bindings, | 1802 | + &bindings, |
| 1798 | - // CompositorMod::Super, | 1803 | + CompositorMod::Super, |
| 1799 | - // Some(Keysym::h), | 1804 | + Some(Keysym::h), |
| 1800 | - // ModifiersState { | 1805 | + ModifiersState { |
| 1801 | - // logo: true, | 1806 | + logo: true, |
| 1802 | - // ..Default::default() | 1807 | + ..Default::default() |
| 1803 | - // } | 1808 | + } |
| 1804 | - // ), | 1809 | + ), |
| 1805 | - // Some(Action::FocusColumnLeft) | 1810 | + Some(Action::FocusColumnLeft) |
| 1806 | - // ); | 1811 | + ); |
| 1807 | assert_eq!( | 1812 | assert_eq!( |
| 1808 | bound_action( | 1813 | bound_action( |
| 1809 | &bindings, | 1814 | &bindings, |
| @@ -1858,19 +1863,19 @@ mod tests { | |||
| 1858 | None, | 1863 | None, |
| 1859 | ); | 1864 | ); |
| 1860 | 1865 | ||
| 1861 | - // assert_eq!( | 1866 | + assert_eq!( |
| 1862 | - // bound_action( | 1867 | + bound_action( |
| 1863 | - // &bindings, | 1868 | + &bindings, |
| 1864 | - // CompositorMod::Super, | 1869 | + CompositorMod::Super, |
| 1865 | - // Some(Keysym::l), | 1870 | + Some(Keysym::l), |
| 1866 | - // ModifiersState { | 1871 | + ModifiersState { |
| 1867 | - // logo: true, | 1872 | + logo: true, |
| 1868 | - // alt: true, | 1873 | + alt: true, |
| 1869 | - // ..Default::default() | 1874 | + ..Default::default() |
| 1870 | - // } | 1875 | + } |
| 1871 | - // ), | 1876 | + ), |
| 1872 | - // Some(Action::FocusColumnRight) | 1877 | + Some(Action::FocusColumnRight) |
| 1873 | - // ); | 1878 | + ); |
| 1874 | assert_eq!( | 1879 | assert_eq!( |
| 1875 | bound_action( | 1880 | bound_action( |
| 1876 | &bindings, | 1881 | &bindings, |