[gnome-shell] windowManager: Block dynamic workspace updates while showing the popup



commit aeb971c33a78308d793195127489b355bba4233a
Author: Shivam Mishra <shivam m live com>
Date:   Wed Mar 25 16:52:24 2015 +0530

    windowManager: Block dynamic workspace updates while showing the popup
    
    Pause dynamic workspace management while workspaceSwitcherPopup
    is shown so as to eliminate infinite creation and destruction of
    workspaces, thus preventing stuttering while trying to move a
    window to last workspace.
    Add _isWorkspacePrepended flag to make sure only a single workspace
    is prepended at a time thus preventing the possibility of prepending
    infinite workspaces while dynamic workspace management is on pause.
    Prepend a new workspace by creating a new workspace instead of only
    shifting the windows to next workspace so that the workspaceSwitcherPopup
    may appear in sync with what's happening behind the scene and display
    correct number of workspaces.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712778

 js/ui/windowManager.js |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index bdde746..01d5107 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -197,6 +197,8 @@ const WorkspaceTracker = new Lang.Class({
         this._workspaces = [];
         this._checkWorkspacesId = 0;
 
+        this._pauseWorkspaceCheck = false;
+
         let tracker = Shell.WindowTracker.get_default();
         tracker.connect('startup-sequence-changed', Lang.bind(this, this._queueCheckWorkspaces));
 
@@ -220,6 +222,14 @@ const WorkspaceTracker = new Lang.Class({
         return new Gio.Settings({ schema_id: 'org.gnome.mutter' });
     },
 
+    blockUpdates: function() {
+        this._pauseWorkspaceCheck = true;
+    },
+
+    unblockUpdates: function() {
+        this._pauseWorkspaceCheck = false;
+    },
+
     _checkWorkspaces: function() {
         let i;
         let emptyWorkspaces = [];
@@ -229,6 +239,10 @@ const WorkspaceTracker = new Lang.Class({
             return false;
         }
 
+        // Update workspaces only if Dynamic Workspace Management has not been paused by some other function
+        if (this._pauseWorkspaceCheck)
+            return true;
+
         for (i = 0; i < this._workspaces.length; i++) {
             let lastRemoved = this._workspaces[i]._lastRemovedWindow;
             if ((lastRemoved &&
@@ -627,6 +641,8 @@ const WindowManager = new Lang.Class({
 
         this._allowedKeybindings = {};
 
+        this._isWorkspacePrepended = false;
+
         this._switchData = null;
         this._shellwm.connect('kill-switch-workspace', Lang.bind(this, this._switchWorkspaceDone));
         this._shellwm.connect('kill-window-effects', Lang.bind(this, function (shellwm, actor) {
@@ -915,6 +931,8 @@ const WindowManager = new Lang.Class({
         if (!Meta.prefs_get_dynamic_workspaces())
             return;
 
+        global.screen.append_new_workspace(false, global.get_current_time());
+
         let windows = global.get_window_actors().map(function(winActor) {
             return winActor.meta_window;
         });
@@ -1642,8 +1660,10 @@ const WindowManager = new Lang.Class({
         } else if (isNaN(target)) {
             // Prepend a new workspace dynamically
             if (screen.get_active_workspace_index() == 0 &&
-                action == 'move' && target == 'up')
+                action == 'move' && target == 'up' && this._isWorkspacePrepended == false) {
                 this.insertWorkspace(0);
+                this._isWorkspacePrepended = true;
+            }
 
             direction = Meta.MotionDirection[target.toUpperCase()];
             newWs = screen.get_active_workspace().get_neighbor(direction);
@@ -1668,9 +1688,12 @@ const WindowManager = new Lang.Class({
 
         if (!Main.overview.visible) {
             if (this._workspaceSwitcherPopup == null) {
+                this._workspaceTracker.blockUpdates();
                 this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
                 this._workspaceSwitcherPopup.connect('destroy', Lang.bind(this, function() {
+                    this._workspaceTracker.unblockUpdates();
                     this._workspaceSwitcherPopup = null;
+                    this._isWorkspacePrepended = false;
                 }));
             }
             this._workspaceSwitcherPopup.display(direction, newWs.index());


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