refactor some places to use output_get_content()

This commit is contained in:
Michael Stapelberg 2011-02-21 01:55:36 +01:00
parent a92b9dca73
commit 9719b21243
2 changed files with 38 additions and 57 deletions

View File

@ -288,13 +288,8 @@ IPC_HANDLER(get_workspaces) {
Con *output; Con *output;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) { TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
Con *child;
TAILQ_FOREACH(child, &(output->nodes_head), nodes) {
if (child->type != CT_CON)
continue;
Con *ws; Con *ws;
TAILQ_FOREACH(ws, &(child->nodes_head), nodes) { TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
assert(ws->type == CT_WORKSPACE); assert(ws->type == CT_WORKSPACE);
y(map_open); y(map_open);
@ -333,7 +328,6 @@ IPC_HANDLER(get_workspaces) {
y(map_close); y(map_close);
} }
} }
}
y(array_close); y(array_close);

View File

@ -18,39 +18,26 @@
* *
*/ */
Con *workspace_get(const char *num) { Con *workspace_get(const char *num) {
Con *output, *workspace = NULL, *current, *child; Con *output, *workspace = NULL, *child;
/* TODO: could that look like this in the future? /* TODO: could that look like this in the future?
GET_MATCHING_NODE(workspace, croot, strcasecmp(current->name, num) != 0); GET_MATCHING_NODE(workspace, croot, strcasecmp(current->name, num) != 0);
*/ */
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) { TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
TAILQ_FOREACH(current, &(output->nodes_head), nodes) { TAILQ_FOREACH(child, &(output_get_content(output)->nodes_head), nodes) {
if (current->type != CT_CON)
continue;
TAILQ_FOREACH(child, &(current->nodes_head), nodes) {
if (strcasecmp(child->name, num) != 0) if (strcasecmp(child->name, num) != 0)
continue; continue;
workspace = child; workspace = child;
break; break;
} }
}
}
LOG("getting ws %s\n", num); LOG("getting ws %s\n", num);
if (workspace == NULL) { if (workspace == NULL) {
LOG("need to create this one\n"); LOG("need to create this one\n");
output = con_get_output(focused); output = con_get_output(focused);
Con *child, *content = NULL; Con *content = output_get_content(output);
TAILQ_FOREACH(child, &(output->nodes_head), nodes) { LOG("got output %p with content %p\n", output, content);
if (child->type == CT_CON) {
content = child;
break;
}
}
assert(content != NULL);
LOG("got output %p with child %p\n", output, content);
/* We need to attach this container after setting its type. con_attach /* We need to attach this container after setting its type. con_attach
* will handle CT_WORKSPACEs differently */ * will handle CT_WORKSPACEs differently */
workspace = con_new(NULL); workspace = con_new(NULL);