+void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
+ y(map_open);
+ ystr("id");
+ y(integer, (long int)con);
+
+ ystr("type");
+ y(integer, con->type);
+
+ ystr("orientation");
+ switch (con->orientation) {
+ case NO_ORIENTATION:
+ ystr("none");
+ break;
+ case HORIZ:
+ ystr("horizontal");
+ break;
+ case VERT:
+ ystr("vertical");
+ break;
+ }
+
+ ystr("percent");
+ if (con->percent == 0.0)
+ y(null);
+ else y(double, con->percent);
+
+ ystr("urgent");
+ y(bool, con->urgent);
+
+ if (con->mark != NULL) {
+ ystr("mark");
+ ystr(con->mark);
+ }
+
+ ystr("focused");
+ y(bool, (con == focused));
+
+ ystr("layout");
+ switch (con->layout) {
+ case L_DEFAULT:
+ ystr("default");
+ break;
+ case L_STACKED:
+ ystr("stacked");
+ break;
+ case L_TABBED:
+ ystr("tabbed");
+ break;
+ case L_DOCKAREA:
+ ystr("dockarea");
+ break;
+ case L_OUTPUT:
+ ystr("output");
+ break;
+ }
+
+ ystr("border");
+ switch (con->border_style) {
+ case BS_NORMAL:
+ ystr("normal");
+ break;
+ case BS_NONE:
+ ystr("none");
+ break;
+ case BS_1PIXEL:
+ ystr("1pixel");
+ break;
+ }
+
+ dump_rect(gen, "rect", con->rect);
+ dump_rect(gen, "window_rect", con->window_rect);
+ dump_rect(gen, "geometry", con->geometry);
+
+ ystr("name");
+ ystr(con->name);
+
+ if (con->type == CT_WORKSPACE) {
+ ystr("num");
+ y(integer, con->num);
+ }
+
+ ystr("window");
+ if (con->window)
+ y(integer, con->window->id);
+ else y(null);
+
+ ystr("nodes");
+ y(array_open);
+ Con *node;
+ if (con->type != CT_DOCKAREA || !inplace_restart) {
+ TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
+ dump_node(gen, node, inplace_restart);
+ }
+ }
+ y(array_close);
+
+ ystr("floating_nodes");
+ y(array_open);
+ TAILQ_FOREACH(node, &(con->floating_head), floating_windows) {
+ dump_node(gen, node, inplace_restart);
+ }
+ y(array_close);
+
+ ystr("focus");
+ y(array_open);
+ TAILQ_FOREACH(node, &(con->focus_head), nodes) {
+ y(integer, (long int)node);
+ }
+ y(array_close);
+
+ ystr("fullscreen_mode");
+ y(integer, con->fullscreen_mode);
+
+ ystr("swallows");
+ y(array_open);
+ Match *match;
+ TAILQ_FOREACH(match, &(con->swallow_head), matches) {
+ if (match->dock != -1) {
+ y(map_open);
+ ystr("dock");
+ y(integer, match->dock);
+ ystr("insert_where");
+ y(integer, match->insert_where);
+ y(map_close);
+ }