aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-10-08 09:57:59 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-10-08 09:57:59 +0400
commite70e660df62d46879f01fc76c55fa09adce9c994 (patch)
tree8d989a6ff5c88c7c3b36b847b310a393e839d945 /src/input.rs
parent0411fd8d90f4e80990ca511f7ea65ea680aef185 (diff)
downloadniri-e70e660df62d46879f01fc76c55fa09adce9c994.tar.gz
niri-e70e660df62d46879f01fc76c55fa09adce9c994.tar.bz2
niri-e70e660df62d46879f01fc76c55fa09adce9c994.zip
Add barebones three-finger-swipe workspace switch
Notable omission is velocity tracking.
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/input.rs b/src/input.rs
index 033b90f4..955c63f4 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -631,6 +631,19 @@ impl State {
}
}
InputEvent::GestureSwipeBegin { event } => {
+ if event.fingers() == 3 {
+ if let Some(output) = self.niri.output_under_cursor() {
+ self.niri.layout.workspace_switch_gesture_begin(&output);
+
+ // FIXME: granular. This one is awkward because this can cancel a gesture on
+ // multiple other outputs in theory.
+ self.niri.queue_redraw_all();
+ }
+
+ // We handled this event.
+ return;
+ }
+
let serial = SERIAL_COUNTER.next_serial();
let pointer = self.niri.seat.get_pointer().unwrap();
pointer.gesture_swipe_begin(
@@ -643,6 +656,19 @@ impl State {
);
}
InputEvent::GestureSwipeUpdate { event } => {
+ let res = self
+ .niri
+ .layout
+ .workspace_switch_gesture_update(event.delta_y());
+ if let Some(output) = res {
+ if let Some(output) = output {
+ self.niri.queue_redraw(output);
+ }
+
+ // We handled this event.
+ return;
+ }
+
let pointer = self.niri.seat.get_pointer().unwrap();
pointer.gesture_swipe_update(
self,
@@ -653,6 +679,17 @@ impl State {
);
}
InputEvent::GestureSwipeEnd { event } => {
+ let res = self
+ .niri
+ .layout
+ .workspace_switch_gesture_end(event.cancelled());
+ if let Some(output) = res {
+ self.niri.queue_redraw(output);
+
+ // We handled this event.
+ return;
+ }
+
let serial = SERIAL_COUNTER.next_serial();
let pointer = self.niri.seat.get_pointer().unwrap();
pointer.gesture_swipe_end(