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
3 changes: 2 additions & 1 deletion lib/Gestures/Backends/TouchScreenSwipeBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ private class Gala.TouchScreenSwipeBackend : Object, GestureBackend {
type = TOUCHPAD_SWIPE,
direction = get_direction (),
fingers = (int) gesture.get_n_points (),
performed_on_device_type = TOUCHSCREEN_DEVICE
performed_on_device_type = TOUCHSCREEN_DEVICE,
begin_centroid = gesture.get_begin_centroid ()
};

return on_gesture_detected (detected_gesture, Clutter.get_current_event_time ());
Expand Down
1 change: 1 addition & 0 deletions lib/Gestures/Gesture.vala
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ namespace Gala {
public GestureDirection direction;
public int fingers;
public Clutter.InputDeviceType performed_on_device_type;
public Graphene.Point begin_centroid;
}
}
53 changes: 53 additions & 0 deletions lib/Gestures/Triggers/EdgeSwipeTrigger.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2026 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Authored by: Leonhard Kargl <leo.kargl@proton.me>
*/

public class Gala.EdgeSwipeTrigger : Object, GestureTrigger {
private const int START_MARGIN = 20;

public Meta.Display display { get; construct; }

private Meta.Side side;

public EdgeSwipeTrigger (Meta.Display display, Meta.Side side) {
Object (display: display);

/* Meta.Side is not supported as GObject property */
this.side = side;
}

internal bool triggers (Gesture gesture) {
return (
(gesture.direction == RIGHT || gesture.direction == LEFT) && (side == LEFT || side == RIGHT) ||
(gesture.direction == UP || gesture.direction == DOWN) && (side == TOP || side == BOTTOM)
) && (
gesture.fingers == 1 && gesture.performed_on_device_type == TOUCHSCREEN_DEVICE && gesture.type == TOUCHPAD_SWIPE
) && (
get_allowed_area ().contains_point (gesture.begin_centroid)
);
}

private Graphene.Rect get_allowed_area () {
var geometry = display.get_monitor_geometry (display.get_primary_monitor ());
switch (side) {
case Meta.Side.LEFT:
return { { geometry.x, geometry.y }, { START_MARGIN, geometry.height } };
case Meta.Side.RIGHT:
return { { geometry.x + geometry.width - START_MARGIN, geometry.y }, { START_MARGIN, geometry.height } };
case Meta.Side.TOP:
return { { geometry.x, geometry.y }, { geometry.width, START_MARGIN } };
case Meta.Side.BOTTOM:
return { { geometry.x, geometry.y + geometry.height - START_MARGIN }, { geometry.width, START_MARGIN } };
default:
return { { 0, 0 }, { 0, 0 } };
}
}

internal void enable_backends (GestureController controller) {
var stage = display.get_compositor ().get_stage ();
controller.enable_backend (new TouchScreenSwipeBackend (stage), this);
}
}
1 change: 1 addition & 0 deletions lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ gala_lib_sources = files(
'Gestures/Targets/GestureTarget.vala',
'Gestures/Targets/PropertyTarget.vala',
'Gestures/Targets/RootTarget.vala',
'Gestures/Triggers/EdgeSwipeTrigger.vala',
'Gestures/Triggers/GestureTrigger.vala',
'Gestures/Triggers/GlobalTrigger.vala',
'Gestures/Triggers/SwipeTrigger.vala',
Expand Down
40 changes: 1 addition & 39 deletions src/Widgets/MultitaskingView/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public class Gala.MultitaskingView : Root, RootTarget {
private Drawing.StyleManager style_manager;
private GlobalTrigger workspaces_trigger;

private Clutter.PanGesture pan_action;

public MultitaskingView (WindowManager wm) {
Object (wm: wm);
}
Expand All @@ -68,6 +66,7 @@ public class Gala.MultitaskingView : Root, RootTarget {
overshoot_lower_clamp = -0.1,
};
multitasking_gesture_controller.add_trigger (new GlobalTrigger (MULTITASKING_VIEW, wm));
multitasking_gesture_controller.add_trigger (new EdgeSwipeTrigger (display, BOTTOM));
add_gesture_controller (multitasking_gesture_controller);

add_target (ShellClientsManager.get_instance ()); // For hiding the panels
Expand Down Expand Up @@ -120,16 +119,6 @@ public class Gala.MultitaskingView : Root, RootTarget {
});

style_manager.notify["prefers-color-scheme"].connect (update_brightness_effect);

pan_action = new Clutter.PanGesture () {
min_n_points = 1,
max_n_points = 1,
pan_axis = Clutter.PanAxis.X
};
pan_action.may_recognize.connect (check_valid_gesture);
pan_action.pan_update.connect (on_pan);

wm.stage.add_action_full ("panel-swipe-gesture", CAPTURE, pan_action);
}

/**
Expand Down Expand Up @@ -404,31 +393,4 @@ public class Gala.MultitaskingView : Root, RootTarget {

return Clutter.EVENT_PROPAGATE;
}

private bool check_valid_gesture () {
if (wm.filter_action (MULTITASKING_VIEW)) {
return false;
}

float y;
y = pan_action.get_point_begin_coords (0).y;

var monitor_geom = display.get_monitor_geometry (display.get_primary_monitor ());
if ((y - monitor_geom.y - monitor_geom.height).abs () < 50) { // Only start if the gesture starts near the bottom of the monitor
return true;
}

return false;
}

private void on_pan () {
float delta_y;
delta_y = pan_action.get_delta ().get_y ();

if (delta_y < 0) { // Only allow swipes upwards
open ();
}

}

}
Loading