mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Respect natural-scroll for workspace switch gesture
This commit is contained in:
+14
-5
@@ -1156,11 +1156,20 @@ impl State {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_gesture_swipe_update<I: InputBackend>(&mut self, event: I::GestureSwipeUpdateEvent) {
|
fn on_gesture_swipe_update<I: InputBackend>(&mut self, event: I::GestureSwipeUpdateEvent)
|
||||||
let res = self
|
where
|
||||||
.niri
|
I::Device: 'static,
|
||||||
.layout
|
{
|
||||||
.workspace_switch_gesture_update(event.delta_y());
|
let mut delta_y = event.delta_y();
|
||||||
|
|
||||||
|
let device = event.device();
|
||||||
|
if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {
|
||||||
|
if device.config_scroll_natural_scroll_enabled() {
|
||||||
|
delta_y = -delta_y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let res = self.niri.layout.workspace_switch_gesture_update(delta_y);
|
||||||
if let Some(output) = res {
|
if let Some(output) = res {
|
||||||
if let Some(output) = output {
|
if let Some(output) = output {
|
||||||
self.niri.queue_redraw(output);
|
self.niri.queue_redraw(output);
|
||||||
|
|||||||
+1
-1
@@ -1462,7 +1462,7 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
for monitor in monitors {
|
for monitor in monitors {
|
||||||
if let Some(WorkspaceSwitch::Gesture(gesture)) = &mut monitor.workspace_switch {
|
if let Some(WorkspaceSwitch::Gesture(gesture)) = &mut monitor.workspace_switch {
|
||||||
// Normalize like GNOME Shell's workspace switching.
|
// Normalize like GNOME Shell's workspace switching.
|
||||||
let delta_y = -delta_y / 400.;
|
let delta_y = delta_y / 400.;
|
||||||
|
|
||||||
let min = gesture.center_idx.saturating_sub(1) as f64;
|
let min = gesture.center_idx.saturating_sub(1) as f64;
|
||||||
let max = (gesture.center_idx + 1).min(monitor.workspaces.len() - 1) as f64;
|
let max = (gesture.center_idx + 1).min(monitor.workspaces.len() - 1) as f64;
|
||||||
|
|||||||
Reference in New Issue
Block a user