i3 - improved tiling WM


Create pixmaps using the real bar height, rather than screen height.

Patch status: merged

Patch by Deiz

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

b/i3bar/src/xcb.c

14
@@ -59,6 +59,9 @@ xcb_connection_t *conn;
15
 /* The font we'll use */
16
 static i3Font font;
17
 
18
+/* Overall height of the bar (based on font size) */
19
+int bar_height;
20
+
21
 /* These are only relevant for XKB, which we only need for grabbing modifiers */
22
 Display          *xkb_dpy;
23
 int              xkb_event_base;
24
@@ -240,9 +243,9 @@ void unhide_bars(void) {
25
         values[0] = walk->rect.x;
26
         if (config.position == POS_TOP)
27
             values[1] = walk->rect.y;
28
-        else values[1] = walk->rect.y + walk->rect.h - font.height - 6;
29
+        else values[1] = walk->rect.y + walk->rect.h - bar_height;
30
         values[2] = walk->rect.w;
31
-        values[3] = font.height + 6;
32
+        values[3] = bar_height;
33
         values[4] = XCB_STACK_MODE_ABOVE;
34
         DLOG("Reconfiguring Window for output %s to %d,%d\n", walk->name, values[0], values[1]);
35
         cookie = xcb_configure_window_checked(xcb_connection,
36
@@ -1061,6 +1064,7 @@ void init_xcb_late(char *fontname) {
37
     font = load_font(fontname, true);
38
     set_font(&font);
39
     DLOG("Calculated Font-height: %d\n", font.height);
40
+    bar_height = font.height + 6;
41
 
42
     xcb_flush(xcb_connection);
43
 
44
@@ -1334,7 +1338,7 @@ void realloc_sl_buffer(void) {
45
                                                                statusline_pm,
46
                                                                xcb_root,
47
                                                                MAX(root_screen->width_in_pixels, statusline_width),
48
-                                                               root_screen->height_in_pixels);
49
+                                                               bar_height);
50
 
51
     uint32_t mask = XCB_GC_FOREGROUND;
52
     uint32_t vals[2] = { colors.bar_bg, colors.bar_bg };
53
@@ -1407,8 +1411,8 @@ void reconfig_windows(bool redraw_bars) {
54
                                                                      root_screen->root_depth,
55
                                                                      walk->bar,
56
                                                                      xcb_root,
57
-                                                                     walk->rect.x, walk->rect.y + walk->rect.h - font.height - 6,
58
-                                                                     walk->rect.w, font.height + 6,
59
+                                                                     walk->rect.x, walk->rect.y + walk->rect.h - bar_height,
60
+                                                                     walk->rect.w, bar_height,
61
                                                                      0,
62
                                                                      XCB_WINDOW_CLASS_INPUT_OUTPUT,
63
                                                                      root_screen->root_visual,
64
@@ -1421,7 +1425,7 @@ void reconfig_windows(bool redraw_bars) {
65
                                                                     walk->buffer,
66
                                                                     walk->bar,
67
                                                                     walk->rect.w,
68
-                                                                    walk->rect.h);
69
+                                                                    bar_height);
70
 
71
             /* Set the WM_CLASS and WM_NAME (we don't need UTF-8) atoms */
72
             xcb_void_cookie_t class_cookie;
73
@@ -1482,12 +1486,12 @@ void reconfig_windows(bool redraw_bars) {
74
                 case POS_NONE:
75
                     break;
76
                 case POS_TOP:
77
-                    strut_partial.top = font.height + 6;
78
+                    strut_partial.top = bar_height;
79
                     strut_partial.top_start_x = walk->rect.x;
80
                     strut_partial.top_end_x = walk->rect.x + walk->rect.w;
81
                     break;
82
                 case POS_BOT:
83
-                    strut_partial.bottom = font.height + 6;
84
+                    strut_partial.bottom = bar_height;
85
                     strut_partial.bottom_start_x = walk->rect.x;
86
                     strut_partial.bottom_end_x = walk->rect.x + walk->rect.w;
87
                     break;
88
@@ -1541,9 +1545,9 @@ void reconfig_windows(bool redraw_bars) {
89
                    XCB_CONFIG_WINDOW_HEIGHT |
90
                    XCB_CONFIG_WINDOW_STACK_MODE;
91
             values[0] = walk->rect.x;
92
-            values[1] = walk->rect.y + walk->rect.h - font.height - 6;
93
+            values[1] = walk->rect.y + walk->rect.h - bar_height;
94
             values[2] = walk->rect.w;
95
-            values[3] = font.height + 6;
96
+            values[3] = bar_height;
97
             values[4] = XCB_STACK_MODE_ABOVE;
98
 
99
             DLOG("Destroying buffer for output %s\n", walk->name);
100
@@ -1569,7 +1573,7 @@ void reconfig_windows(bool redraw_bars) {
101
                                                                     walk->buffer,
102
                                                                     walk->bar,
103
                                                                     walk->rect.w,
104
-                                                                    walk->rect.h);
105
+                                                                    bar_height);
106
 
107
             xcb_void_cookie_t map_cookie, umap_cookie;
108
             if (redraw_bars) {
109
@@ -1631,7 +1635,7 @@ void draw_bars(bool unhide) {
110
                       outputs_walk->bargc,
111
                       XCB_GC_FOREGROUND,
112
                       &color);
113
-        xcb_rectangle_t rect = { 0, 0, outputs_walk->rect.w, font.height + 6 };
114
+        xcb_rectangle_t rect = { 0, 0, outputs_walk->rect.w, bar_height };
115
         xcb_poly_fill_rectangle(xcb_connection,
116
                                 outputs_walk->buffer,
117
                                 outputs_walk->bargc,