[gnome-shell-extensions] Auto-move-windows: don't manage workspaces if they're not dynamic



commit cd7d9aa2a4992d86975c14a4cfc24063f6078775
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Sep 1 19:07:03 2012 +0200

    Auto-move-windows: don't manage workspaces if they're not dynamic
    
    The workspace management done by auto-move-windows is semi-dynamic,
    in that it collects empty workspaces at the end, and ensures there
    is always one free.
    This is undesirable when the user explicitly choose static
    workspaces in the tweak tool or in dconf-editor.

 extensions/auto-move-windows/extension.js |  117 +++++++++++++++--------------
 1 files changed, 59 insertions(+), 58 deletions(-)
---
diff --git a/extensions/auto-move-windows/extension.js b/extensions/auto-move-windows/extension.js
index 4a1025f..e1aa7ff 100644
--- a/extensions/auto-move-windows/extension.js
+++ b/extensions/auto-move-windows/extension.js
@@ -87,75 +87,76 @@ function init() {
     settings = Convenience.getSettings();
 }
 
-function enable() {
-    prevCheckWorkspaces = Main._checkWorkspaces;
-    Main._checkWorkspaces = function() {
-        let i;
-        let emptyWorkspaces = new Array(Main._workspaces.length);
-
-        for (i = 0; i < Main._workspaces.length; i++) {
-            let lastRemoved = Main._workspaces[i]._lastRemovedWindow;
-            if (lastRemoved &&
-                (lastRemoved.get_window_type() == Meta.WindowType.SPLASHSCREEN ||
-                 lastRemoved.get_window_type() == Meta.WindowType.DIALOG ||
-                 lastRemoved.get_window_type() == Meta.WindowType.MODAL_DIALOG))
-                    emptyWorkspaces[i] = false;
-            else
-                emptyWorkspaces[i] = true;
-        }
-
+function myCheckWorkspaces() {
+    let i;
+    let emptyWorkspaces = new Array(Main._workspaces.length);
+
+    for (i = 0; i < Main._workspaces.length; i++) {
+	let lastRemoved = Main._workspaces[i]._lastRemovedWindow;
+	if (lastRemoved &&
+            (lastRemoved.get_window_type() == Meta.WindowType.SPLASHSCREEN ||
+             lastRemoved.get_window_type() == Meta.WindowType.DIALOG ||
+             lastRemoved.get_window_type() == Meta.WindowType.MODAL_DIALOG))
+            emptyWorkspaces[i] = false;
+	else
+            emptyWorkspaces[i] = true;
+    }
 
-        let windows = global.get_window_actors();
-        for (i = 0; i < windows.length; i++) {
-            let win = windows[i];
+    let windows = global.get_window_actors();
+    for (i = 0; i < windows.length; i++) {
+	let win = windows[i];
 
-            if (win.get_meta_window().is_on_all_workspaces())
-                continue;
+	if (win.get_meta_window().is_on_all_workspaces())
+            continue;
 
-            let workspaceIndex = win.get_workspace();
-            emptyWorkspaces[workspaceIndex] = false;
-        }
+	let workspaceIndex = win.get_workspace();
+	emptyWorkspaces[workspaceIndex] = false;
+    }
 
-        // If we don't have an empty workspace at the end, add one
-        if (!emptyWorkspaces[emptyWorkspaces.length -1]) {
-            global.screen.append_new_workspace(false, global.get_current_time());
-            emptyWorkspaces.push(false);
-        }
+    // If we don't have an empty workspace at the end, add one
+    if (!emptyWorkspaces[emptyWorkspaces.length -1]) {
+	global.screen.append_new_workspace(false, global.get_current_time());
+	emptyWorkspaces.push(false);
+    }
 
-        let activeWorkspaceIndex = global.screen.get_active_workspace_index();
-        let activeIsLast = activeWorkspaceIndex == global.screen.n_workspaces - 2;
-        let removingTrailWorkspaces = (emptyWorkspaces[activeWorkspaceIndex] &&
-                                        activeIsLast);
-        // Don't enter the overview when removing multiple empty workspaces at startup
-        let showOverview  = (removingTrailWorkspaces &&
-                             !emptyWorkspaces.every(function(x) { return x; }));
-
-        if (removingTrailWorkspaces) {
-            // "Merge" the empty workspace we are removing with the one at the end
-            Main.wm.blockAnimations();
-        }
+    let activeWorkspaceIndex = global.screen.get_active_workspace_index();
+    let activeIsLast = activeWorkspaceIndex == global.screen.n_workspaces - 2;
+    let removingTrailWorkspaces = (emptyWorkspaces[activeWorkspaceIndex] &&
+                                   activeIsLast);
+    // Don't enter the overview when removing multiple empty workspaces at startup
+    let showOverview  = (removingTrailWorkspaces &&
+                         !emptyWorkspaces.every(function(x) { return x; }));
+
+    if (removingTrailWorkspaces) {
+        // "Merge" the empty workspace we are removing with the one at the end
+        Main.wm.blockAnimations();
+    }
 
-        // Delete other empty workspaces; do it from the end to avoid index changes
-        for (i = emptyWorkspaces.length - 2; i >= 0; i--) {
-            if (emptyWorkspaces[i])
-                global.screen.remove_workspace(Main._workspaces[i], global.get_current_time());
-            else
-                break;
-        }
+    // Delete other empty workspaces; do it from the end to avoid index changes
+    for (i = emptyWorkspaces.length - 2; i >= 0; i--) {
+        if (emptyWorkspaces[i])
+            global.screen.remove_workspace(Main._workspaces[i], global.get_current_time());
+        else
+            break;
+    }
 
-        if (removingTrailWorkspaces) {
-            global.screen.get_workspace_by_index(global.screen.n_workspaces - 1).activate(global.get_current_time());
+    if (removingTrailWorkspaces) {
+        global.screen.get_workspace_by_index(global.screen.n_workspaces - 1).activate(global.get_current_time());
 
-            Main.wm.unblockAnimations();
+        Main.wm.unblockAnimations();
 
-            if (!Main.overview.visible && showOverview)
-                Main.overview.show();
-        }
+        if (!Main.overview.visible && showOverview)
+            Main.overview.show();
+    }
 
-        Main._checkWorkspacesId = 0;
-        return false;
+    Main._checkWorkspacesId = 0;
+    return false;
+}
 
-    };
+function enable() {
+    prevCheckWorkspaces = Main._checkWorkspaces;
+    if (Meta.prefs_get_dynamic_workspaces())
+	Main._checkWorkspaces = myCheckWorkspaces;
 
     winMover = new WindowMover();
 }



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