i3 - improved tiling WM


Prevent an infinite loop when an output is disabled

Patch status: superseded

Patch by Tony Crisci

Long description:

When looping over workspaces to reassign them from the output being
disabled, be sure to remove them from the loop. Do not rely on
tree_close to do this, because tree_close refuses to close a workspace
that is visible.

fixes #1103.

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

b/src/randr.c

19
@@ -716,13 +716,8 @@ void randr_query_outputs(void) {
20
                 Con *current;
21
                 Con *old_content = output_get_content(output->con);
22
                 while (!TAILQ_EMPTY(&(old_content->nodes_head))) {
23
+                    /* make sure the workspace is re-assigned first to avoid an infinite loop */
24
                     current = TAILQ_FIRST(&(old_content->nodes_head));
25
-                    if (current != next && TAILQ_EMPTY(&(current->focus_head))) {
26
-                        /* the workspace is empty and not focused, get rid of it */
27
-                        DLOG("Getting rid of current = %p / %s (empty, unfocused)\n", current, current->name);
28
-                        tree_close(current, DONT_KILL_WINDOW, false, false);
29
-                        continue;
30
-                    }
31
                     DLOG("Detaching current = %p / %s\n", current, current->name);
32
                     con_detach(current);
33
                     DLOG("Re-attaching current = %p / %s\n", current, current->name);
34
@@ -731,6 +726,11 @@ void randr_query_outputs(void) {
35
                     Con *floating_con;
36
                     TAILQ_FOREACH(floating_con, &(current->floating_head), floating_windows)
37
                         floating_fix_coordinates(floating_con, &(output->con->rect), &(first->con->rect));
38
+                    if (current != next && TAILQ_EMPTY(&(current->focus_head))) {
39
+                        /* the workspace is empty and not focused, get rid of it */
40
+                        DLOG("Getting rid of current = %p / %s (empty, unfocused)\n", current, current->name);
41
+                        tree_close(current, DONT_KILL_WINDOW, false, false);
42
+                    }
43
                     DLOG("Done, next\n");
44
                 }
45
                 DLOG("re-attached all workspaces\n");