Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Jan 2, 2025
1 parent 787ac58 commit 021f6bf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 35 deletions.
42 changes: 14 additions & 28 deletions src/Gestures/GestureTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ public class Gala.GestureTracker : Object {
public delegate void OnEnd (double percentage, int completions, int calculated_duration);

/**
* Backend used if enable_touchpad is called.
* Backend used if enable_touchpad is called on wayland.
*/
private GestureBackend touchpad_backend;
private TouchpadBackend touchpad_backend;

/**
* Backend used if enable_touchscreen is called.
* Backend used if enable_touchpad is called on X or for
* touchscreen and pinch gestures if enable_touchpad is called on wayland.
*/
private ToucheggBackend touchscreen_backend;
private ToucheggBackend touchegg_backend;

/**
* Scroll backend used if enable_scroll is called.
Expand Down Expand Up @@ -159,36 +160,21 @@ public class Gala.GestureTracker : Object {

/**
* Allow to receive touchpad multi-touch gestures.
* On X this automatically enables touchscreen as well.
*/
public void enable_touchpad (Clutter.Actor actor) {
if (Meta.Util.is_wayland_compositor ()) {
touchpad_backend = new TouchpadBackend (actor);
} else {
touchpad_backend = ToucheggBackend.get_default ();
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);
}

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);
}

/**
* Allow to receive touchscreen multi-touch gestures.
*/
public void enable_touchscreen () {
if (!Meta.Util.is_wayland_compositor ()) { //Automatically enabled by enable_touchpad
return;
}

touchscreen_backend = ToucheggBackend.get_default ();
touchscreen_backend.touchscreen_only = true;

touchscreen_backend.on_gesture_detected.connect (gesture_detected);
touchscreen_backend.on_begin.connect (gesture_begin);
touchscreen_backend.on_update.connect (gesture_update);
touchscreen_backend.on_end.connect (gesture_end);
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);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Gestures/ToucheggBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ public class Gala.ToucheggBackend : Object, GestureBackend {
*/
private static ToucheggBackend? instance = null;

public bool touchscreen_only { get; set; default = false; }

/**
* Connection with the daemon.
*/
Expand Down Expand Up @@ -194,7 +192,7 @@ public class Gala.ToucheggBackend : Object, GestureBackend {
signal_params.get ("(uudiut)", out type, out direction, out percentage, out fingers,
out performed_on_device_type, out elapsed_time);

if (touchscreen_only && performed_on_device_type != DeviceType.TOUCHSCREEN) {
if (Meta.Util.is_wayland_compositor () && performed_on_device_type != DeviceType.TOUCHSCREEN && type != PINCH) {
return;
}

Expand Down
2 changes: 0 additions & 2 deletions src/Widgets/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,11 @@ namespace Gala {

multitasking_gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION);
multitasking_gesture_tracker.enable_touchpad (wm.stage);
multitasking_gesture_tracker.enable_touchscreen ();
multitasking_gesture_tracker.on_gesture_detected.connect (on_multitasking_gesture_detected);
multitasking_gesture_tracker.on_gesture_handled.connect (() => toggle (true, false));

workspace_gesture_tracker = new GestureTracker (AnimationDuration.WORKSPACE_SWITCH_MIN, AnimationDuration.WORKSPACE_SWITCH);
workspace_gesture_tracker.enable_touchpad (this);
workspace_gesture_tracker.enable_touchscreen ();
workspace_gesture_tracker.enable_scroll (this, Clutter.Orientation.HORIZONTAL);
workspace_gesture_tracker.on_gesture_detected.connect (on_workspace_gesture_detected);
workspace_gesture_tracker.on_gesture_handled.connect (switch_workspace_with_gesture);
Expand Down
1 change: 0 additions & 1 deletion src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ namespace Gala {
#endif
gesture_tracker = new GestureTracker (AnimationDuration.WORKSPACE_SWITCH_MIN, AnimationDuration.WORKSPACE_SWITCH);
gesture_tracker.enable_touchpad (stage);
gesture_tracker.enable_touchscreen ();
gesture_tracker.on_gesture_detected.connect (on_gesture_detected);
gesture_tracker.on_gesture_handled.connect (on_gesture_handled);

Expand Down
1 change: 0 additions & 1 deletion src/Zoom.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class Gala.Zoom : Object {

gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION);
gesture_tracker.enable_touchpad (wm.stage);
gesture_tracker.enable_touchscreen ();
gesture_tracker.on_gesture_detected.connect (on_gesture_detected);
gesture_tracker.on_gesture_handled.connect ((gesture) => zoom_with_gesture (gesture.direction));

Expand Down

0 comments on commit 021f6bf

Please sign in to comment.