i3 - improved tiling WM


Prevent workspace change during global fullscreen

Patch status: merged

Patch by Mats

Long description:

While in global fullscreen, the workspace could be changed leaving the
fullscreen container still visible on top but losing its focus.

To apply this patch, use:
curl http://cr.i3wm.org/patch/686/raw.patch | git am

b/src/commands.c

16
@@ -958,6 +958,12 @@ void cmd_workspace(I3_CMD, char *which) {
17
 
18
     DLOG("which=%s\n", which);
19
 
20
+    if (con_get_fullscreen_con(croot, CF_GLOBAL)) {
21
+        LOG("Cannot switch workspace while in global fullscreen\n");
22
+        ysuccess(false);
23
+        return;
24
+    }
25
+
26
     if (strcmp(which, "next") == 0)
27
         ws = workspace_next();
28
     else if (strcmp(which, "prev") == 0)
29
@@ -986,6 +992,12 @@ void cmd_workspace(I3_CMD, char *which) {
30
 void cmd_workspace_number(I3_CMD, char *which) {
31
     Con *output, *workspace = NULL;
32
 
33
+    if (con_get_fullscreen_con(croot, CF_GLOBAL)) {
34
+        LOG("Cannot switch workspace while in global fullscreen\n");
35
+        ysuccess(false);
36
+        return;
37
+    }
38
+
39
     long parsed_num = ws_name_to_number(which);
40
 
41
     if (parsed_num == -1) {
42
@@ -1020,6 +1032,12 @@ void cmd_workspace_number(I3_CMD, char *which) {
43
  *
44
  */
45
 void cmd_workspace_back_and_forth(I3_CMD) {
46
+    if (con_get_fullscreen_con(croot, CF_GLOBAL)) {
47
+        LOG("Cannot switch workspace while in global fullscreen\n");
48
+        ysuccess(false);
49
+        return;
50
+    }
51
+
52
     workspace_back_and_forth();
53
 
54
     cmd_output->needs_tree_render = true;
55
@@ -1038,6 +1056,12 @@ void cmd_workspace_name(I3_CMD, char *name) {
56
         return;
57
     }
58
 
59
+    if (con_get_fullscreen_con(croot, CF_GLOBAL)) {
60
+        LOG("Cannot switch workspace while in global fullscreen\n");
61
+        ysuccess(false);
62
+        return;
63
+    }
64
+
65
     DLOG("should switch to workspace %s\n", name);
66
     if (maybe_back_and_forth(cmd_output, name))
67
         return;

b/testcases/t/100-fullscreen.t

72
@@ -192,6 +192,26 @@ cmd 'focus left';
73
 is($x->input_focus, $window->id, 'fullscreen window still focused');
74
 
75
 ################################################################################
76
+# Verify that changing workspace while in global fullscreen does not work.
77
+################################################################################
78
+
79
+$tmp = fresh_workspace;
80
+$window = open_window;
81
+
82
+cmd 'fullscreen global';
83
+is($x->input_focus, $window->id, 'window focused');
84
+is(focused_ws(), $tmp, 'workspace selected');
85
+
86
+$other = get_unused_workspace;
87
+cmd "workspace $other";
88
+is($x->input_focus, $window->id, 'window still focused');
89
+is(focused_ws(), $tmp, 'workspace still selected');
90
+
91
+# leave global fullscreen so that is does not interfere with the other tests
92
+$window->fullscreen(0);
93
+sync_with_i3;
94
+
95
+################################################################################
96
 # Verify that fullscreening a window on a second workspace and moving it onto
97
 # the first workspace unfullscreens the first window.
98
 ################################################################################