[gnome-shell] workspacesView: Initialize/update swipe orientation before gesture



commit f69727464ca7d6d6df58d799de2a133fa0ecec4f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Feb 12 00:24:13 2021 +0100

    workspacesView: Initialize/update swipe orientation before gesture
    
    Separate this logic from _switchWorkspaceBegin() and ensure it is set
    before this call. The SwipeTracker code uses the orientation to determine
    whether the gesture should begin at all, so changing the orientation on
    gesture begin was a bit too late.
    
    But also, that meant the SwipeTracker was left at the default orientation,
    which was vertical (unlike workspaces, and like the overview gesture).
    This made both swipe trackers try to handle the same swipe, with the
    WorkspacesView being doubly unfortunate (for triggering in the first place,
    and for happening after the other gesture did queue relayouts on it).
    
    Taking this logic outside of _switchWorkspaceBegin() and having the right
    orientation beforehand results in both gestures looking for their direction,
    and not meddle with each other.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1643>

 js/ui/workspacesView.js | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 268adae44c..717ae0c634 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -613,6 +613,10 @@ class WorkspacesDisplay extends St.Widget {
         this._swipeTracker.connect('end', this._switchWorkspaceEnd.bind(this));
         this.connect('notify::mapped', this._updateSwipeTracker.bind(this));
 
+        this._layoutRowsNotifyId = workspaceManager.connect(
+            'notify::layout-rows', this._updateTrackerOrientation.bind(this));
+        this._updateTrackerOrientation();
+
         this._windowDragBeginId =
             Main.overview.connect('window-drag-begin',
                 this._windowDragBegin.bind(this));
@@ -649,6 +653,7 @@ class WorkspacesDisplay extends St.Widget {
 
         global.window_manager.disconnect(this._switchWorkspaceId);
         global.workspace_manager.disconnect(this._reorderWorkspacesdId);
+        global.workspace_manager.disconnect(this._layoutRowsNotifyId);
         Main.overview.disconnect(this._windowDragBeginId);
         Main.overview.disconnect(this._windowDragEndId);
     }
@@ -687,6 +692,13 @@ class WorkspacesDisplay extends St.Widget {
         });
     }
 
+    _updateTrackerOrientation() {
+        const { layoutRows } = global.workspace_manager;
+        this._swipeTracker.orientation = layoutRows !== -1
+            ? Clutter.Orientation.HORIZONTAL
+            : Clutter.Orientation.VERTICAL;
+    }
+
     _directionForProgress(progress) {
         if (global.workspace_manager.layout_rows === -1) {
             return progress > 0
@@ -712,10 +724,6 @@ class WorkspacesDisplay extends St.Widget {
         if (this._gestureActive)
             adjustment.remove_transition('value');
 
-        tracker.orientation = workspaceManager.layout_rows !== -1
-            ? Clutter.Orientation.HORIZONTAL
-            : Clutter.Orientation.VERTICAL;
-
         const distance = global.workspace_manager.layout_rows === -1
             ? this.height : this.width;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]