]> git.sur5r.net Git - i3/i3/commitdiff
randr: Skip workspaces which are assigned to a different output when creating a new...
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 7 Feb 2012 21:10:16 +0000 (21:10 +0000)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 7 Feb 2012 21:10:16 +0000 (21:10 +0000)
If you had workspace 1, 2, 3, 4 on LVDS1 and you enabled HDMI2 (where workspace
1 to workspace 5 are assigned to HDMI2), i3 would look for a new workspace for
LVDS1 (since all workspaces were moved), create workspace 5, move that over due
to assignment and then create workspace 6. Effectively, you would end up with
an empty workspace 5.

src/randr.c

index 5f1dad52ff71e796511af7097b73703cdb5595a9..1c01fdd5e35891904d1761b55dbbff2b4c02b0a7 100644 (file)
@@ -439,6 +439,22 @@ void init_ws_for_output(Output *output, Con *content) {
             ws->name[strlen(ws->name)-1] = '\0';
         DLOG("trying name *%s*\n", ws->name);
 
+        /* Ensure that this workspace is not assigned to a different output —
+         * otherwise we would create it, then move it over to its output, then
+         * find a new workspace, etc… */
+        bool assigned = false;
+        TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
+            if (strcmp(assignment->name, ws->name) != 0 ||
+                strcmp(assignment->output, output->name) == 0)
+                continue;
+
+            assigned = true;
+            break;
+        }
+
+        if (assigned)
+            continue;
+
         current = NULL;
         TAILQ_FOREACH(out, &(croot->nodes_head), nodes)
             GREP_FIRST(current, output_get_content(out), !strcasecmp(child->name, ws->name));