i3 - improved tiling WM


Close all children when closing a workspace

Patch status: needinfo

Patch by jj

Long description:

fixes #591

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

b/src/tree.c

15
@@ -229,6 +229,11 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool
16
         return false;
17
     }
18
 
19
+    if (workspace_is_visible(con)) {
20
+        DLOG("A visible workspace cannot be killed.\n");
21
+        return false;
22
+    }
23
+
24
     if (con->window != NULL) {
25
         if (kill_window != DONT_KILL_WINDOW) {
26
             x_window_kill(con->window->id, kill_window);
27
@@ -359,10 +364,6 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool
28
  */
29
 void tree_close_con(kill_window_t kill_window) {
30
     assert(focused != NULL);
31
-    if (focused->type == CT_WORKSPACE) {
32
-        LOG("Cannot close workspace\n");
33
-        return;
34
-    }
35
 
36
     /* There *should* be no possibility to focus outputs / root container */
37
     assert(focused->type != CT_OUTPUT);

b/testcases/t/129-focus-after-close.t

42
@@ -120,6 +120,30 @@ sync_with_i3;
43
 is(get_focused($tmp), $middle, 'middle container focused');
44
 
45
 ##############################################################
46
+# check if the workspace container can be closed
47
+##############################################################
48
+
49
+$tmp = fresh_workspace;
50
+
51
+my $window = open_window();
52
+
53
+# one window opened on the current workspace
54
+($nodes, $focus) = get_ws_content($tmp);
55
+is(scalar @$nodes, 1, 'workspace contains one node');
56
+
57
+# focus the workspace
58
+cmd "focus parent";
59
+cmd "focus parent";
60
+
61
+# try to kill the workspace
62
+cmd "kill";
63
+sync_with_i3;
64
+
65
+# the workspace should now be empty
66
+($nodes, $focus) = get_ws_content($tmp);
67
+is(scalar @$nodes, 0, 'workspace is empty');
68
+
69
+##############################################################
70
 # and now for something completely different:
71
 # check if the pointer position is relevant when restoring focus
72
 # (it should not be relevant, of course)