1919 * it will be a hard boundary, if they are fractional it will slow the gesture progress when over the
2020 * limit simulating a kind of spring that pushes against it.
2121 * Note that the progress snaps to full integer values after a gesture ends.
22+ * Events are always shared between all GestureControllers in the same group (except for the group NONE).
23+ * This means that two gestures that can be done in one motion (e.g. horizontal and vertical swipe)
24+ * can be done simultaneously if each of two GestureControllers in the same group handle one of
25+ * the gestures.
2226 */
2327public class Gala.GestureController : Object {
28+ public enum Group {
29+ NONE ,
30+ MULTITASKING_VIEW ,
31+ }
32+
2433 /**
2534 * When a gesture ends with a velocity greater than this constant, the action is not cancelled,
2635 * even if the animation threshold has not been reached.
@@ -34,6 +43,7 @@ public class Gala.GestureController : Object {
3443
3544 public GestureAction action { get ; construct; }
3645 public WindowManager wm { get ; construct; }
46+ public Group group { get ; construct; }
3747
3848 private unowned RootTarget ? _target;
3949 public RootTarget target {
@@ -50,6 +60,7 @@ public class Gala.GestureController : Object {
5060 public double distance { get ; construct set ; }
5161 public double overshoot_lower_clamp { get ; construct set ; default = 0d; }
5262 public double overshoot_upper_clamp { get ; construct set ; default = 1d; }
63+ public bool follow_natural_scroll { get ; set ; default = false ; }
5364
5465 /**
5566 * When disabled gesture progress will stay where the gesture ended and not snap to full integers values.
@@ -77,7 +88,8 @@ public class Gala.GestureController : Object {
7788
7889 public bool recognizing { get ; private set ; }
7990
80- private ToucheggBackend ? touchpad_backend;
91+ private ToucheggBackend ? touchegg_backend;
92+ private TouchpadBackend ? touchpad_backend;
8193 private ScrollBackend ? scroll_backend;
8294
8395 private GestureBackend ? recognizing_backend;
@@ -90,8 +102,8 @@ public class Gala.GestureController : Object {
90102
91103 private SpringTimeline ? timeline;
92104
93- public GestureController (GestureAction action, WindowManager wm) {
94- Object (action: action, wm: wm);
105+ public GestureController (GestureAction action, WindowManager wm, Group group = NONE ) {
106+ Object (action: action, wm: wm, group : group );
95107 }
96108
97109 /**
@@ -107,12 +119,20 @@ public class Gala.GestureController : Object {
107119 unref ();
108120 }
109121
110- public void enable_touchpad () {
111- touchpad_backend = ToucheggBackend . get_default ();
112- touchpad_backend. on_gesture_detected. connect (gesture_detected);
113- touchpad_backend. on_begin. connect (gesture_begin);
114- touchpad_backend. on_update. connect (gesture_update);
115- touchpad_backend. on_end. connect (gesture_end);
122+ public void enable_touchpad (Clutter . Actor actor) {
123+ if (Meta . Util . is_wayland_compositor ()) {
124+ touchpad_backend = new TouchpadBackend (actor, group);
125+ touchpad_backend. on_gesture_detected. connect (gesture_detected);
126+ touchpad_backend. on_begin. connect (gesture_begin);
127+ touchpad_backend. on_update. connect (gesture_update);
128+ touchpad_backend. on_end. connect (gesture_end);
129+ }
130+
131+ touchegg_backend = ToucheggBackend . get_default (); // Will automatically filter events on wayland
132+ touchegg_backend. on_gesture_detected. connect (gesture_detected);
133+ touchegg_backend. on_begin. connect (gesture_begin);
134+ touchegg_backend. on_update. connect (gesture_update);
135+ touchegg_backend. on_end. connect (gesture_end);
116136 }
117137
118138 public void enable_scroll (Clutter . Actor actor, Clutter . Orientation orientation) {
@@ -147,6 +167,12 @@ public class Gala.GestureController : Object {
147167 direction_multiplier = - 1 ;
148168 }
149169
170+ if (follow_natural_scroll &&
171+ ! GestureSettings . is_natural_scroll_enabled (gesture. performed_on_device_type)
172+ ) {
173+ direction_multiplier * = - 1 ;
174+ }
175+
150176 if (snap && ! Meta . Prefs . get_gnome_animations ()) {
151177 recognizing = false ;
152178 prepare ();
0 commit comments