Fix restarting with 32bit depth windows (v5)

What I do in this patch is:

1. Split the con_new() function, so I can create a Con without actually
create a window.
2. Store the depth of Cons in the layout file when i3 is restarting.

Fix typos and mis-staged files in previous patch.
This commit is contained in:
Yuxuan Shui 2013-03-15 22:40:26 +08:00 committed by Michael Stapelberg
parent 7552a02d5c
commit 5b4ff1804d
5 changed files with 37 additions and 11 deletions

View File

@ -14,8 +14,13 @@
/**
* Create a new container (and attach it to the given parent, if not NULL).
* This function initializes the data structures and creates the appropriate
* X11 IDs using x_con_init().
* This function only initializes the data structures.
*
*/
Con *con_new_skeleton(Con *parent, i3Window *window);
/* A wrapper for con_new_skeleton, to retain the old con_new behaviour
*
*/
Con *con_new(Con *parent, i3Window *window);

View File

@ -584,6 +584,9 @@ struct Con {
/* The ID of this container before restarting. Necessary to correctly
* interpret back-references in the JSON (such as the focus stack). */
int old_id;
/* Depth of the container window */
uint16_t depth;
};
#endif

View File

@ -44,11 +44,10 @@ static void con_force_split_parents_redraw(Con *con) {
/*
* Create a new container (and attach it to the given parent, if not NULL).
* This function initializes the data structures and creates the appropriate
* X11 IDs using x_con_init().
* This function only initializes the data structures.
*
*/
Con *con_new(Con *parent, i3Window *window) {
Con *con_new_skeleton(Con *parent, i3Window *window) {
Con *new = scalloc(sizeof(Con));
new->on_remove_child = con_on_remove_child;
TAILQ_INSERT_TAIL(&all_cons, new, all_cons);
@ -56,6 +55,10 @@ Con *con_new(Con *parent, i3Window *window) {
new->window = window;
new->border_style = config.default_border;
new->current_border_width = -1;
if (window)
new->depth = window->depth;
else
new->depth = XCB_COPY_FROM_PARENT;
static int cnt = 0;
DLOG("opening window %d\n", cnt);
@ -66,10 +69,6 @@ Con *con_new(Con *parent, i3Window *window) {
cnt++;
if ((cnt % (sizeof(colors) / sizeof(char*))) == 0)
cnt = 0;
if (window)
x_con_init(new, window->depth);
else
x_con_init(new, XCB_COPY_FROM_PARENT);
TAILQ_INIT(&(new->floating_head));
TAILQ_INIT(&(new->nodes_head));
@ -82,6 +81,15 @@ Con *con_new(Con *parent, i3Window *window) {
return new;
}
/* A wrapper for con_new_skeleton, to retain the old con_new behaviour
*
*/
Con *con_new(Con *parent, i3Window *window) {
Con *new = con_new_skeleton(parent, window);
x_con_init(new, new->depth);
return new;
}
/*
* Attaches the given container to the given parent. This happens when moving
* a container or when inserting a new container at a specific place in the

View File

@ -354,6 +354,11 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
}
y(array_close);
if (inplace_restart && con->window != NULL) {
ystr("depth");
y(integer, con->depth);
}
y(map_close);
}

View File

@ -51,12 +51,12 @@ static int json_start_map(void *ctx) {
if (last_key && strcasecmp(last_key, "floating_nodes") == 0) {
DLOG("New floating_node\n");
Con *ws = con_get_workspace(json_node);
json_node = con_new(NULL, NULL);
json_node = con_new_skeleton(NULL, NULL);
json_node->parent = ws;
DLOG("Parent is workspace = %p\n", ws);
} else {
Con *parent = json_node;
json_node = con_new(NULL, NULL);
json_node = con_new_skeleton(NULL, NULL);
json_node->parent = parent;
}
}
@ -69,6 +69,8 @@ static int json_end_map(void *ctx) {
if (!parsing_swallows && !parsing_rect && !parsing_window_rect && !parsing_geometry) {
LOG("attaching\n");
con_attach(json_node, json_node->parent, true);
LOG("Creating window\n");
x_con_init(json_node, json_node->depth);
json_node = json_node->parent;
}
if (parsing_rect)
@ -277,6 +279,9 @@ static int json_int(void *ctx, long val) {
if (strcasecmp(last_key, "current_border_width") == 0)
json_node->current_border_width = val;
if (strcasecmp(last_key, "depth") == 0)
json_node->depth = val;
if (!parsing_swallows && strcasecmp(last_key, "id") == 0)
json_node->old_id = val;