[gnome-shell-extensions/wip/gcampagna/add-monitor-option] auto-move-windows: allow specifying a monitor index too



commit 5228d4578d250e9332ed38bb38321b42abab5150
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue Mar 26 16:12:19 2013 +0100

    auto-move-windows: allow specifying a monitor index too
    
    In addition to force windows on specific workspaces, it is useful to
    assign them a specific monitor too.
    Allow to do so by extending the configuration format.
    
    As a small change, windows now get moved to the primary monitor if
    they match a configured app. This is in line with the idea that
    workspaces are only on the primary monitor.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell-extensions/issues/3

 extensions/auto-move-windows/extension.js             | 19 ++++++++++++++++++-
 ...ome.shell.extensions.auto-move-windows.gschema.xml |  2 +-
 2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/extensions/auto-move-windows/extension.js b/extensions/auto-move-windows/extension.js
index e4c7fca..10fe117 100644
--- a/extensions/auto-move-windows/extension.js
+++ b/extensions/auto-move-windows/extension.js
@@ -68,11 +68,28 @@ const WindowMover = new Lang.Class({
             let apps_to_space = spaces[j].split(":");
             // Match application id
             if (apps_to_space[0] == app_id) {
-                let workspace_num = parseInt(apps_to_space[1]) - 1;
+                let workspace_num, monitor_num;
+
+                if (apps_to_space.length == 2) {
+                    workspace_num = parseInt(apps_to_space[1]);
+                    monitor_num = Main.layoutManager.primaryMonitor;
+                } else {
+                    workspace_num = apps_to_space[1] ? parseInt(apps_to_space[1]) :
+                        global.screen.get_active_workspace_index();
+                    monitor_num = parseInt(apps_to_space[2]);
+                }
 
                 if (workspace_num >= global.screen.n_workspaces)
                     this._ensureAtLeastWorkspaces(workspace_num, window);
+                if (workspace_num < 0)
+                    workspace_num = global.screen.get_active_workspace_index();
+
+                if (monitor_num >= Main.layoutManager.monitors.length)
+                    monitor_num = Main.layoutManager.monitors.length - 1;
+                if (monitor_num < 0)
+                    monitor_num = 0;
 
+                window.move_to_monitor(monitor_num);
                 window.change_workspace_by_index(workspace_num, false);
             }
         }
diff --git a/extensions/auto-move-windows/org.gnome.shell.extensions.auto-move-windows.gschema.xml 
b/extensions/auto-move-windows/org.gnome.shell.extensions.auto-move-windows.gschema.xml
index 1af61b3..34f035b 100644
--- a/extensions/auto-move-windows/org.gnome.shell.extensions.auto-move-windows.gschema.xml
+++ b/extensions/auto-move-windows/org.gnome.shell.extensions.auto-move-windows.gschema.xml
@@ -4,7 +4,7 @@
       <!-- FIXME: should be a(su), when JS supports more of GVariant -->
       <default>[ ]</default>
       <summary>Application and workspace list</summary>
-      <description>A list of strings, each containing an application id (desktop file name), followed by a 
colon and the workspace number</description>
+      <description>A list of strings, each containing an application id (desktop file name), followed by a 
colon and the workspace number, optionally followed by another colon and a monitor number.</description>
     </key>
   </schema>
 </schemalist>


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