forge
Explore
Log in

Don't you dare go Hollow

Respect natural-scroll for workspace switch gesture

Browse files at this commit

b23dd4b800285f120ad556d77c2357b17c1ea6a2Ivan MolodetskikhParent: 1f72089
src/input.rsmodified+14 -5
@@ -1156,11 +1156,20 @@ impl State {
1156 );1156 );
1157 }1157 }
1158 1158
1159- fn on_gesture_swipe_update<I: InputBackend>(&mut self, event: I::GestureSwipeUpdateEvent) {1159+ fn on_gesture_swipe_update<I: InputBackend>(&mut self, event: I::GestureSwipeUpdateEvent)
1160- let res = self1160+ where
1161- .niri1161+ I::Device: 'static,
1162- .layout1162+ {
1163- .workspace_switch_gesture_update(event.delta_y());1163+ let mut delta_y = event.delta_y();
1164+
1165+ let device = event.device();
1166+ if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {
1167+ if device.config_scroll_natural_scroll_enabled() {
1168+ delta_y = -delta_y;
1169+ }
1170+ }
1171+
1172+ let res = self.niri.layout.workspace_switch_gesture_update(delta_y);
1164 if let Some(output) = res {1173 if let Some(output) = res {
1165 if let Some(output) = output {1174 if let Some(output) = output {
1166 self.niri.queue_redraw(output);1175 self.niri.queue_redraw(output);
src/layout/mod.rsmodified+1 -1
@@ -1462,7 +1462,7 @@ impl<W: LayoutElement> Layout<W> {
1462 for monitor in monitors {1462 for monitor in monitors {
1463 if let Some(WorkspaceSwitch::Gesture(gesture)) = &mut monitor.workspace_switch {1463 if let Some(WorkspaceSwitch::Gesture(gesture)) = &mut monitor.workspace_switch {
1464 // Normalize like GNOME Shell's workspace switching.1464 // Normalize like GNOME Shell's workspace switching.
1465- let delta_y = -delta_y / 400.;1465+ let delta_y = delta_y / 400.;
1466 1466
1467 let min = gesture.center_idx.saturating_sub(1) as f64;1467 let min = gesture.center_idx.saturating_sub(1) as f64;
1468 let max = (gesture.center_idx + 1).min(monitor.workspaces.len() - 1) as f64;1468 let max = (gesture.center_idx + 1).min(monitor.workspaces.len() - 1) as f64;