i3 - improved tiling WM


Fix restarting with 32bit depth windows (v2)

Patch status: superseded

Patch by Yuxuan Shui

Long description:

Fix a typo in previous patch.

To apply this patch, use:
curl http://cr.i3wm.org/patch/84/raw.patch | git am

b/include/con.h

18
@@ -12,10 +12,20 @@
19
 #ifndef I3_CON_H
20
 #define I3_CON_H
21
 
22
-/**
23
+/*
24
  * Create a new container (and attach it to the given parent, if not NULL).
25
- * This function initializes the data structures and creates the appropriate
26
- * X11 IDs using x_con_init().
27
+ * This function only initializes the data structures.
28
+ *
29
+ */
30
+Con *con_new_sketelon(Con *parent, i3Window *window);
31
+
32
+/* Create the appropriate X11 IDs for a con using x_con_init()
33
+ *
34
+ */
35
+void con_new_window(Con *con);
36
+
37
+/* A wrapper for con_new_sketelon and con_new_window,
38
+ * to retain the old con_new behaviour
39
  *
40
  */
41
 Con *con_new(Con *parent, i3Window *window);

b/include/data.h

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

b/src/con.c

60
@@ -44,11 +44,10 @@ static void con_force_split_parents_redraw(Con *con) {
61
 
62
 /*
63
  * Create a new container (and attach it to the given parent, if not NULL).
64
- * This function initializes the data structures and creates the appropriate
65
- * X11 IDs using x_con_init().
66
+ * This function only initializes the data structures.
67
  *
68
  */
69
-Con *con_new(Con *parent, i3Window *window) {
70
+Con *con_new_sketelon(Con *parent, i3Window *window) {
71
     Con *new = scalloc(sizeof(Con));
72
     new->on_remove_child = con_on_remove_child;
73
     TAILQ_INSERT_TAIL(&all_cons, new, all_cons);
74
@@ -56,6 +55,10 @@ Con *con_new(Con *parent, i3Window *window) {
75
     new->window = window;
76
     new->border_style = config.default_border;
77
     new->current_border_width = -1;
78
+    if (window)
79
+        new->depth = window->depth;
80
+    else
81
+        new->depth = XCB_COPY_FROM_PARENT;
82
     static int cnt = 0;
83
     DLOG("opening window %d\n", cnt);
84
 
85
@@ -66,10 +69,6 @@ Con *con_new(Con *parent, i3Window *window) {
86
     cnt++;
87
     if ((cnt % (sizeof(colors) / sizeof(char*))) == 0)
88
         cnt = 0;
89
-    if (window)
90
-        x_con_init(new, window->depth);
91
-    else
92
-        x_con_init(new, XCB_COPY_FROM_PARENT);
93
 
94
     TAILQ_INIT(&(new->floating_head));
95
     TAILQ_INIT(&(new->nodes_head));
96
@@ -82,6 +81,15 @@ Con *con_new(Con *parent, i3Window *window) {
97
     return new;
98
 }
99
 
100
+/* A wrapper for con_new_sketelon, to retain the old con_new behaviour
101
+ *
102
+ */
103
+Con *con_new(Con *parent, i3Window *window) {
104
+    Con *new = con_new_sketelon(parent, window);
105
+    x_con_init(new, new->depth);
106
+    return new;
107
+}
108
+
109
 /*
110
  * Attaches the given container to the given parent. This happens when moving
111
  * a container or when inserting a new container at a specific place in the

b/src/ipc.c

116
@@ -354,6 +354,11 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
117
     }
118
     y(array_close);
119
 
120
+    if (inplace_restart && con->window != NULL) {
121
+        ystr("depth");
122
+        y(integer, con->depth);
123
+    }
124
+
125
     y(map_close);
126
 }
127
 

b/src/load_layout.c

132
@@ -51,12 +51,12 @@ static int json_start_map(void *ctx) {
133
             if (last_key && strcasecmp(last_key, "floating_nodes") == 0) {
134
                 DLOG("New floating_node\n");
135
                 Con *ws = con_get_workspace(json_node);
136
-                json_node = con_new(NULL, NULL);
137
+                json_node = con_new_sketelon(NULL, NULL);
138
                 json_node->parent = ws;
139
                 DLOG("Parent is workspace = %p\n", ws);
140
             } else {
141
                 Con *parent = json_node;
142
-                json_node = con_new(NULL, NULL);
143
+                json_node = con_new_sketelon(NULL, NULL);
144
                 json_node->parent = parent;
145
             }
146
         }
147
@@ -69,6 +69,8 @@ static int json_end_map(void *ctx) {
148
     if (!parsing_swallows && !parsing_rect && !parsing_window_rect && !parsing_geometry) {
149
         LOG("attaching\n");
150
         con_attach(json_node, json_node->parent, true);
151
+        LOG("Creating window\n");
152
+        x_con_init(json_node, json_node->depth);
153
         json_node = json_node->parent;
154
     }
155
     if (parsing_rect)
156
@@ -277,6 +279,9 @@ static int json_int(void *ctx, long val) {
157
     if (strcasecmp(last_key, "current_border_width") == 0)
158
         json_node->current_border_width = val;
159
 
160
+    if (strcasecmp(last_key, "depth") == 0)
161
+        json_node->depth = val;
162
+
163
     if (!parsing_swallows && strcasecmp(last_key, "id") == 0)
164
         json_node->old_id = val;
165