Blob Blame History Raw
From dd7d9565555fcfc9ecc730e421ec2145988ea755 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Tue, 14 Mar 2017 17:04:36 +0100
Subject: [PATCH] windowMenu: Bring back workspaces submenu for static
 workspaces

When the titlebar context menu was moved to the shell, the submenu for
moving to a specific workspace was intentionally left out; some people
are quite attached to it though, so bring it back when static workspaces
are used.
---
 js/ui/windowMenu.js | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/js/ui/windowMenu.js b/js/ui/windowMenu.js
index 5cd6802e6..6b7f6f7c9 100644
--- a/js/ui/windowMenu.js
+++ b/js/ui/windowMenu.js
@@ -97,8 +97,6 @@ const WindowMenu = new Lang.Class({
             if (window.is_always_on_all_workspaces())
                 item.setSensitive(false);
 
-            let nWorkspaces = global.screen.n_workspaces;
-
             if (!isSticky) {
                 let workspace = window.get_workspace();
                 if (workspace != workspace.get_neighbor(Meta.MotionDirection.LEFT)) {
@@ -121,6 +119,22 @@ const WindowMenu = new Lang.Class({
                         window.change_workspace(workspace.get_neighbor(Meta.MotionDirection.DOWN));
                     }));
                 }
+
+                let nWorkspaces = global.screen.n_workspaces;
+                if (nWorkspaces > 1 && !Meta.prefs_get_dynamic_workspaces()) {
+                    item = new PopupMenu.PopupSubMenuMenuItem(_("Move to another workspace"));
+                    this.addMenuItem(item);
+
+                    let currentIndex = global.screen.get_active_workspace_index();
+                    for (let i = 0; i < nWorkspaces; i++) {
+                        let index = i;
+                        let name = Meta.prefs_get_workspace_name(i);
+                        let subitem = item.menu.addAction(name, Lang.bind(this, function() {
+                            window.change_workspace_by_index(index, false);
+                        }));
+                        subitem.setSensitive(currentIndex != i);
+                    }
+                }
             }
         }
 
-- 
2.12.0