]> git.sur5r.net Git - i3/i3/commitdiff
Fix the text alignment in the workspace indicator.
authorFernando Tarlá Cardoso Lemos <fernandotcl@gmail.com>
Sun, 29 Jan 2012 22:07:19 +0000 (20:07 -0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 29 Jan 2012 23:08:58 +0000 (23:08 +0000)
We now use 5px padding for the workspace text on both sides. Some
fonts will look off-by-one (e.g. fixed), but that's because X core
fonts have padding. This padding is per-char, varies wildly across
different fonts, and would be a major pain to offset for. Even if
we could take this padding into account, this would probably make
things look even worse for some fonts.

i3bar/src/xcb.c

index a3631c8a8840417773c8f33f42b1b857378ac7b7..978288e1aeb441d254c5d3d08ef3d3f26a4a7c7f 100644 (file)
@@ -267,10 +267,10 @@ void handle_button(xcb_button_press_event_t *event) {
              * and set cur_ws accordingly */
             TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) {
                 DLOG("x = %d\n", x);
-                if (x >= 1 && x <= cur_ws->name_width + 9) {
+                if (x >= 0 && x < cur_ws->name_width + 10) {
                     break;
                 }
-                x -= cur_ws->name_width + 10;
+                x -= cur_ws->name_width + 11;
             }
             if (cur_ws == NULL) {
                 return;
@@ -1408,7 +1408,7 @@ void draw_bars() {
                           outputs_walk->bargc,
                           mask,
                           vals_border);
-            xcb_rectangle_t rect_border = { i + 1, 0, ws_walk->name_width + 9, font.height + 4 };
+            xcb_rectangle_t rect_border = { i, 0, ws_walk->name_width + 10, font.height + 4 };
             xcb_poly_fill_rectangle(xcb_connection,
                                     outputs_walk->buffer,
                                     outputs_walk->bargc,
@@ -1419,7 +1419,7 @@ void draw_bars() {
                           outputs_walk->bargc,
                           mask,
                           vals);
-            xcb_rectangle_t rect = { i + 2, 1, ws_walk->name_width + 7, font.height + 2 };
+            xcb_rectangle_t rect = { i + 1, 1, ws_walk->name_width + 8, font.height + 2 };
             xcb_poly_fill_rectangle(xcb_connection,
                                     outputs_walk->buffer,
                                     outputs_walk->bargc,
@@ -1427,8 +1427,8 @@ void draw_bars() {
                                     &rect);
             set_font_colors(outputs_walk->bargc, fg_color, bg_color);
             draw_text((char*)ws_walk->ucs2_name, ws_walk->name_glyphs, true,
-                    outputs_walk->buffer, outputs_walk->bargc, i + 6, 2, ws_walk->name_width);
-            i += 10 + ws_walk->name_width;
+                    outputs_walk->buffer, outputs_walk->bargc, i + 5, 2, ws_walk->name_width);
+            i += 10 + ws_walk->name_width + 1;
         }
 
         i = 0;