[gnome-shell/wip/grab-helper-top-panel: 15/20] workspacesView: Don't use the overview swipe scrolling system



commit 1e40264ee41f8ca1d70f3dd5cb7aa257fcb7fef7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Nov 25 23:40:48 2012 -0500

    workspacesView: Don't use the overview swipe scrolling system
    
    Switch to a ClutterPanAction instead too.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689062

 js/ui/overview.js       |    7 +++++
 js/ui/workspacesView.js |   68 ++++++++++++++++------------------------------
 2 files changed, 31 insertions(+), 44 deletions(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 3f1663f..de62961 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -341,6 +341,13 @@ const Overview = new Lang.Class({
         return DND.DragMotionResult.CONTINUE;
     },
 
+    addAction: function(action) {
+        if (this.isDummy)
+            return;
+
+        this._group.add_action(action);
+    },
+
     setScrollAdjustment: function(adjustment, direction) {
         if (this.isDummy)
             return;
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index b9fdd1e..bbfed60 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -382,24 +382,11 @@ const WorkspacesView = new Lang.Class({
         this._scrolling = true;
     },
 
-    endSwipeScroll: function(result) {
+    endSwipeScroll: function() {
         this._scrolling = false;
 
-        if (result == Overview.SwipeScrollResult.CLICK) {
-            let [x, y, mod] = global.get_pointer();
-            let actor = global.stage.get_actor_at_pos(Clutter.PickMode.ALL,
-                                                      x, y);
-
-            // Only switch to the workspace when there's no application
-            // windows open. The problem is that it's too easy to miss
-            // an app window and get the wrong one focused.
-            let active = global.screen.get_active_workspace_index();
-            if (this._workspaces[active].isEmpty() &&
-                this.actor.contains(actor))
-                Main.overview.hide();
-        }
-
         // Make sure title captions etc are shown as necessary
+        this._scrollToActive();
         this._updateVisibility();
     },
 
@@ -451,9 +438,23 @@ const WorkspacesDisplay = new Lang.Class({
         this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
         this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
         this.actor.connect('allocate', Lang.bind(this, this._allocate));
-        this.actor.connect('notify::mapped', Lang.bind(this, this._setupSwipeScrolling));
         this.actor.connect('parent-set', Lang.bind(this, this._parentSet));
         this.actor.set_clip_to_allocation(true);
+        let action = new Clutter.PanAction();
+        action.connect('pan', Lang.bind(this, this._onPan));
+        action.connect('gesture-begin', Lang.bind(this, function() {
+            for (let i = 0; i < this._workspacesViews.length; i++)
+                this._workspacesViews[i].startSwipeScroll();
+            return true;
+        }));
+        action.connect('gesture-end', Lang.bind(this, function() {
+            for (let i = 0; i < this._workspacesViews.length; i++)
+                this._workspacesViews[i].endSwipeScroll();
+        }));
+        Main.overview.addAction(action);
+        this.actor.connect('notify::mapped', Lang.bind(this, function() {
+            action.enabled = this.actor.mapped;
+        }));
 
         let controls = new St.Bin({ style_class: 'workspace-controls',
                                     request_mode: Clutter.RequestMode.WIDTH_FOR_HEIGHT,
@@ -526,6 +527,13 @@ const WorkspacesDisplay = new Lang.Class({
             Lang.bind(this, this._updateSwitcherVisibility));
     },
 
+    _onPan: function(action) {
+        let [dist, dx, dy] = action.get_motion_delta(0);
+        let adjustment = this._scrollAdjustment;
+        adjustment.value -= (dy / this.actor.height) * adjustment.page_size;
+        return false;
+    },
+
     _updateSwitcherVisibility: function() {
         this._thumbnailsBox.actor.visible =
             this._settings.get_boolean('dynamic-workspaces') ||
@@ -635,33 +643,6 @@ const WorkspacesDisplay = new Lang.Class({
             }
     },
 
-    _setupSwipeScrolling: function() {
-        if (this._swipeScrollBeginId)
-            Main.overview.disconnect(this._swipeScrollBeginId);
-        this._swipeScrollBeginId = 0;
-
-        if (this._swipeScrollEndId)
-            Main.overview.disconnect(this._swipeScrollEndId);
-        this._swipeScrollEndId = 0;
-
-        if (!this.actor.mapped)
-            return;
-
-        let direction = Overview.SwipeScrollDirection.VERTICAL;
-        Main.overview.setScrollAdjustment(this._scrollAdjustment,
-                                          direction);
-        this._swipeScrollBeginId = Main.overview.connect('swipe-scroll-begin',
-            Lang.bind(this, function() {
-                for (let i = 0; i < this._workspacesViews.length; i++)
-                    this._workspacesViews[i].startSwipeScroll();
-            }));
-        this._swipeScrollEndId = Main.overview.connect('swipe-scroll-end',
-           Lang.bind(this, function(overview, result) {
-                for (let i = 0; i < this._workspacesViews.length; i++)
-                    this._workspacesViews[i].endSwipeScroll(result);
-           }));
-    },
-
     _workspacesOnlyOnPrimaryChanged: function() {
         this._workspacesOnlyOnPrimary = this._settings.get_boolean('workspaces-only-on-primary');
 
@@ -701,7 +682,6 @@ const WorkspacesDisplay = new Lang.Class({
                 this._scrollAdjustment = view.scrollAdjustment;
                 this._scrollAdjustment.connect('notify::value',
                                                Lang.bind(this, this._scrollValueChanged));
-                this._setupSwipeScrolling();
             }
             this._workspacesViews.push(view);
         }



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