Skip to content

Commit 997b519

Browse files
authored
Daemon: disable "Move to Workspace" when it does nothing (#2431)
1 parent 1e8de62 commit 997b519

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

daemon-gtk3/WindowMenu.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ public class Gala.Daemon.WindowMenu : Gtk.Menu {
174174
SignalHandler.unblock (always_on_top, always_on_top_sid);
175175
SignalHandler.unblock (on_visible_workspace, on_visible_workspace_sid);
176176

177-
move_right.sensitive = !on_visible_workspace.active;
177+
move_right.sensitive = !on_visible_workspace.active && Gala.WindowFlags.ALLOWS_MOVE_RIGHT in flags;
178178
if (move_right.sensitive) {
179179
move_right_accellabel.accel_string = keybind_settings.get_strv ("move-to-workspace-right")[0];
180180
}
181181

182-
move_left.sensitive = !on_visible_workspace.active;
182+
move_left.sensitive = !on_visible_workspace.active && Gala.WindowFlags.ALLOWS_MOVE_LEFT in flags;
183183
if (move_left.sensitive) {
184184
move_left_accellabel.accel_string = keybind_settings.get_strv ("move-to-workspace-left")[0];
185185
}

daemon/DBus.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public enum Gala.WindowFlags {
3636
ALWAYS_ON_TOP,
3737
ON_ALL_WORKSPACES,
3838
CAN_CLOSE,
39-
IS_TILED
39+
IS_TILED,
40+
ALLOWS_MOVE_LEFT,
41+
ALLOWS_MOVE_RIGHT
4042
}
4143

4244
[DBus (name = "org.pantheon.gala")]

daemon/WindowMenu.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ public class Gala.Daemon.WindowMenu : Gtk.Popover {
200200
SignalHandler.unblock (always_on_top, always_on_top_sid);
201201
SignalHandler.unblock (on_visible_workspace, on_visible_workspace_sid);
202202

203-
move_right.sensitive = !on_visible_workspace.active;
203+
move_right.sensitive = !on_visible_workspace.active && Gala.WindowFlags.ALLOWS_MOVE_RIGHT in flags;
204204
if (move_right.sensitive) {
205205
move_right_accellabel.accel_string = keybind_settings.get_strv ("move-to-workspace-right")[0];
206206
}
207207

208-
move_left.sensitive = !on_visible_workspace.active;
208+
move_left.sensitive = !on_visible_workspace.active && Gala.WindowFlags.ALLOWS_MOVE_LEFT in flags;
209209
if (move_left.sensitive) {
210210
move_left_accellabel.accel_string = keybind_settings.get_strv ("move-to-workspace-left")[0];
211211
}

lib/WindowManager.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ namespace Gala {
5656
ALWAYS_ON_TOP,
5757
ON_ALL_WORKSPACES,
5858
CAN_CLOSE,
59-
IS_TILED
59+
IS_TILED,
60+
ALLOWS_MOVE_LEFT,
61+
ALLOWS_MOVE_RIGHT
6062
}
6163

6264
/**

src/WindowManager.vala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,19 @@ namespace Gala {
937937
if (window.can_close ())
938938
flags |= WindowFlags.CAN_CLOSE;
939939

940+
unowned var workspace = window.get_workspace ();
941+
if (workspace != null) {
942+
unowned var manager = window.display.get_workspace_manager ();
943+
var workspace_index = workspace.workspace_index;
944+
if (workspace_index != 0) {
945+
flags |= WindowFlags.ALLOWS_MOVE_LEFT;
946+
}
947+
948+
if (workspace_index != manager.n_workspaces - 2 || Utils.get_n_windows (workspace) != 1) {
949+
flags |= WindowFlags.ALLOWS_MOVE_RIGHT;
950+
}
951+
}
952+
940953
daemon_manager.show_window_menu.begin (flags, x, y);
941954
break;
942955
case Meta.WindowMenuType.APP:

0 commit comments

Comments
 (0)