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,50 +288,44 @@ IPC_HANDLER(get_workspaces) {
Con *output; Con *output;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) { TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
Con *child; Con *ws;
TAILQ_FOREACH(child, &(output->nodes_head), nodes) { TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
if (child->type != CT_CON) assert(ws->type == CT_WORKSPACE);
continue; y(map_open);
Con *ws; ystr("num");
TAILQ_FOREACH(ws, &(child->nodes_head), nodes) { if (ws->num == -1)
assert(ws->type == CT_WORKSPACE); y(null);
y(map_open); else y(integer, ws->num);
ystr("num"); ystr("name");
if (ws->num == -1) ystr(ws->name);
y(null);
else y(integer, ws->num);
ystr("name"); ystr("visible");
ystr(ws->name); y(bool, workspace_is_visible(ws));
ystr("visible"); ystr("focused");
y(bool, workspace_is_visible(ws)); y(bool, ws == focused_ws);
ystr("focused"); ystr("rect");
y(bool, ws == focused_ws); y(map_open);
ystr("x");
y(integer, ws->rect.x);
ystr("y");
y(integer, ws->rect.y);
ystr("width");
y(integer, ws->rect.width);
ystr("height");
y(integer, ws->rect.height);
y(map_close);
ystr("rect"); ystr("output");
y(map_open); ystr(output->name);
ystr("x");
y(integer, ws->rect.x);
ystr("y");
y(integer, ws->rect.y);
ystr("width");
y(integer, ws->rect.width);
ystr("height");
y(integer, ws->rect.height);
y(map_close);
ystr("output"); ystr("urgent");
ystr(output->name); y(bool, ws->urgent);
ystr("urgent"); y(map_close);
y(bool, ws->urgent);
y(map_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) if (strcasecmp(child->name, num) != 0)
continue; continue;
TAILQ_FOREACH(child, &(current->nodes_head), nodes) { workspace = child;
if (strcasecmp(child->name, num) != 0) break;
continue;
workspace = child;
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);