Skip to content

Commit 3ca07f8

Browse files
authored
HideTracker: Reveal panel on swipe (#2091)
1 parent 4c11882 commit 3ca07f8

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/ShellClients/HideTracker.vala

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class Gala.HideTracker : Object {
1515
public unowned PanelWindow panel { get; construct; }
1616
public Pantheon.Desktop.HideMode hide_mode { get; set; default = NEVER; }
1717

18+
private Clutter.PanAction pan_action;
19+
1820
private bool hovered = false;
1921

2022
private bool overlap = false;
@@ -60,6 +62,15 @@ public class Gala.HideTracker : Object {
6062
});
6163

6264
display.get_workspace_manager ().active_workspace_changed.connect (schedule_update);
65+
66+
pan_action = new Clutter.PanAction () {
67+
n_touch_points = 1,
68+
pan_axis = X_AXIS
69+
};
70+
pan_action.gesture_begin.connect (check_valid_gesture);
71+
pan_action.pan.connect (on_pan);
72+
73+
display.get_stage ().add_action_full ("panel-swipe-gesture", CAPTURE, pan_action);
6374
}
6475

6576
//Can be removed with mutter > 45
@@ -181,7 +192,7 @@ public class Gala.HideTracker : Object {
181192
hovered = window_has_pointer ();
182193
#endif
183194

184-
if (should_hide && !hovered) {
195+
if (should_hide && !hovered && !panel.window.has_focus ()) {
185196
// Don't hide if we have transients, e.g. an open popover, dialog, etc.
186197
var has_transients = false;
187198
panel.window.foreach_transient (() => {
@@ -198,4 +209,33 @@ public class Gala.HideTracker : Object {
198209
show ();
199210
}
200211
}
212+
213+
private bool check_valid_gesture () {
214+
if (panel.anchor != BOTTOM) {
215+
debug ("Swipe to reveal is currently only supported for bottom anchors");
216+
return false;
217+
}
218+
219+
float y;
220+
pan_action.get_press_coords (0, null, out y);
221+
222+
var monitor_geom = display.get_monitor_geometry (panel.window.get_monitor ());
223+
if ((y - monitor_geom.y - monitor_geom.height).abs () < 50) { // Only start if the gesture starts near the bottom of the monitor
224+
return true;
225+
}
226+
227+
return false;
228+
}
229+
230+
private bool on_pan () {
231+
float delta_y;
232+
pan_action.get_motion_delta (0, null, out delta_y);
233+
234+
if (delta_y < 0) { // Only allow swipes upwards
235+
panel.window.focus (pan_action.get_last_event (0).get_time ());
236+
show ();
237+
}
238+
239+
return false;
240+
}
201241
}

0 commit comments

Comments
 (0)