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/38/raw.patch | git am

b/include/render.h

16
@@ -21,4 +21,9 @@
17
  */
18
 void render_con(Con *con, bool render_fullscreen);
19
 
20
+/*
21
+ * Returns the height for the decorations
22
+ */
23
+int render_deco_height();
24
+
25
 #endif

b/src/con.c

30
@@ -1181,7 +1181,7 @@ void con_set_border_style(Con *con, int border_style, int border_width) {
31
     con->current_border_width = border_width;
32
     bsr = con_border_style_rect(con);
33
     int deco_height =
34
-        (con->border_style == BS_NORMAL ? config.font.height + 5 : 0);
35
+        (con->border_style == BS_NORMAL ? render_deco_height() : 0);
36
 
37
     con->rect.x -= bsr.x;
38
     con->rect.y -= bsr.y;

b/src/floating.c

43
@@ -165,7 +165,7 @@ void floating_enable(Con *con, bool automatic) {
44
     free(name);
45
 
46
     /* find the height for the decorations */
47
-    int deco_height = config.font.height + 5;
48
+    int deco_height = render_deco_height();
49
 
50
     DLOG("Original rect: (%d, %d) with %d x %d\n", con->rect.x, con->rect.y, con->rect.width, con->rect.height);
51
     DLOG("Geometry = (%d, %d) with %d x %d\n", con->geometry.x, con->geometry.y, con->geometry.width, con->geometry.height);
52
@@ -251,7 +251,7 @@ void floating_enable(Con *con, bool automatic) {
53
     /* 5: Subtract the deco_height in order to make the floating window appear
54
      * at precisely the position it specified in its original geometry (which
55
      * is what applications might remember). */
56
-    deco_height = (con->border_style == BS_NORMAL ? config.font.height + 5 : 0);
57
+    deco_height = (con->border_style == BS_NORMAL ? render_deco_height() : 0);
58
     nc->rect.y -= deco_height;
59
 
60
     DLOG("Corrected y = %d (deco_height = %d)\n", nc->rect.y, deco_height);

b/src/render.c

65
@@ -17,6 +17,16 @@
66
 static bool show_debug_borders = false;
67
 
68
 /*
69
+ * Returns the height for the decorations
70
+ */
71
+int render_deco_height() {
72
+    int deco_height = config.font.height + 4;
73
+    if (config.font.height & 0x01)
74
+        ++deco_height;
75
+    return deco_height;
76
+}
77
+
78
+/*
79
  * Renders a container with layout L_OUTPUT. In this layout, all CT_DOCKAREAs
80
  * get the height of their content and the remaining CT_CON gets the rest.
81
  *
82
@@ -203,9 +213,7 @@ void render_con(Con *con, bool render_fullscreen) {
83
     }
84
 
85
     /* find the height for the decorations */
86
-    int deco_height = config.font.height + 4;
87
-    if (config.font.height & 0x01)
88
-        ++deco_height;
89
+    int deco_height = render_deco_height();
90
 
91
     /* precalculate the sizes to be able to correct rounding errors */
92
     int sizes[children];