[gnome-shell/wip/fmuellner/fix-536] workspaceTracker: Don't keep multiple trailing workspaces



commit ce3c5c067ac681bd2a8fc56ea56b2b842aac28d3
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Sep 5 15:27:02 2018 +0200

    workspaceTracker: Don't keep multiple trailing workspaces
    
    Since we always keep the active workspace until the user switches
    to a different one, we may end up with two empty workspaces at
    the end. It's not obvious to users why this happens, and there's
    indeed no good reason for the behavior - just remove the trailing
    workspace in that case.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/issues/536

 js/ui/windowManager.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index b6627e253..ea0238f48 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -278,14 +278,21 @@ var WorkspaceTracker = new Lang.Class({
         // If we don't have an empty workspace at the end, add one
         if (!emptyWorkspaces[emptyWorkspaces.length -1]) {
             workspaceManager.append_new_workspace(false, global.get_current_time());
-            emptyWorkspaces.push(false);
+            emptyWorkspaces.push(true);
         }
 
         let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
+        let lastIndex = emptyWorkspaces.length - 1;
+        let removeOffset = 1; // keep the trailing empty workspace ...
+        if (emptyWorkspaces[activeWorkspaceIndex] &&
+            activeWorkspaceIndex == lastIndex - 1)
+            // ... except when we're on an empty workspace right before it
+            removeOffset = 0;
+
         emptyWorkspaces[activeWorkspaceIndex] = false;
 
         // Delete other empty workspaces; do it from the end to avoid index changes
-        for (i = emptyWorkspaces.length - 2; i >= 0; i--) {
+        for (i = lastIndex - removeOffset; i >= 0; i--) {
             if (emptyWorkspaces[i])
                 workspaceManager.remove_workspace(this._workspaces[i], global.get_current_time());
         }


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