Use default gesture tracker

This commit is contained in:
Leonhard Kargl 2024-12-10 01:38:22 +01:00
parent 0f0b50a300
commit ea5b965286
2 changed files with 14 additions and 14 deletions

View File

@ -6,7 +6,6 @@
*/ */
public class Gala.HideTracker : Object { public class Gala.HideTracker : Object {
private const int ANIMATION_DURATION = 250;
private const int BARRIER_OFFSET = 50; // Allow hot corner trigger private const int BARRIER_OFFSET = 50; // Allow hot corner trigger
private const int UPDATE_TIMEOUT = 200; private const int UPDATE_TIMEOUT = 200;
private const int HIDE_DELAY = 500; private const int HIDE_DELAY = 500;
@ -16,11 +15,11 @@ public class Gala.HideTracker : Object {
public Meta.Display display { get; construct; } public Meta.Display display { get; construct; }
public unowned PanelWindow panel { get; construct; } public unowned PanelWindow panel { get; construct; }
public GestureTracker default_gesture_tracker { get; construct; } // Placeholder that will replace pan_action once the pan_backend gets merged
public Pantheon.Desktop.HideMode hide_mode { get; set; } public Pantheon.Desktop.HideMode hide_mode { get; set; }
private Clutter.PanAction pan_action; private Clutter.PanAction pan_action;
private GestureTracker gesture_tracker; // Placeholder that will replace pan_action once the pan_backend gets merged
private bool hovered = false; private bool hovered = false;
@ -35,8 +34,8 @@ public class Gala.HideTracker : Object {
private uint hide_timeout_id = 0; private uint hide_timeout_id = 0;
private uint update_timeout_id = 0; private uint update_timeout_id = 0;
public HideTracker (Meta.Display display, PanelWindow panel) { public HideTracker (Meta.Display display, PanelWindow panel, GestureTracker default_gesture_tracker) {
Object (display: display, panel: panel); Object (display: display, panel: panel, default_gesture_tracker: default_gesture_tracker);
} }
~HideTracker () { ~HideTracker () {
@ -81,8 +80,6 @@ public class Gala.HideTracker : Object {
display.get_workspace_manager ().active_workspace_changed.connect (schedule_update); display.get_workspace_manager ().active_workspace_changed.connect (schedule_update);
gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION);
pan_action = new Clutter.PanAction () { pan_action = new Clutter.PanAction () {
n_touch_points = 1, n_touch_points = 1,
pan_axis = X_AXIS pan_axis = X_AXIS
@ -150,7 +147,7 @@ public class Gala.HideTracker : Object {
} }
update_timeout_id = Timeout.add (UPDATE_TIMEOUT, () => { update_timeout_id = Timeout.add (UPDATE_TIMEOUT, () => {
update_overlap (gesture_tracker, false); update_overlap (default_gesture_tracker, false);
update_timeout_id = 0; update_timeout_id = 0;
return Source.REMOVE; return Source.REMOVE;
}); });
@ -249,7 +246,7 @@ public class Gala.HideTracker : Object {
} }
hide_timeout_id = Timeout.add_once (HIDE_DELAY, () => { hide_timeout_id = Timeout.add_once (HIDE_DELAY, () => {
hide (gesture_tracker, false); hide (default_gesture_tracker, false);
hide_timeout_id = 0; hide_timeout_id = 0;
}); });
} }
@ -289,7 +286,7 @@ public class Gala.HideTracker : Object {
if (delta_y < 0) { // Only allow swipes upwards if (delta_y < 0) { // Only allow swipes upwards
panel.window.focus (pan_action.get_last_event (0).get_time ()); panel.window.focus (pan_action.get_last_event (0).get_time ());
trigger_show (gesture_tracker, false); trigger_show (default_gesture_tracker, false);
} }
return false; return false;
@ -333,7 +330,7 @@ public class Gala.HideTracker : Object {
int.MAX int.MAX
); );
barrier.trigger.connect (() => trigger_show (gesture_tracker, false)); barrier.trigger.connect (() => trigger_show (default_gesture_tracker, false));
} }
#if HAS_MUTTER45 #if HAS_MUTTER45
@ -354,6 +351,6 @@ public class Gala.HideTracker : Object {
int.MAX int.MAX
); );
barrier.trigger.connect (() => trigger_show (gesture_tracker, false)); barrier.trigger.connect (() => trigger_show (default_gesture_tracker, false));
} }
} }

View File

@ -18,10 +18,10 @@ public class Gala.PanelClone : Object {
set { set {
if (value == NEVER) { if (value == NEVER) {
hide_tracker = null; hide_tracker = null;
show (new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION), false); show (default_gesture_tracker, false);
return; return;
} else if (hide_tracker == null) { } else if (hide_tracker == null) {
hide_tracker = new HideTracker (wm.get_display (), panel); hide_tracker = new HideTracker (wm.get_display (), panel, default_gesture_tracker);
hide_tracker.hide.connect (hide); hide_tracker.hide.connect (hide);
hide_tracker.show.connect (show); hide_tracker.show.connect (show);
} }
@ -35,6 +35,7 @@ public class Gala.PanelClone : Object {
private SafeWindowClone clone; private SafeWindowClone clone;
private Meta.WindowActor actor; private Meta.WindowActor actor;
private GestureTracker default_gesture_tracker;
private GestureTracker? last_gesture_tracker; private GestureTracker? last_gesture_tracker;
private bool force_hide = false; private bool force_hide = false;
@ -45,6 +46,8 @@ public class Gala.PanelClone : Object {
} }
construct { construct {
default_gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION);
clone = new SafeWindowClone (panel.window, true); clone = new SafeWindowClone (panel.window, true);
wm.ui_group.add_child (clone); wm.ui_group.add_child (clone);
@ -75,7 +78,7 @@ public class Gala.PanelClone : Object {
Idle.add_once (() => { Idle.add_once (() => {
if (hide_mode == NEVER) { if (hide_mode == NEVER) {
show (new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION), false); show (default_gesture_tracker, false);
} else { } else {
hide_tracker.schedule_update (); hide_tracker.schedule_update ();
} }