From 25a6f5ead944535a296fba785934e6a13628eb71 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Mon, 13 Oct 2025 16:10:28 +0200 Subject: [PATCH 1/2] Introduce custom gestures These are gestures that aren't relevant globally but instead local. The backend decides whether its gestures are custom or not. It then has full responsibility to filter the correct gestures. --- lib/Gestures/Gesture.vala | 5 +++++ lib/Gestures/GestureController.vala | 2 +- lib/Gestures/GestureSettings.vala | 5 +++++ lib/Gestures/ScrollBackend.vala | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Gestures/Gesture.vala b/lib/Gestures/Gesture.vala index 2e2a5bcde..00d2710d8 100644 --- a/lib/Gestures/Gesture.vala +++ b/lib/Gestures/Gesture.vala @@ -47,6 +47,11 @@ namespace Gala { private class Gesture { public const float INVALID_COORD = float.MAX; + /** + * A hint that this gesture isn't a globally configured gesture but instead a local custom one. + * Examples for this are a scroll gesture on the workspaces or a scroll gesture to close windows. + */ + public bool custom = false; public Clutter.EventType type; public GestureDirection direction; public int fingers; diff --git a/lib/Gestures/GestureController.vala b/lib/Gestures/GestureController.vala index aec8241c1..c3de8e9c4 100644 --- a/lib/Gestures/GestureController.vala +++ b/lib/Gestures/GestureController.vala @@ -157,7 +157,7 @@ public class Gala.GestureController : Object { var recognized_action = GestureSettings.get_action (gesture, out _action_info); recognizing = !wm.filter_action (recognized_action) && recognized_action == action || - backend == scroll_backend && recognized_action == NONE; + recognized_action == CUSTOM; if (recognizing) { if (gesture.direction == UP || gesture.direction == RIGHT || gesture.direction == OUT) { diff --git a/lib/Gestures/GestureSettings.vala b/lib/Gestures/GestureSettings.vala index a117ee869..af58c62ce 100644 --- a/lib/Gestures/GestureSettings.vala +++ b/lib/Gestures/GestureSettings.vala @@ -57,6 +57,11 @@ private class Gala.GestureSettings : Object { public static GestureAction get_action (Gesture gesture, out Variant? action_info = null) { action_info = null; + + if (gesture.custom) { + return CUSTOM; + } + var fingers = gesture.fingers; switch (gesture.type) { diff --git a/lib/Gestures/ScrollBackend.vala b/lib/Gestures/ScrollBackend.vala index 9c4f1c102..572076190 100644 --- a/lib/Gestures/ScrollBackend.vala +++ b/lib/Gestures/ScrollBackend.vala @@ -156,6 +156,7 @@ private class Gala.ScrollBackend : Object, GestureBackend { } return new Gesture () { + custom = true, type = Clutter.EventType.SCROLL, direction = direction, fingers = 2, From 231e205550259111dda17d8ce77c0a69055690c6 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Mon, 13 Oct 2025 16:22:09 +0200 Subject: [PATCH 2/2] Use generic enable_backend method --- lib/Gestures/GestureController.vala | 34 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/Gestures/GestureController.vala b/lib/Gestures/GestureController.vala index c3de8e9c4..01dba706b 100644 --- a/lib/Gestures/GestureController.vala +++ b/lib/Gestures/GestureController.vala @@ -87,9 +87,7 @@ public class Gala.GestureController : Object { public bool recognizing { get; private set; } - private ToucheggBackend? touchegg_backend; - private TouchpadBackend? touchpad_backend; - private ScrollBackend? scroll_backend; + private Gee.List backends; private GestureBackend? recognizing_backend; private double gesture_progress; @@ -105,6 +103,10 @@ public class Gala.GestureController : Object { Object (action: action, wm: wm, group: group); } + construct { + backends = new Gee.ArrayList (); + } + /** * Do not call this directly, use {@link RooTarget.add_controller} instead. */ @@ -120,26 +122,22 @@ public class Gala.GestureController : Object { public void enable_touchpad (Clutter.Actor actor) { if (Meta.Util.is_wayland_compositor ()) { - touchpad_backend = new TouchpadBackend (actor, group); - touchpad_backend.on_gesture_detected.connect (gesture_detected); - touchpad_backend.on_begin.connect (gesture_begin); - touchpad_backend.on_update.connect (gesture_update); - touchpad_backend.on_end.connect (gesture_end); + enable_backend (new TouchpadBackend (actor, group)); } - touchegg_backend = ToucheggBackend.get_default (); // Will automatically filter events on wayland - touchegg_backend.on_gesture_detected.connect (gesture_detected); - touchegg_backend.on_begin.connect (gesture_begin); - touchegg_backend.on_update.connect (gesture_update); - touchegg_backend.on_end.connect (gesture_end); + enable_backend (ToucheggBackend.get_default ()); // Will automatically filter events on wayland } public void enable_scroll (Clutter.Actor actor, Clutter.Orientation orientation) { - scroll_backend = new ScrollBackend (actor, orientation, new GestureSettings ()); - scroll_backend.on_gesture_detected.connect (gesture_detected); - scroll_backend.on_begin.connect (gesture_begin); - scroll_backend.on_update.connect (gesture_update); - scroll_backend.on_end.connect (gesture_end); + enable_backend (new ScrollBackend (actor, orientation, new GestureSettings ())); + } + + internal void enable_backend (GestureBackend backend) { + backend.on_gesture_detected.connect (gesture_detected); + backend.on_begin.connect (gesture_begin); + backend.on_update.connect (gesture_update); + backend.on_end.connect (gesture_end); + backends.add (backend); } private void prepare () {