[gnome-shell/wip/exalm/gestures: 2/11] b



commit 0dbd4ba8072787fc0d9109addb3eb3c095d3240c
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Fri Apr 26 17:21:50 2019 +0500

    b

 js/js-resources.gresource.xml |  1 +
 js/ui/swipeTracker.js         | 10 ++++-----
 js/ui/windowManager.js        | 52 ++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 57 insertions(+), 6 deletions(-)
---
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
index b5348ddcb..aec3427e0 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -98,6 +98,7 @@
     <file>ui/shellEntry.js</file>
     <file>ui/shellMountOperation.js</file>
     <file>ui/slider.js</file>
+    <file>ui/swipeTracker.js</file>
     <file>ui/switcherPopup.js</file>
     <file>ui/switchMonitor.js</file>
     <file>ui/tweener.js</file>
diff --git a/js/ui/swipeTracker.js b/js/ui/swipeTracker.js
index aa6db94fb..250b833d2 100644
--- a/js/ui/swipeTracker.js
+++ b/js/ui/swipeTracker.js
@@ -100,7 +100,7 @@ var SwipeTracker = class {
 
     _cancel() {
         this.emit('end', true, 0);
-        this.reset();
+        this._reset();
     }
 
     _handleEvent(actor, event) {
@@ -120,11 +120,11 @@ var SwipeTracker = class {
             return Clutter.EVENT_PROPAGATE;
 
         let time = event.get_time();
-        let [dx, dy] = event.get_scroll_delta();
+        let [dx, dy] = event.get_gesture_motion_delta(); //event.get_scroll_delta();
 
         if (event.get_gesture_phase() == Clutter.TouchpadGesturePhase.UPDATE) {
 //        if ((event.get_scroll_finish_flags() & Clutter.ScrollFinishFlags.VERTICAL == 0) || (dx == 0 && dy 
== 0))
-            if(!(this._touchpadSettings.get_boolean('natural-scroll'))).
+            if(!(this._touchpadSettings.get_boolean('natural-scroll')))
                 dy = -dy;
             this._updateGesture(time, -dy / TOUCHPAD_BASE_DISTANCE * SCROLL_MULTIPLIER); // TODO: multiply 
on actor diman
         } else if (event.get_gesture_phase() == Clutter.TouchpadGesturePhase.END)
@@ -146,7 +146,7 @@ var SwipeTracker = class {
 
     _updateGesture(time, delta) {
         if (this._state != State.SCROLLING) {
-            _beginGesture(time);
+            this._beginGesture(time);
         }
 
         this._progress += delta;
@@ -163,7 +163,7 @@ var SwipeTracker = class {
         let minProgress = (this._progress < 0) ? -1 : 0;
         this._progress = clamp(this._progress, minProgress, maxProgress);
 
-        this.emit('progress', this._progress);
+        this.emit('update', this._progress);
 
         this._prevTime = time;
     }
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 1d94e1583..802d446c4 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -17,6 +17,7 @@ const PadOsd = imports.ui.padOsd;
 const EdgeDragAction = imports.ui.edgeDragAction;
 const CloseDialog = imports.ui.closeDialog;
 const SwitchMonitor = imports.ui.switchMonitor;
+const SwipeTracker = imports.ui.swipeTracker;
 
 const { loadInterfaceXML } = imports.misc.fileUtils;
 
@@ -1060,7 +1061,7 @@ var WindowManager = class {
                                                            false, -1, 1);
 
         let allowedModes = Shell.ActionMode.NORMAL;
-        let gesture = new WorkspaceSwitchAction(allowedModes);
+/*        let gesture = new WorkspaceSwitchAction(allowedModes);
         gesture.connect('motion', this._switchWorkspaceMotion.bind(this));
         gesture.connect('activated', this._actionSwitchWorkspace.bind(this));
         gesture.connect('cancel', this._switchWorkspaceCancel.bind(this));
@@ -1071,6 +1072,11 @@ var WindowManager = class {
         gesture.connect('motion', this._switchWorkspaceMotion.bind(this));
         gesture.connect('activated', this._actionSwitchWorkspace.bind(this));
         gesture.connect('cancel', this._switchWorkspaceCancel.bind(this));
+*/
+        let gesture = new SwipeTracker.SwipeTracker(global.stage, allowedModes);
+        gesture.connect('begin', this._switchWorkspaceBegin.bind(this));
+        gesture.connect('update', this._switchWorkspaceUpdate.bind(this));
+        gesture.connect('end', this._switchWorkspaceEnd.bind(this));
 
         gesture = new AppSwitchAction();
         gesture.connect('activated', this._switchApp.bind(this));
@@ -1112,6 +1118,50 @@ var WindowManager = class {
         return this._currentPadOsd.actor;
     }
 
+    _switchWorkspaceBegin() {
+        let workspaceManager = global.workspace_manager;
+        let activeWorkspace = workspaceManager.get_active_workspace();
+
+        if (!this._switchData)
+            this._prepareWorkspaceSwitch(activeWorkspace.index(), -1);
+    }
+
+    _switchWorkspaceUpdate(progress) {
+        if (!this._switchData)
+            return;
+
+        if (yRel < 0 && !this._switchData.surroundings[Meta.MotionDirection.DOWN])
+            yRel = 0;
+        if (yRel > 0 && !this._switchData.surroundings[Meta.MotionDirection.UP])
+            yRel = 0;
+        if (xRel < 0 && !this._switchData.surroundings[Meta.MotionDirection.RIGHT])
+            xRel = 0;
+        if (xRel > 0 && !this._switchData.surroundings[Meta.MotionDirection.LEFT])
+            xRel = 0;
+
+        this._switchData.container.set_position(xRel, yRel);
+    }
+
+    _switchWorkspaceEnd(cancelled, duration) {
+        if (!this._switchData)
+            return;
+
+        if (cancelled)
+            this._switchWorkspaceCancel();
+        let direction = Meta.MotionDirection.DOWN;
+
+        let workspaceManager = global.workspace_manager;
+        let activeWorkspace = workspaceManager.get_active_workspace();
+        let newWs = activeWorkspace.get_neighbor(direction);
+
+        if (newWs == activeWorkspace) {
+            this._switchWorkspaceCancel();
+        } else {
+            this._switchData.gestureActivated = true;
+            this.actionMoveWorkspace(newWs);
+        }
+    }
+
     _switchWorkspaceMotion(action, xRel, yRel) {
         let workspaceManager = global.workspace_manager;
         let activeWorkspace = workspaceManager.get_active_workspace();


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