From: Michael Stapelberg Date: Tue, 7 Feb 2012 21:10:16 +0000 (+0000) Subject: randr: Skip workspaces which are assigned to a different output when creating a new... X-Git-Tag: 4.2~92 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c1e0c38b271cd616d98994cbb62769419c7af93f;p=i3%2Fi3 randr: Skip workspaces which are assigned to a different output when creating a new workspace 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. --- diff --git a/src/randr.c b/src/randr.c index 5f1dad52..1c01fdd5 100644 --- a/src/randr.c +++ b/src/randr.c @@ -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));