i3 - improved tiling WM


add deco_rect property to con in ipc response

Patch status: merged

Patch by cornerman

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

b/docs/ipc

16
@@ -316,6 +316,10 @@ window_rect (map)::
17
 	So, when using the +default+ layout, you will have a 2 pixel border on
18
 	each side, making the window_rect +{ "x": 2, "y": 0, "width": 632,
19
 	"height": 366 }+ (for example).
20
+deco_rect (map)::
21
+	The coordinates of the *window decoration* inside its container. These
22
+	coordinates are relative to the container and do not include the actual
23
+	client window.
24
 geometry (map)::
25
 	The original geometry the window specified when i3 mapped it. Used when
26
 	switching a window to floating mode, for example.

b/src/ipc.c

31
@@ -347,6 +347,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
32
     y(integer, con->current_border_width);
33
 
34
     dump_rect(gen, "rect", con->rect);
35
+    dump_rect(gen, "deco_rect", con->deco_rect);
36
     dump_rect(gen, "window_rect", con->window_rect);
37
     dump_rect(gen, "geometry", con->geometry);
38
 

b/src/load_layout.c

43
@@ -24,6 +24,7 @@ static Con *json_node;
44
 static Con *to_focus;
45
 static bool parsing_swallows;
46
 static bool parsing_rect;
47
+static bool parsing_deco_rect;
48
 static bool parsing_window_rect;
49
 static bool parsing_geometry;
50
 static bool parsing_focus;
51
@@ -47,7 +48,7 @@ static int json_start_map(void *ctx) {
52
         match_init(current_swallow);
53
         TAILQ_INSERT_TAIL(&(json_node->swallow_head), current_swallow, matches);
54
     } else {
55
-        if (!parsing_rect && !parsing_window_rect && !parsing_geometry) {
56
+        if (!parsing_rect && !parsing_deco_rect && !parsing_window_rect && !parsing_geometry) {
57
             if (last_key && strcasecmp(last_key, "floating_nodes") == 0) {
58
                 DLOG("New floating_node\n");
59
                 Con *ws = con_get_workspace(json_node);
60
@@ -68,7 +69,7 @@ static int json_start_map(void *ctx) {
61
 
62
 static int json_end_map(void *ctx) {
63
     LOG("end of map\n");
64
-    if (!parsing_swallows && !parsing_rect && !parsing_window_rect && !parsing_geometry) {
65
+    if (!parsing_swallows && !parsing_rect && !parsing_deco_rect && !parsing_window_rect && !parsing_geometry) {
66
         /* Set a few default values to simplify manually crafted layout files. */
67
         if (json_node->layout == L_DEFAULT) {
68
             DLOG("Setting layout = L_SPLITH\n");
69
@@ -121,12 +122,11 @@ static int json_end_map(void *ctx) {
70
         x_con_init(json_node, json_node->depth);
71
         json_node = json_node->parent;
72
     }
73
-    if (parsing_rect)
74
-        parsing_rect = false;
75
-    if (parsing_window_rect)
76
-        parsing_window_rect = false;
77
-    if (parsing_geometry)
78
-        parsing_geometry = false;
79
+
80
+    parsing_rect = false;
81
+    parsing_deco_rect = false;
82
+    parsing_window_rect = false;
83
+    parsing_geometry = false;
84
     return 1;
85
 }
86
 
87
@@ -175,6 +175,9 @@ static int json_key(void *ctx, const unsigned char *val, size_t len) {
88
     if (strcasecmp(last_key, "rect") == 0)
89
         parsing_rect = true;
90
 
91
+    if (strcasecmp(last_key, "deco_rect") == 0)
92
+        parsing_deco_rect = true;
93
+
94
     if (strcasecmp(last_key, "window_rect") == 0)
95
         parsing_window_rect = true;
96
 
97
@@ -532,6 +535,7 @@ void tree_append_json(Con *con, const char *filename, char **errormsg) {
98
     to_focus = NULL;
99
     parsing_swallows = false;
100
     parsing_rect = false;
101
+    parsing_deco_rect = false;
102
     parsing_window_rect = false;
103
     parsing_geometry = false;
104
     parsing_focus = false;

b/testcases/t/116-nestedcons.t

109
@@ -54,6 +54,7 @@ my $expected = {
110
     type => 'root',
111
     id => $ignore,
112
     rect => $ignore,
113
+    deco_rect => $ignore,
114
     window_rect => $ignore,
115
     geometry => $ignore,
116
     swallows => $ignore,