i3 - improved tiling WM


Add render_deco_height()

Patch status: rejected

Patch by oblique

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

b/src/con.c

15
@@ -1181,7 +1181,7 @@ void con_set_border_style(Con *con, int border_style, int border_width) {
16
     con->current_border_width = border_width;
17
     bsr = con_border_style_rect(con);
18
     int deco_height =
19
-        (con->border_style == BS_NORMAL ? config.font.height + 5 : 0);
20
+        (con->border_style == BS_NORMAL ? render_deco_height() : 0);
21
 
22
     con->rect.x -= bsr.x;
23
     con->rect.y -= bsr.y;

b/src/floating.c

28
@@ -165,7 +165,7 @@ void floating_enable(Con *con, bool automatic) {
29
     free(name);
30
 
31
     /* find the height for the decorations */
32
-    int deco_height = config.font.height + 5;
33
+    int deco_height = render_deco_height();
34
 
35
     DLOG("Original rect: (%d, %d) with %d x %d\n", con->rect.x, con->rect.y, con->rect.width, con->rect.height);
36
     DLOG("Geometry = (%d, %d) with %d x %d\n", con->geometry.x, con->geometry.y, con->geometry.width, con->geometry.height);
37
@@ -251,7 +251,7 @@ void floating_enable(Con *con, bool automatic) {
38
     /* 5: Subtract the deco_height in order to make the floating window appear
39
      * at precisely the position it specified in its original geometry (which
40
      * is what applications might remember). */
41
-    deco_height = (con->border_style == BS_NORMAL ? config.font.height + 5 : 0);
42
+    deco_height = (con->border_style == BS_NORMAL ? render_deco_height() : 0);
43
     nc->rect.y -= deco_height;
44
 
45
     DLOG("Corrected y = %d (deco_height = %d)\n", nc->rect.y, deco_height);

b/src/render.c

50
@@ -17,6 +17,16 @@
51
 static bool show_debug_borders = false;
52
 
53
 /*
54
+ * Returns the height for the decorations
55
+ */
56
+int render_deco_height() {
57
+    int deco_height = config.font.height + 4;
58
+    if (config.font.height & 0x01)
59
+        ++deco_height;
60
+    return deco_height;
61
+}
62
+
63
+/*
64
  * Renders a container with layout L_OUTPUT. In this layout, all CT_DOCKAREAs
65
  * get the height of their content and the remaining CT_CON gets the rest.
66
  *
67
@@ -203,9 +213,7 @@ void render_con(Con *con, bool render_fullscreen) {
68
     }
69
 
70
     /* find the height for the decorations */
71
-    int deco_height = config.font.height + 4;
72
-    if (config.font.height & 0x01)
73
-        ++deco_height;
74
+    int deco_height = render_deco_height();
75
 
76
     /* precalculate the sizes to be able to correct rounding errors */
77
     int sizes[children];