i3 - improved tiling WM


Draw Binding mode indicator before workspace buttons.

Patch status: rejected

Patch by syl20bnr

Long description:

This feel more natural to me since the total width for the
workspace buttons constantly changes. By drawing the indicator
first, it is alway at the same absolute position.
Moreover, on small screens, it makes sense to not have the
indicator mode overlaping the status info displayed on the
left side of the bar.

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

b/i3bar/src/xcb.c

19
@@ -1670,6 +1670,42 @@ void draw_bars(bool unhide) {
20
                           MIN(outputs_walk->rect.w - traypx - 4, statusline_width), font.height + 2);
21
         }
22
 
23
+        if (binding.name && !config.disable_binding_mode_indicator) {
24
+            uint32_t fg_color = colors.urgent_ws_fg;
25
+            uint32_t bg_color = colors.urgent_ws_bg;
26
+            uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
27
+
28
+            uint32_t vals_border[] = { colors.urgent_ws_border, colors.urgent_ws_border };
29
+            xcb_change_gc(xcb_connection,
30
+                          outputs_walk->bargc,
31
+                          mask,
32
+                          vals_border);
33
+            xcb_rectangle_t rect_border = { i, 1, binding.width + 10, font.height + 4 };
34
+            xcb_poly_fill_rectangle(xcb_connection,
35
+                                    outputs_walk->buffer,
36
+                                    outputs_walk->bargc,
37
+                                    1,
38
+                                    &rect_border);
39
+
40
+            uint32_t vals[] = { bg_color, bg_color };
41
+            xcb_change_gc(xcb_connection,
42
+                          outputs_walk->bargc,
43
+                          mask,
44
+                          vals);
45
+            xcb_rectangle_t rect = { i + 1, 2, binding.width + 8, font.height + 2 };
46
+            xcb_poly_fill_rectangle(xcb_connection,
47
+                                    outputs_walk->buffer,
48
+                                    outputs_walk->bargc,
49
+                                    1,
50
+                                    &rect);
51
+
52
+            set_font_colors(outputs_walk->bargc, fg_color, bg_color);
53
+            draw_text(binding.name, outputs_walk->buffer, outputs_walk->bargc, i + 5, 3, binding.width);
54
+
55
+            unhide = true;
56
+            i += 1 + binding.width + 10;
57
+        }
58
+
59
         if (!config.disable_ws) {
60
             i3_ws *ws_walk;
61
             TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
62
@@ -1734,41 +1770,6 @@ void draw_bars(bool unhide) {
63
             }
64
         }
65
 
66
-        if (binding.name && !config.disable_binding_mode_indicator) {
67
-            uint32_t fg_color = colors.urgent_ws_fg;
68
-            uint32_t bg_color = colors.urgent_ws_bg;
69
-            uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
70
-
71
-            uint32_t vals_border[] = { colors.urgent_ws_border, colors.urgent_ws_border };
72
-            xcb_change_gc(xcb_connection,
73
-                          outputs_walk->bargc,
74
-                          mask,
75
-                          vals_border);
76
-            xcb_rectangle_t rect_border = { i, 1, binding.width + 10, font.height + 4 };
77
-            xcb_poly_fill_rectangle(xcb_connection,
78
-                                    outputs_walk->buffer,
79
-                                    outputs_walk->bargc,
80
-                                    1,
81
-                                    &rect_border);
82
-
83
-            uint32_t vals[] = { bg_color, bg_color };
84
-            xcb_change_gc(xcb_connection,
85
-                          outputs_walk->bargc,
86
-                          mask,
87
-                          vals);
88
-            xcb_rectangle_t rect = { i + 1, 2, binding.width + 8, font.height + 2 };
89
-            xcb_poly_fill_rectangle(xcb_connection,
90
-                                    outputs_walk->buffer,
91
-                                    outputs_walk->bargc,
92
-                                    1,
93
-                                    &rect);
94
-
95
-            set_font_colors(outputs_walk->bargc, fg_color, bg_color);
96
-            draw_text(binding.name, outputs_walk->buffer, outputs_walk->bargc, i + 5, 3, binding.width);
97
-
98
-            unhide = true;
99
-        }
100
-
101
         i = 0;
102
     }
103