[gnome-shell] workspacesView: Don't use the overview swipe scrolling system



commit 830e701d13d0a7696b4cd67a2f6fc5eb52af0d78
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 |   67 ++++++++++++++++------------------------------
 2 files changed, 30 insertions(+), 44 deletions(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 3c1f030..4b69922 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -347,6 +347,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 a247d2e..95d8ca5 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -2,6 +2,7 @@
 
 const Clutter = imports.gi.Clutter;
 const Gio = imports.gi.Gio;
+const GObject = imports.gi.GObject;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Meta = imports.gi.Meta;
@@ -385,24 +386,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();
     },
 
@@ -454,9 +442,21 @@ 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.bind_property('mapped', action, 'enabled', GObject.BindingFlags.SYNC_CREATE);
 
         let controls = new St.Bin({ style_class: 'workspace-controls',
                                     request_mode: Clutter.RequestMode.WIDTH_FOR_HEIGHT,
@@ -529,6 +529,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') ||
@@ -638,33 +645,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');
 
@@ -704,7 +684,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]