Fix dock client handling for inplace restarts
This commit is contained in:
parent
3dfe5c8a9a
commit
f34b045619
27
src/ipc.c
27
src/ipc.c
|
@ -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, "rect", con->rect);
|
||||||
dump_rect(gen, "window_rect", con->window_rect);
|
dump_rect(gen, "window_rect", con->window_rect);
|
||||||
|
dump_rect(gen, "geometry", con->geometry);
|
||||||
|
|
||||||
ystr("name");
|
ystr("name");
|
||||||
ystr(con->name);
|
ystr(con->name);
|
||||||
|
@ -224,8 +225,10 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
|
||||||
ystr("nodes");
|
ystr("nodes");
|
||||||
y(array_open);
|
y(array_open);
|
||||||
Con *node;
|
Con *node;
|
||||||
TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
|
if (con->type != CT_DOCKAREA || !inplace_restart) {
|
||||||
dump_node(gen, node, inplace_restart);
|
TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
|
||||||
|
dump_node(gen, node, inplace_restart);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
y(array_close);
|
y(array_close);
|
||||||
|
|
||||||
|
@ -246,17 +249,31 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
|
||||||
ystr("fullscreen_mode");
|
ystr("fullscreen_mode");
|
||||||
y(integer, con->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 (inplace_restart) {
|
||||||
if (con->window != NULL) {
|
if (con->window != NULL) {
|
||||||
ystr("swallows");
|
|
||||||
y(array_open);
|
|
||||||
y(map_open);
|
y(map_open);
|
||||||
ystr("id");
|
ystr("id");
|
||||||
y(integer, con->window->id);
|
y(integer, con->window->id);
|
||||||
y(map_close);
|
y(map_close);
|
||||||
y(array_close);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
y(array_close);
|
||||||
|
|
||||||
y(map_close);
|
y(map_close);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ static Con *to_focus;
|
||||||
static bool parsing_swallows;
|
static bool parsing_swallows;
|
||||||
static bool parsing_rect;
|
static bool parsing_rect;
|
||||||
static bool parsing_window_rect;
|
static bool parsing_window_rect;
|
||||||
|
static bool parsing_geometry;
|
||||||
struct Match *current_swallow;
|
struct Match *current_swallow;
|
||||||
|
|
||||||
static int json_start_map(void *ctx) {
|
static int json_start_map(void *ctx) {
|
||||||
|
@ -26,7 +27,7 @@ static int json_start_map(void *ctx) {
|
||||||
match_init(current_swallow);
|
match_init(current_swallow);
|
||||||
TAILQ_INSERT_TAIL(&(json_node->swallow_head), current_swallow, matches);
|
TAILQ_INSERT_TAIL(&(json_node->swallow_head), current_swallow, matches);
|
||||||
} else {
|
} else {
|
||||||
if (!parsing_rect && !parsing_window_rect) {
|
if (!parsing_rect && !parsing_window_rect && !parsing_geometry) {
|
||||||
if (last_key && strcasecmp(last_key, "floating_nodes") == 0) {
|
if (last_key && strcasecmp(last_key, "floating_nodes") == 0) {
|
||||||
Con *ws = con_get_workspace(json_node);
|
Con *ws = con_get_workspace(json_node);
|
||||||
json_node = con_new(NULL);
|
json_node = con_new(NULL);
|
||||||
|
@ -45,7 +46,7 @@ static int json_start_map(void *ctx) {
|
||||||
|
|
||||||
static int json_end_map(void *ctx) {
|
static int json_end_map(void *ctx) {
|
||||||
LOG("end of map\n");
|
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");
|
LOG("attaching\n");
|
||||||
con_attach(json_node, json_node->parent, false);
|
con_attach(json_node, json_node->parent, false);
|
||||||
json_node = json_node->parent;
|
json_node = json_node->parent;
|
||||||
|
@ -54,6 +55,8 @@ static int json_end_map(void *ctx) {
|
||||||
parsing_rect = false;
|
parsing_rect = false;
|
||||||
if (parsing_window_rect)
|
if (parsing_window_rect)
|
||||||
parsing_window_rect = false;
|
parsing_window_rect = false;
|
||||||
|
if (parsing_geometry)
|
||||||
|
parsing_geometry = false;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +78,8 @@ static int json_key(void *ctx, const unsigned char *val, unsigned int len) {
|
||||||
parsing_rect = true;
|
parsing_rect = true;
|
||||||
if (strcasecmp(last_key, "window_rect") == 0)
|
if (strcasecmp(last_key, "window_rect") == 0)
|
||||||
parsing_window_rect = true;
|
parsing_window_rect = true;
|
||||||
|
if (strcasecmp(last_key, "geometry") == 0)
|
||||||
|
parsing_geometry = true;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,8 +134,13 @@ static int json_int(void *ctx, long val) {
|
||||||
if (strcasecmp(last_key, "num") == 0)
|
if (strcasecmp(last_key, "num") == 0)
|
||||||
json_node->num = val;
|
json_node->num = val;
|
||||||
|
|
||||||
if (parsing_rect || parsing_window_rect) {
|
if (parsing_rect || parsing_window_rect || parsing_geometry) {
|
||||||
Rect *r = (parsing_rect ? &(json_node->rect) : &(json_node->window_rect));
|
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)
|
if (strcasecmp(last_key, "x") == 0)
|
||||||
r->x = val;
|
r->x = val;
|
||||||
else if (strcasecmp(last_key, "y") == 0)
|
else if (strcasecmp(last_key, "y") == 0)
|
||||||
|
@ -148,7 +158,10 @@ static int json_int(void *ctx, long val) {
|
||||||
current_swallow->id = val;
|
current_swallow->id = val;
|
||||||
}
|
}
|
||||||
if (strcasecmp(last_key, "dock") == 0) {
|
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;
|
to_focus = NULL;
|
||||||
parsing_rect = false;
|
parsing_rect = false;
|
||||||
parsing_window_rect = false;
|
parsing_window_rect = false;
|
||||||
|
parsing_geometry = false;
|
||||||
setlocale(LC_NUMERIC, "C");
|
setlocale(LC_NUMERIC, "C");
|
||||||
stat = yajl_parse(hand, (const unsigned char*)buf, n);
|
stat = yajl_parse(hand, (const unsigned char*)buf, n);
|
||||||
if (stat != yajl_status_ok &&
|
if (stat != yajl_status_ok &&
|
||||||
|
|
Loading…
Reference in New Issue