Bugfix: When looking for an unused workspace, try the named workspaces first
Fixes: #449
This commit is contained in:
parent
72d2b2c9bd
commit
0092b245a1
43
src/randr.c
43
src/randr.c
|
@ -365,36 +365,43 @@ void init_ws_for_output(Output *output, Con *content) {
|
||||||
DLOG("Now adding a workspace\n");
|
DLOG("Now adding a workspace\n");
|
||||||
|
|
||||||
/* add a workspace to this output */
|
/* add a workspace to this output */
|
||||||
|
Con *out, *current;
|
||||||
|
bool exists = true;
|
||||||
Con *ws = con_new(NULL, NULL);
|
Con *ws = con_new(NULL, NULL);
|
||||||
ws->type = CT_WORKSPACE;
|
ws->type = CT_WORKSPACE;
|
||||||
|
|
||||||
|
/* try the configured workspace bindings first to find a free name */
|
||||||
|
Binding *bind;
|
||||||
|
TAILQ_FOREACH(bind, bindings, bindings) {
|
||||||
|
DLOG("binding with command %s\n", bind->command);
|
||||||
|
if (strlen(bind->command) < strlen("workspace ") ||
|
||||||
|
strncasecmp(bind->command, "workspace", strlen("workspace")) != 0)
|
||||||
|
continue;
|
||||||
|
DLOG("relevant command = %s\n", bind->command);
|
||||||
|
FREE(ws->name);
|
||||||
|
ws->name = strdup(bind->command + strlen("workspace "));
|
||||||
|
DLOG("trying name *%s*\n", ws->name);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(out, &(croot->nodes_head), nodes)
|
||||||
|
GREP_FIRST(current, output_get_content(out), !strcasecmp(child->name, ws->name));
|
||||||
|
|
||||||
|
exists = (current != NULL);
|
||||||
|
if (!exists)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* get the next unused workspace number */
|
/* get the next unused workspace number */
|
||||||
DLOG("Getting next unused workspace\n");
|
DLOG("Getting next unused workspace\n");
|
||||||
int c = 0;
|
int c = 0;
|
||||||
bool exists = true;
|
|
||||||
while (exists) {
|
while (exists) {
|
||||||
Con *out, *current, *child;
|
|
||||||
|
|
||||||
c++;
|
c++;
|
||||||
|
|
||||||
FREE(ws->name);
|
FREE(ws->name);
|
||||||
asprintf(&(ws->name), "%d", c);
|
asprintf(&(ws->name), "%d", c);
|
||||||
|
|
||||||
exists = false;
|
TAILQ_FOREACH(out, &(croot->nodes_head), nodes)
|
||||||
TAILQ_FOREACH(out, &(croot->nodes_head), nodes) {
|
GREP_FIRST(current, output_get_content(out), !strcasecmp(child->name, ws->name));
|
||||||
TAILQ_FOREACH(current, &(out->nodes_head), nodes) {
|
exists = (current != NULL);
|
||||||
if (current->type != CT_CON)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
TAILQ_FOREACH(child, &(current->nodes_head), nodes) {
|
|
||||||
if (strcasecmp(child->name, ws->name) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
exists = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DLOG("result for ws %s / %d: exists = %d\n", ws->name, c, exists);
|
DLOG("result for ws %s / %d: exists = %d\n", ws->name, c, exists);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue