i3 - improved tiling WM


i3-nagbar: Set close button inner-width to label width

Patch status: needinfo

Patch by Tony Crisci

Long description:

Use predict_text_width to find the width of the close button label and
then account for right padding when calculating the width of the
button.

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

b/i3-nagbar/main.c

16
@@ -198,8 +198,9 @@ static int handle_expose(xcb_connection_t *conn, xcb_expose_event_t *event) {
17
             4 + 4, 4 + 4, rect.width - 4 - 4);
18
 
19
     /* render close button */
20
+    char *close_button_label = "X";
21
     int line_width = 4;
22
-    int w = 20;
23
+    int w = predict_text_width(i3string_from_utf8(close_button_label)) + 8;
24
     int y = rect.width;
25
     uint32_t values[3];
26
     values[0] = color_button_background;
27
@@ -221,7 +222,7 @@ static int handle_expose(xcb_connection_t *conn, xcb_expose_event_t *event) {
28
 
29
     values[0] = 1;
30
     set_font_colors(pixmap_gc, color_text, color_button_background);
31
-    draw_text_ascii("X", pixmap, pixmap_gc, y - w - line_width + w / 2 - 4,
32
+    draw_text_ascii(close_button_label, pixmap, pixmap_gc, y - w - line_width + w / 2 - 4,
33
             4 + 4 - 1, rect.width - y + w + line_width - w / 2 + 4);
34
     y -= w;
35