Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Gestures/Gesture.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 17 additions & 19 deletions lib/Gestures/GestureController.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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<GestureBackend> backends;

private GestureBackend? recognizing_backend;
private double gesture_progress;
Expand All @@ -105,6 +103,10 @@ public class Gala.GestureController : Object {
Object (action: action, wm: wm, group: group);
}

construct {
backends = new Gee.ArrayList<GestureBackend> ();
}

/**
* Do not call this directly, use {@link RooTarget.add_controller} instead.
*/
Expand All @@ -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 () {
Expand All @@ -157,7 +155,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) {
Expand Down
5 changes: 5 additions & 0 deletions lib/Gestures/GestureSettings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions lib/Gestures/ScrollBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ private class Gala.ScrollBackend : Object, GestureBackend {
}

return new Gesture () {
custom = true,
type = Clutter.EventType.SCROLL,
direction = direction,
fingers = 2,
Expand Down