I3_IPC_REPLY_TYPE_COMMAND, strlen(reply));
}
+static void dump_rect(yajl_gen gen, const char *name, Rect r) {
+ ystr(name);
+ y(map_open);
+ ystr("x");
+ y(integer, r.x);
+ ystr("y");
+ y(integer, r.y);
+ ystr("width");
+ y(integer, r.width);
+ ystr("height");
+ y(integer, r.height);
+ y(map_close);
+}
+
void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
y(map_open);
ystr("id");
ystr("border");
y(integer, con->border_style);
- ystr("rect");
- y(map_open);
- ystr("x");
- y(integer, con->rect.x);
- ystr("y");
- y(integer, con->rect.y);
- ystr("width");
- y(integer, con->rect.width);
- ystr("height");
- y(integer, con->rect.height);
- y(map_close);
+ dump_rect(gen, "rect", con->rect);
+ dump_rect(gen, "window_rect", con->window_rect);
ystr("name");
ystr(con->name);
static Con *to_focus;
static bool parsing_swallows;
static bool parsing_rect;
+static bool parsing_window_rect;
struct Match *current_swallow;
static int json_start_map(void *ctx) {
match_init(current_swallow);
TAILQ_INSERT_TAIL(&(json_node->swallow_head), current_swallow, matches);
} else {
- if (!parsing_rect)
+ if (!parsing_rect && !parsing_window_rect)
json_node = con_new(json_node);
}
return 1;
static int json_end_map(void *ctx) {
LOG("end of map\n");
- if (!parsing_swallows && !parsing_rect)
+ if (!parsing_swallows && !parsing_rect && !parsing_window_rect)
json_node = json_node->parent;
if (parsing_rect)
parsing_rect = false;
+ if (parsing_window_rect)
+ parsing_window_rect = false;
return 1;
}
}
if (strcasecmp(last_key, "rect") == 0)
parsing_rect = true;
+ if (strcasecmp(last_key, "window_rect") == 0)
+ parsing_window_rect = true;
return 1;
}
to_focus = json_node;
}
- if (parsing_rect) {
+ if (parsing_rect || parsing_window_rect) {
+ Rect *r = (parsing_rect ? &(json_node->rect) : &(json_node->window_rect));
if (strcasecmp(last_key, "x") == 0)
- json_node->rect.x = val;
+ r->x = val;
else if (strcasecmp(last_key, "y") == 0)
- json_node->rect.y = val;
+ r->y = val;
else if (strcasecmp(last_key, "width") == 0)
- json_node->rect.width = val;
+ r->width = val;
else if (strcasecmp(last_key, "height") == 0)
- json_node->rect.height = val;
+ r->height = val;
else printf("WARNING: unknown key %s in rect\n", last_key);
printf("rect now: (%d, %d, %d, %d)\n",
- json_node->rect.x, json_node->rect.y,
- json_node->rect.width, json_node->rect.height);
+ r->x, r->y, r->width, r->height);
}
if (parsing_swallows) {
if (strcasecmp(last_key, "id") == 0) {
yajl_status stat;
json_node = focused;
to_focus = NULL;
+ parsing_rect = false;
+ parsing_window_rect = false;
setlocale(LC_NUMERIC, "C");
stat = yajl_parse(hand, (const unsigned char*)buf, n);
if (stat != yajl_status_ok &&