Close all children when closing a workspace
Patch status: superseded
Patch by jj
Long description:
fixes #591
To apply this patch, use:
curl http://cr.i3wm.org/patch/225/raw.patch | git am
b/src/tree.c
15 |
@@ -360,7 +360,15 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool |
16 |
void tree_close_con(kill_window_t kill_window) { |
17 |
assert(focused != NULL); |
18 |
if (focused->type == CT_WORKSPACE) { |
19 |
- LOG("Cannot close workspace\n"); |
20 |
+ DLOG("A workspace container is focused, all children will be killed.\n"); |
21 |
+ Con *child, *nextchild; |
22 |
+ for (child = TAILQ_FIRST(&(focused->nodes_head)); child; ) { |
23 |
+ nextchild = TAILQ_NEXT(child, nodes); |
24 |
+ DLOG("killing child=%p\n", child); |
25 |
+ tree_close(child, kill_window, false, false); |
26 |
+ child = nextchild; |
27 |
+ } |
28 |
+ |
29 |
return; |
30 |
} |
31 |
|
b/testcases/t/129-focus-after-close.t
36 |
@@ -120,6 +120,30 @@ sync_with_i3; |
37 |
is(get_focused($tmp), $middle, 'middle container focused'); |
38 |
|
39 |
############################################################## |
40 |
+# check if the workspace container can be closed |
41 |
+############################################################## |
42 |
+ |
43 |
+$tmp = fresh_workspace; |
44 |
+ |
45 |
+my $window = open_window(); |
46 |
+ |
47 |
+# one window opened on the current workspace |
48 |
+($nodes, $focus) = get_ws_content($tmp); |
49 |
+is(scalar @$nodes, 1, 'workspace contains one node'); |
50 |
+ |
51 |
+# focus the workspace |
52 |
+cmd "focus parent"; |
53 |
+cmd "focus parent"; |
54 |
+ |
55 |
+# try to kill the workspace |
56 |
+cmd "kill"; |
57 |
+sync_with_i3; |
58 |
+ |
59 |
+# the workspace should now be empty |
60 |
+($nodes, $focus) = get_ws_content($tmp); |
61 |
+is(scalar @$nodes, 0, 'workspace is empty'); |
62 |
+ |
63 |
+############################################################## |
64 |
# and now for something completely different: |
65 |
# check if the pointer position is relevant when restoring focus |
66 |
# (it should not be relevant, of course) |