1919/**
2020 * This gesture backend transforms the touchpad scroll events received by an actor into gestures.
2121 */
22- public class Gala.ScrollBackend : Object {
22+ public class Gala.ScrollBackend : Object , GestureBackend {
2323 // Mutter does not expose the size of the touchpad, so we use the same values as GTK apps.
2424 // From GNOME Shell, TOUCHPAD_BASE_[WIDTH|HEIGHT] / SCROLL_MULTIPLIER
2525 // https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/swipeTracker.js
2626 private const double FINISH_DELTA_HORIZONTAL = 40 ;
2727 private const double FINISH_DELTA_VERTICAL = 30 ;
2828
29- public signal void on_gesture_detected (Gesture gesture );
30- public signal void on_begin (double delta , uint64 time );
31- public signal void on_update (double delta , uint64 time );
32- public signal void on_end (double delta , uint64 time );
33-
3429 public Clutter . Actor actor { get ; construct; }
3530 public Clutter . Orientation orientation { get ; construct; }
3631 public GestureSettings settings { get ; construct; }
@@ -62,7 +57,7 @@ public class Gala.ScrollBackend : Object {
6257 return false ;
6358 }
6459
65- uint64 time = event. get_time ();
60+ var time = event. get_time ();
6661 double x, y;
6762 event. get_scroll_delta (out x, out y);
6863
@@ -80,10 +75,12 @@ public class Gala.ScrollBackend : Object {
8075
8176 if (! started) {
8277 if (delta_x != 0 || delta_y != 0 ) {
83- Gesture gesture = build_gesture (delta_x, delta_y, orientation);
78+ float origin_x, origin_y;
79+ event. get_coords (out origin_x, out origin_y);
80+ Gesture gesture = build_gesture (origin_x, origin_y, delta_x, delta_y, orientation, time);
8481 started = true ;
8582 direction = gesture. direction;
86- on_gesture_detected (gesture);
83+ on_gesture_detected (gesture, time );
8784
8885 double delta = calculate_delta (delta_x, delta_y, direction);
8986 on_begin (delta, time);
@@ -114,7 +111,7 @@ public class Gala.ScrollBackend : Object {
114111 && event. get_scroll_direction () == Clutter . ScrollDirection . SMOOTH ;
115112 }
116113
117- private static Gesture build_gesture (double delta_x, double delta_y, Clutter . Orientation orientation) {
114+ private static Gesture build_gesture (float origin_x, float origin_y, double delta_x, double delta_y, Clutter . Orientation orientation, uint32 timestamp ) {
118115 GestureDirection direction;
119116 if (orientation == Clutter . Orientation . HORIZONTAL ) {
120117 direction = delta_x > 0 ? GestureDirection . RIGHT : GestureDirection . LEFT ;
@@ -126,7 +123,9 @@ public class Gala.ScrollBackend : Object {
126123 type = Clutter . EventType . SCROLL ,
127124 direction = direction,
128125 fingers = 2 ,
129- performed_on_device_type = Clutter . InputDeviceType . TOUCHPAD_DEVICE
126+ performed_on_device_type = Clutter . InputDeviceType . TOUCHPAD_DEVICE ,
127+ origin_x = origin_x,
128+ origin_y = origin_y
130129 };
131130 }
132131
0 commit comments