[gnome-shell] windowManager: Split out workspace insertion from thumbnails



commit cc05d303d89e697059f2d2bf27d2f6084a65235f
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jan 15 23:03:24 2015 +0100

    windowManager: Split out workspace insertion from thumbnails
    
    We will soon allow to insert a new workspace by other means than
    DND in between workspace thumbnails, so move the relevant code
    to a new windowManager method.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=665764

 js/ui/windowManager.js      |   25 +++++++++++++++++++++++++
 js/ui/workspaceThumbnail.js |   24 +-----------------------
 2 files changed, 26 insertions(+), 23 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 65ec623..70d723c 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -888,6 +888,31 @@ const WindowManager = new Lang.Class({
         Main.activateWindow(nextWindow);
     },
 
+    insertWorkspace: function(pos) {
+        if (!Meta.prefs_get_dynamic_workspaces())
+            return;
+
+        let windows = global.get_window_actors().map(function(winActor) {
+            return winActor.meta_window;
+        });
+
+        // To create a new workspace, we slide all the windows on workspaces
+        // below us to the next workspace, leaving a blank workspace for us
+        // to recycle.
+        windows.forEach(function(window) {
+            // If the window is attached to an ancestor, we don't need/want
+            // to move it
+            if (window.get_transient_for() != null)
+                return;
+            // Windows on workspaces below pos don't need moving
+            let index = window.get_workspace().index();
+            if (index < pos)
+                return;
+            window.change_workspace_by_index(index + 1, true);
+        });
+    },
+
+
     keepWorkspaceAlive: function(workspace, duration) {
         if (!this._workspaceTracker)
             return;
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index 3adc327..df8bc55 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -795,35 +795,13 @@ const ThumbnailsBox = new Lang.Class({
 
             let isWindow = !!source.realWindow;
 
-            // To create a new workspace, we first slide all the windows on workspaces
-            // below us to the next workspace, leaving a blank workspace for us to recycle.
             let newWorkspaceIndex;
             [newWorkspaceIndex, this._dropPlaceholderPos] = [this._dropPlaceholderPos, -1];
-
-            // Nab all the windows below us.
-            let windows = global.get_window_actors().filter(function(winActor) {
-                // If the window is attached to an ancestor, we don't need/want to move it
-                let window = winActor.meta_window;
-
-                if (window.get_transient_for() != null)
-                    return false;
-
-                if (isWindow)
-                    return window.get_workspace().index() >= newWorkspaceIndex && winActor != source;
-                else
-                    return window.get_workspace().index() >= newWorkspaceIndex;
-            });
-
             this._spliceIndex = newWorkspaceIndex;
 
-            // ... move them down one.
-            windows.forEach(function(winActor) {
-                let window = winActor.meta_window;
-                window.change_workspace_by_index(window.get_workspace().index() + 1, true);
-            });
+            Main.wm.insertWorkspace(newWorkspaceIndex);
 
             if (isWindow) {
-                // ... and bam, a workspace, good as new.
                 // Move the window to our monitor first if necessary.
                 let thumbMonitor = this._thumbnails[newWorkspaceIndex].monitorIndex;
                 if (source.metaWindow.get_monitor() != thumbMonitor)


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