i3 - improved tiling WM


add deco_rect property to con in ipc response

Patch status: needinfo

Patch by cornerman

To apply this patch, use:
curl http://cr.i3wm.org/patch/678/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
@@ -123,6 +124,8 @@ static int json_end_map(void *ctx) {
70
     }
71
     if (parsing_rect)
72
         parsing_rect = false;
73
+    if (parsing_deco_rect)
74
+        parsing_deco_rect = false;
75
     if (parsing_window_rect)
76
         parsing_window_rect = false;
77
     if (parsing_geometry)
78
@@ -175,6 +178,9 @@ static int json_key(void *ctx, const unsigned char *val, size_t len) {
79
     if (strcasecmp(last_key, "rect") == 0)
80
         parsing_rect = true;
81
 
82
+    if (strcasecmp(last_key, "deco_rect") == 0)
83
+        parsing_deco_rect = true;
84
+
85
     if (strcasecmp(last_key, "window_rect") == 0)
86
         parsing_window_rect = true;
87
 
88
@@ -363,10 +369,12 @@ static int json_int(void *ctx, long long val) {
89
         TAILQ_INSERT_TAIL(&focus_mappings, focus_mapping, focus_mappings);
90
     }
91
 
92
-    if (parsing_rect || parsing_window_rect || parsing_geometry) {
93
+    if (parsing_rect || parsing_deco_rect || parsing_window_rect || parsing_geometry) {
94
         Rect *r;
95
         if (parsing_rect)
96
             r = &(json_node->rect);
97
+        else if (parsing_deco_rect)
98
+            r = &(json_node->deco_rect);
99
         else if (parsing_window_rect)
100
             r = &(json_node->window_rect);
101
         else
102
@@ -532,6 +540,7 @@ void tree_append_json(Con *con, const char *filename, char **errormsg) {
103
     to_focus = NULL;
104
     parsing_swallows = false;
105
     parsing_rect = false;
106
+    parsing_deco_rect = false;
107
     parsing_window_rect = false;
108
     parsing_geometry = false;
109
     parsing_focus = false;

b/testcases/t/116-nestedcons.t

114
@@ -54,6 +54,7 @@ my $expected = {
115
     type => 'root',
116
     id => $ignore,
117
     rect => $ignore,
118
+    deco_rect => $ignore,
119
     window_rect => $ignore,
120
     geometry => $ignore,
121
     swallows => $ignore,