forge
Explore
Log in

Don't you dare go Hollow

input: Generalize bound_action() to Trigger

Browse files at this commit

969519b5d8b163e61d74e9c1a7e525a2d11bc7e6Ivan MolodetskikhParent: a0c8c39
src/input.rsmodified+14 -15
@@ -1696,13 +1696,14 @@ fn action(
1696 _ => (),1696 _ => (),
1697 }1697 }
1698 1698
1699- bound_action(bindings, comp_mod, raw, mods)1699+ let trigger = Trigger::Keysym(raw?);
1700+ bound_action(bindings, comp_mod, trigger, mods)
1700 }1701 }
1701 1702
1702 fn bound_action(1703 fn bound_action(
1703 bindings: &Binds,1704 bindings: &Binds,
1704 comp_mod: CompositorMod,1705 comp_mod: CompositorMod,
1705- raw: Option<Keysym>,1706+ trigger: Trigger,
1706 mods: ModifiersState,1707 mods: ModifiersState,
1707 ) -> Option<Action> {1708 ) -> Option<Action> {
1708 // Handle configured binds.1709 // Handle configured binds.
@@ -1728,10 +1729,8 @@ fn bound_action(
1728 modifiers |= Modifiers::COMPOSITOR;1729 modifiers |= Modifiers::COMPOSITOR;
1729 }1730 }
1730 1731
1731- let raw = raw?;
1732-
1733 for bind in &bindings.0 {1732 for bind in &bindings.0 {
1734- if bind.key.trigger != Trigger::Keysym(raw) {1733+ if bind.key.trigger != trigger {
1735 continue;1734 continue;
1736 }1735 }
1737 1736
@@ -2072,7 +2071,7 @@ mod tests {
2072 bound_action(2071 bound_action(
2073 &bindings,2072 &bindings,
2074 CompositorMod::Super,2073 CompositorMod::Super,
2075- Some(Keysym::q),2074+ Trigger::Keysym(Keysym::q),
2076 ModifiersState {2075 ModifiersState {
2077 logo: true,2076 logo: true,
2078 ..Default::default()2077 ..Default::default()
@@ -2084,7 +2083,7 @@ mod tests {
2084 bound_action(2083 bound_action(
2085 &bindings,2084 &bindings,
2086 CompositorMod::Super,2085 CompositorMod::Super,
2087- Some(Keysym::q),2086+ Trigger::Keysym(Keysym::q),
2088 ModifiersState::default(),2087 ModifiersState::default(),
2089 ),2088 ),
2090 None,2089 None,
@@ -2094,7 +2093,7 @@ mod tests {
2094 bound_action(2093 bound_action(
2095 &bindings,2094 &bindings,
2096 CompositorMod::Super,2095 CompositorMod::Super,
2097- Some(Keysym::h),2096+ Trigger::Keysym(Keysym::h),
2098 ModifiersState {2097 ModifiersState {
2099 logo: true,2098 logo: true,
2100 ..Default::default()2099 ..Default::default()
@@ -2106,7 +2105,7 @@ mod tests {
2106 bound_action(2105 bound_action(
2107 &bindings,2106 &bindings,
2108 CompositorMod::Super,2107 CompositorMod::Super,
2109- Some(Keysym::h),2108+ Trigger::Keysym(Keysym::h),
2110 ModifiersState::default(),2109 ModifiersState::default(),
2111 ),2110 ),
2112 None,2111 None,
@@ -2116,7 +2115,7 @@ mod tests {
2116 bound_action(2115 bound_action(
2117 &bindings,2116 &bindings,
2118 CompositorMod::Super,2117 CompositorMod::Super,
2119- Some(Keysym::j),2118+ Trigger::Keysym(Keysym::j),
2120 ModifiersState {2119 ModifiersState {
2121 logo: true,2120 logo: true,
2122 ..Default::default()2121 ..Default::default()
@@ -2128,7 +2127,7 @@ mod tests {
2128 bound_action(2127 bound_action(
2129 &bindings,2128 &bindings,
2130 CompositorMod::Super,2129 CompositorMod::Super,
2131- Some(Keysym::j),2130+ Trigger::Keysym(Keysym::j),
2132 ModifiersState::default(),2131 ModifiersState::default(),
2133 ),2132 ),
2134 Some(Action::FocusWindowDown)2133 Some(Action::FocusWindowDown)
@@ -2138,7 +2137,7 @@ mod tests {
2138 bound_action(2137 bound_action(
2139 &bindings,2138 &bindings,
2140 CompositorMod::Super,2139 CompositorMod::Super,
2141- Some(Keysym::k),2140+ Trigger::Keysym(Keysym::k),
2142 ModifiersState {2141 ModifiersState {
2143 logo: true,2142 logo: true,
2144 ..Default::default()2143 ..Default::default()
@@ -2150,7 +2149,7 @@ mod tests {
2150 bound_action(2149 bound_action(
2151 &bindings,2150 &bindings,
2152 CompositorMod::Super,2151 CompositorMod::Super,
2153- Some(Keysym::k),2152+ Trigger::Keysym(Keysym::k),
2154 ModifiersState::default(),2153 ModifiersState::default(),
2155 ),2154 ),
2156 None,2155 None,
@@ -2160,7 +2159,7 @@ mod tests {
2160 bound_action(2159 bound_action(
2161 &bindings,2160 &bindings,
2162 CompositorMod::Super,2161 CompositorMod::Super,
2163- Some(Keysym::l),2162+ Trigger::Keysym(Keysym::l),
2164 ModifiersState {2163 ModifiersState {
2165 logo: true,2164 logo: true,
2166 alt: true,2165 alt: true,
@@ -2173,7 +2172,7 @@ mod tests {
2173 bound_action(2172 bound_action(
2174 &bindings,2173 &bindings,
2175 CompositorMod::Super,2174 CompositorMod::Super,
2176- Some(Keysym::l),2175+ Trigger::Keysym(Keysym::l),
2177 ModifiersState {2176 ModifiersState {
2178 logo: true,2177 logo: true,
2179 ..Default::default()2178 ..Default::default()