-
- /* add a workspace to this output */
- Con *ws = con_new(NULL, NULL);
- ws->type = CT_WORKSPACE;
-
- /* get the next unused workspace number */
- DLOG("Getting next unused workspace\n");
- int c = 0;
- bool exists = true;
- while (exists) {
- Con *out, *current, *child;
-
- c++;
-
- FREE(ws->name);
- asprintf(&(ws->name), "%d", c);
-
- exists = false;
- TAILQ_FOREACH(out, &(croot->nodes_head), nodes) {
- TAILQ_FOREACH(current, &(out->nodes_head), nodes) {
- 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);
- }
- ws->num = c;
- con_attach(ws, content, false);
-
- asprintf(&name, "[i3 con] workspace %s", ws->name);
- x_set_name(ws, name);
- free(name);
-
- ws->fullscreen_mode = CF_OUTPUT;
-
- /* If default_orientation is set to NO_ORIENTATION we determine
- * orientation depending on output resolution. */
- if (config.default_orientation == NO_ORIENTATION) {
- ws->orientation = (output->rect.height > output->rect.width) ? VERT : HORIZ;
- DLOG("Auto orientation. Workspace size set to (%d,%d), setting orientation to %d.\n",
- output->rect.width, output->rect.height, ws->orientation);
- } else {
- ws->orientation = config.default_orientation;
- }
-