[gnome-shell/wip/exalm/swipes: 8/8] swipeTracker: Pass orientation in constructor




commit aa2ab156de303cd3531d3730cbcbc5d3d143db94
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Mon Mar 1 21:53:55 2021 +0500

    swipeTracker: Pass orientation in constructor
    
    When this class was written, all swipes in the shell were vertical, so it
    made sense to make the default orientation vertical. This isn't the case
    anymore, thus pass make it mandatory to specify orientation when creating
    a tracker.
    
    Change the property default values to horizontal as well to match Clutter
    instead of the old shell design.

 js/ui/appDisplay.js         |  1 +
 js/ui/overview.js           |  1 +
 js/ui/swipeTracker.js       | 23 ++++++++++++++---------
 js/ui/unlockDialog.js       |  5 +++--
 js/ui/workspaceAnimation.js |  4 +++-
 js/ui/workspacesView.js     |  1 +
 6 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index dee7df3002..7a41122f9f 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -181,6 +181,7 @@ var BaseAppView = GObject.registerClass({
 
         // Swipe
         this._swipeTracker = new SwipeTracker.SwipeTracker(this._scrollView,
+            Clutter.Orientation.HORIZONTAL,
             Shell.ActionMode.OVERVIEW | Shell.ActionMode.POPUP);
         this._swipeTracker.orientation = Clutter.Orientation.HORIZONTAL;
         this._swipeTracker.connect('begin', this._swipeBegin.bind(this));
diff --git a/js/ui/overview.js b/js/ui/overview.js
index ac1a349da6..af83a1187e 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -236,6 +236,7 @@ var Overview = class {
             this.toggle.bind(this));
 
         const swipeTracker = new SwipeTracker.SwipeTracker(global.stage,
+            Clutter.Orientation.VERTICAL,
             Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
             { allowDrag: false, allowScroll: false });
         swipeTracker.orientation = Clutter.Orientation.VERTICAL;
diff --git a/js/ui/swipeTracker.js b/js/ui/swipeTracker.js
index e93cb889b9..0687fbc847 100644
--- a/js/ui/swipeTracker.js
+++ b/js/ui/swipeTracker.js
@@ -94,7 +94,7 @@ const TouchpadSwipeGesture = GObject.registerClass({
         'orientation': GObject.ParamSpec.enum(
             'orientation', 'orientation', 'orientation',
             GObject.ParamFlags.READWRITE,
-            Clutter.Orientation, Clutter.Orientation.VERTICAL),
+            Clutter.Orientation, Clutter.Orientation.HORIZONTAL),
     },
     Signals: {
         'begin':  { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] },
@@ -218,7 +218,7 @@ const TouchSwipeGesture = GObject.registerClass({
         'orientation': GObject.ParamSpec.enum(
             'orientation', 'orientation', 'orientation',
             GObject.ParamFlags.READWRITE,
-            Clutter.Orientation, Clutter.Orientation.VERTICAL),
+            Clutter.Orientation, Clutter.Orientation.HORIZONTAL),
     },
     Signals: {
         'begin':  { param_types: [GObject.TYPE_UINT, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] },
@@ -314,7 +314,7 @@ const ScrollGesture = GObject.registerClass({
         'orientation': GObject.ParamSpec.enum(
             'orientation', 'orientation', 'orientation',
             GObject.ParamFlags.READWRITE,
-            Clutter.Orientation, Clutter.Orientation.VERTICAL),
+            Clutter.Orientation, Clutter.Orientation.HORIZONTAL),
         'scroll-modifiers': GObject.ParamSpec.flags(
             'scroll-modifiers', 'scroll-modifiers', 'scroll-modifiers',
             GObject.ParamFlags.READWRITE,
@@ -442,7 +442,7 @@ var SwipeTracker = GObject.registerClass({
         'orientation': GObject.ParamSpec.enum(
             'orientation', 'orientation', 'orientation',
             GObject.ParamFlags.READWRITE,
-            Clutter.Orientation, Clutter.Orientation.VERTICAL),
+            Clutter.Orientation, Clutter.Orientation.HORIZONTAL),
         'distance': GObject.ParamSpec.double(
             'distance', 'distance', 'distance',
             GObject.ParamFlags.READWRITE,
@@ -462,10 +462,11 @@ var SwipeTracker = GObject.registerClass({
         'end':    { param_types: [GObject.TYPE_UINT64, GObject.TYPE_DOUBLE] },
     },
 }, class SwipeTracker extends GObject.Object {
-    _init(actor, allowedModes, params) {
+    _init(actor, orientation, allowedModes, params) {
         super._init();
         params = Params.parse(params, { allowDrag: true, allowScroll: true });
 
+        this.orientation = orientation;
         this._allowedModes = allowedModes;
         this._enabled = true;
         this._allowLongSwipes = false;
@@ -478,7 +479,8 @@ var SwipeTracker = GObject.registerClass({
         this._touchpadGesture.connect('update', this._updateGesture.bind(this));
         this._touchpadGesture.connect('end', this._endTouchpadGesture.bind(this));
         this.bind_property('enabled', this._touchpadGesture, 'enabled', 0);
-        this.bind_property('orientation', this._touchpadGesture, 'orientation', 0);
+        this.bind_property('orientation', this._touchpadGesture, 'orientation',
+            GObject.BindingFlags.SYNC_CREATE);
 
         this._touchGesture = new TouchSwipeGesture(allowedModes,
             GESTURE_FINGER_COUNT,
@@ -488,7 +490,8 @@ var SwipeTracker = GObject.registerClass({
         this._touchGesture.connect('end', this._endTouchGesture.bind(this));
         this._touchGesture.connect('cancel', this._cancelTouchGesture.bind(this));
         this.bind_property('enabled', this._touchGesture, 'enabled', 0);
-        this.bind_property('orientation', this._touchGesture, 'orientation', 0);
+        this.bind_property('orientation', this._touchGesture, 'orientation',
+            GObject.BindingFlags.SYNC_CREATE);
         this.bind_property('distance', this._touchGesture, 'distance', 0);
         global.stage.add_action(this._touchGesture);
 
@@ -500,7 +503,8 @@ var SwipeTracker = GObject.registerClass({
             this._dragGesture.connect('end', this._endTouchGesture.bind(this));
             this._dragGesture.connect('cancel', this._cancelTouchGesture.bind(this));
             this.bind_property('enabled', this._dragGesture, 'enabled', 0);
-            this.bind_property('orientation', this._dragGesture, 'orientation', 0);
+            this.bind_property('orientation', this._dragGesture, 'orientation',
+                GObject.BindingFlags.SYNC_CREATE);
             this.bind_property('distance', this._dragGesture, 'distance', 0);
             actor.add_action(this._dragGesture);
         } else {
@@ -513,7 +517,8 @@ var SwipeTracker = GObject.registerClass({
             this._scrollGesture.connect('update', this._updateGesture.bind(this));
             this._scrollGesture.connect('end', this._endTouchpadGesture.bind(this));
             this.bind_property('enabled', this._scrollGesture, 'enabled', 0);
-            this.bind_property('orientation', this._scrollGesture, 'orientation', 0);
+            this.bind_property('orientation', this._scrollGesture, 'orientation',
+                GObject.BindingFlags.SYNC_CREATE);
             this.bind_property('scroll-modifiers',
                 this._scrollGesture, 'scroll-modifiers', 0);
         } else {
diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js
index 974600ae54..8ddae8b036 100644
--- a/js/ui/unlockDialog.js
+++ b/js/ui/unlockDialog.js
@@ -495,8 +495,9 @@ var UnlockDialog = GObject.registerClass({
             this._setTransitionProgress(this._adjustment.value);
         });
 
-        this._swipeTracker = new SwipeTracker.SwipeTracker(
-            this, Shell.ActionMode.UNLOCK_SCREEN);
+        this._swipeTracker = new SwipeTracker.SwipeTracker(this,
+            Clutter.Orientation.VERTICAL,
+            Shell.ActionMode.UNLOCK_SCREEN);
         this._swipeTracker.connect('begin', this._swipeBegin.bind(this));
         this._swipeTracker.connect('update', this._swipeUpdate.bind(this));
         this._swipeTracker.connect('end', this._swipeEnd.bind(this));
diff --git a/js/ui/workspaceAnimation.js b/js/ui/workspaceAnimation.js
index 6cac580e71..d240fe1562 100644
--- a/js/ui/workspaceAnimation.js
+++ b/js/ui/workspaceAnimation.js
@@ -284,7 +284,9 @@ var WorkspaceAnimationController = class {
         });
 
         const swipeTracker = new SwipeTracker.SwipeTracker(global.stage,
-            Shell.ActionMode.NORMAL, { allowDrag: false });
+            Clutter.Orientation.HORIZONTAL,
+            Shell.ActionMode.NORMAL,
+            { allowDrag: false });
         swipeTracker.connect('begin', this._switchWorkspaceBegin.bind(this));
         swipeTracker.connect('update', this._switchWorkspaceUpdate.bind(this));
         swipeTracker.connect('end', this._switchWorkspaceEnd.bind(this));
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index fb9eafb0a8..ca3112c5c5 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -608,6 +608,7 @@ class WorkspacesDisplay extends St.Widget {
 
         this._swipeTracker = new SwipeTracker.SwipeTracker(
             Main.layoutManager.overviewGroup,
+            Clutter.Orientation.HORIZONTAL,
             Shell.ActionMode.OVERVIEW,
             { allowDrag: false });
         this._swipeTracker.allowLongSwipes = true;


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