Fix vertical wheel binds on winit
Browse files at this commitc66319314e2099c2c4f4d05c3d8c1e196ef6bdeaParent: b09dbb81 changed file +12 -2
- src/input.rs +12 -2
src/input.rsmodified+12 -2
| @@ -1121,6 +1121,10 @@ impl State { | ||
| 1121 | 1121 | let comp_mod = self.backend.mod_key(); |
| 1122 | 1122 | let mods = self.niri.seat.get_keyboard().unwrap().modifier_state(); |
| 1123 | 1123 | |
| 1124 | + // Winit sends scroll events where both directions are set at once, so we can't early | |
| 1125 | + // return after handling just one. | |
| 1126 | + let mut handled = false; | |
| 1127 | + | |
| 1124 | 1128 | if let Some(v120) = horizontal_amount_v120 { |
| 1125 | 1129 | let config = self.niri.config.borrow(); |
| 1126 | 1130 | let bindings = &config.binds; |
| @@ -1144,7 +1148,8 @@ impl State { | ||
| 1144 | 1148 | self.handle_bind(left.clone()); |
| 1145 | 1149 | } |
| 1146 | 1150 | } |
| 1147 | - return; | |
| 1151 | + | |
| 1152 | + handled = true; | |
| 1148 | 1153 | } else { |
| 1149 | 1154 | self.niri.horizontal_wheel_tracker.reset(); |
| 1150 | 1155 | } |
| @@ -1171,11 +1176,16 @@ impl State { | ||
| 1171 | 1176 | self.handle_bind(up.clone()); |
| 1172 | 1177 | } |
| 1173 | 1178 | } |
| 1174 | - return; | |
| 1179 | + | |
| 1180 | + handled = true; | |
| 1175 | 1181 | } else { |
| 1176 | 1182 | self.niri.vertical_wheel_tracker.reset(); |
| 1177 | 1183 | } |
| 1178 | 1184 | } |
| 1185 | + | |
| 1186 | + if handled { | |
| 1187 | + return; | |
| 1188 | + } | |
| 1179 | 1189 | } |
| 1180 | 1190 | |
| 1181 | 1191 | let horizontal_amount = event.amount(Axis::Horizontal).unwrap_or_else(|| { |