Fix dock client handling for inplace restarts

next
Michael Stapelberg 2011-02-21 03:01:55 +01:00
parent 3dfe5c8a9a
commit f34b045619
2 changed files with 41 additions and 10 deletions

View File

@ -207,6 +207,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
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);
@ -224,8 +225,10 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
ystr("nodes");
y(array_open);
Con *node;
TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
dump_node(gen, node, inplace_restart);
if (con->type != CT_DOCKAREA || !inplace_restart) {
TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
dump_node(gen, node, inplace_restart);
}
}
y(array_close);
@ -246,17 +249,31 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
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);
}
/* TODO: the other swallow keys */
}
if (inplace_restart) {
if (con->window != NULL) {
ystr("swallows");
y(array_open);
y(map_open);
ystr("id");
y(integer, con->window->id);
y(map_close);
y(array_close);
}
}
y(array_close);
y(map_close);
}

View File

@ -16,6 +16,7 @@ static Con *to_focus;
static bool parsing_swallows;
static bool parsing_rect;
static bool parsing_window_rect;
static bool parsing_geometry;
struct Match *current_swallow;
static int json_start_map(void *ctx) {
@ -26,7 +27,7 @@ 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 && !parsing_window_rect) {
if (!parsing_rect && !parsing_window_rect && !parsing_geometry) {
if (last_key && strcasecmp(last_key, "floating_nodes") == 0) {
Con *ws = con_get_workspace(json_node);
json_node = con_new(NULL);
@ -45,7 +46,7 @@ static int json_start_map(void *ctx) {
static int json_end_map(void *ctx) {
LOG("end of map\n");
if (!parsing_swallows && !parsing_rect && !parsing_window_rect) {
if (!parsing_swallows && !parsing_rect && !parsing_window_rect && !parsing_geometry) {
LOG("attaching\n");
con_attach(json_node, json_node->parent, false);
json_node = json_node->parent;
@ -54,6 +55,8 @@ static int json_end_map(void *ctx) {
parsing_rect = false;
if (parsing_window_rect)
parsing_window_rect = false;
if (parsing_geometry)
parsing_geometry = false;
return 1;
}
@ -75,6 +78,8 @@ static int json_key(void *ctx, const unsigned char *val, unsigned int len) {
parsing_rect = true;
if (strcasecmp(last_key, "window_rect") == 0)
parsing_window_rect = true;
if (strcasecmp(last_key, "geometry") == 0)
parsing_geometry = true;
return 1;
}
@ -129,8 +134,13 @@ static int json_int(void *ctx, long val) {
if (strcasecmp(last_key, "num") == 0)
json_node->num = val;
if (parsing_rect || parsing_window_rect) {
Rect *r = (parsing_rect ? &(json_node->rect) : &(json_node->window_rect));
if (parsing_rect || parsing_window_rect || parsing_geometry) {
Rect *r;
if (parsing_rect)
r = &(json_node->rect);
else if (parsing_window_rect)
r = &(json_node->window_rect);
else r = &(json_node->geometry);
if (strcasecmp(last_key, "x") == 0)
r->x = val;
else if (strcasecmp(last_key, "y") == 0)
@ -148,7 +158,10 @@ static int json_int(void *ctx, long val) {
current_swallow->id = val;
}
if (strcasecmp(last_key, "dock") == 0) {
current_swallow->dock = true;
current_swallow->dock = val;
}
if (strcasecmp(last_key, "insert_where") == 0) {
current_swallow->insert_where = val;
}
}
@ -191,6 +204,7 @@ void tree_append_json(const char *filename) {
to_focus = NULL;
parsing_rect = false;
parsing_window_rect = false;
parsing_geometry = false;
setlocale(LC_NUMERIC, "C");
stat = yajl_parse(hand, (const unsigned char*)buf, n);
if (stat != yajl_status_ok &&