i3bar: Respect the urgency flag on status blocks by drawing urgent blocks with the same settings as an urgent workspace.
Patch status: merged
Patch by Ingo Bürk
To apply this patch, use:
curl http://cr.i3wm.org/patch/682/raw.patch | git am
b/i3bar/src/xcb.c
14 |
@@ -156,7 +156,7 @@ void refresh_statusline(void) { |
15 |
|
16 |
/* If this is not the last block, add some pixels for a separator. */ |
17 |
if (TAILQ_NEXT(block, blocks) != NULL) |
18 |
- block->width += block->sep_block_width; |
19 |
+ statusline_width += block->sep_block_width; |
20 |
|
21 |
statusline_width += block->width + block->x_offset + block->x_append; |
22 |
} |
23 |
@@ -168,7 +168,7 @@ void refresh_statusline(void) { |
24 |
realloc_sl_buffer(); |
25 |
|
26 |
/* Clear the statusline pixmap. */ |
27 |
- xcb_rectangle_t rect = {0, 0, root_screen->width_in_pixels, font.height + logical_px(5)}; |
28 |
+ xcb_rectangle_t rect = {0, 0, root_screen->width_in_pixels, bar_height}; |
29 |
xcb_poly_fill_rectangle(xcb_connection, statusline_pm, statusline_clear, 1, &rect); |
30 |
|
31 |
/* Draw the text of each block. */ |
32 |
@@ -176,11 +176,39 @@ void refresh_statusline(void) { |
33 |
TAILQ_FOREACH(block, &statusline_head, blocks) { |
34 |
if (i3string_get_num_bytes(block->full_text) == 0) |
35 |
continue; |
36 |
+ uint32_t fg_color; |
37 |
|
38 |
- uint32_t colorpixel = (block->color ? get_colorpixel(block->color) : colors.bar_fg); |
39 |
- set_font_colors(statusline_ctx, colorpixel, colors.bar_bg); |
40 |
- draw_text(block->full_text, statusline_pm, statusline_ctx, x + block->x_offset, 1, block->width); |
41 |
- x += block->width + block->x_offset + block->x_append; |
42 |
+ /* If this block is urgent, draw it with the defined color and border. */ |
43 |
+ if (block->urgent) { |
44 |
+ fg_color = colors.urgent_ws_fg; |
45 |
+ |
46 |
+ uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND; |
47 |
+ |
48 |
+ /* Draw the border. */ |
49 |
+ uint32_t border_color = colors.urgent_ws_border; |
50 |
+ uint32_t border_values[] = { border_color, border_color }; |
51 |
+ xcb_change_gc(xcb_connection, statusline_ctx, mask, border_values); |
52 |
+ |
53 |
+ xcb_rectangle_t border_rect = { x, 0, |
54 |
+ block->width + block->x_offset + block->x_append, bar_height }; |
55 |
+ xcb_poly_fill_rectangle(xcb_connection, statusline_pm, statusline_ctx, 1, &border_rect); |
56 |
+ |
57 |
+ /* Draw the background */ |
58 |
+ uint32_t bg_color = colors.urgent_ws_bg; |
59 |
+ uint32_t bg_values[] = { bg_color, bg_color }; |
60 |
+ xcb_change_gc(xcb_connection, statusline_ctx, mask, bg_values); |
61 |
+ |
62 |
+ xcb_rectangle_t bg_rect = { x + 1, 1, |
63 |
+ block->width + block->x_offset + block->x_append - 2, |
64 |
+ bar_height - 2 }; |
65 |
+ xcb_poly_fill_rectangle(xcb_connection, statusline_pm, statusline_ctx, 1, &bg_rect); |
66 |
+ } else { |
67 |
+ fg_color = (block->color ? get_colorpixel(block->color) : colors.bar_fg); |
68 |
+ } |
69 |
+ |
70 |
+ set_font_colors(statusline_ctx, fg_color, colors.bar_bg); |
71 |
+ draw_text(block->full_text, statusline_pm, statusline_ctx, x + block->x_offset, 3, block->width); |
72 |
+ x += block->width + block->sep_block_width + block->x_offset + block->x_append; |
73 |
|
74 |
if (TAILQ_NEXT(block, blocks) != NULL && !block->no_separator && block->sep_block_width > 0) { |
75 |
/* This is not the last block, draw a separator. */ |
76 |
@@ -190,8 +218,8 @@ void refresh_statusline(void) { |
77 |
xcb_change_gc(xcb_connection, statusline_ctx, mask, values); |
78 |
xcb_poly_line(xcb_connection, XCB_COORD_MODE_ORIGIN, statusline_pm, |
79 |
statusline_ctx, 2, |
80 |
- (xcb_point_t[]) {{x - sep_offset, 2}, |
81 |
- {x - sep_offset, font.height - 2}}); |
82 |
+ (xcb_point_t[]) { { x - sep_offset, 4 }, |
83 |
+ { x - sep_offset, bar_height - 4 } }); |
84 |
} |
85 |
} |
86 |
} |
87 |
@@ -1713,8 +1741,8 @@ void draw_bars(bool unhide) { |
88 |
outputs_walk->buffer, |
89 |
outputs_walk->bargc, |
90 |
MAX(0, (int16_t)(statusline_width - outputs_walk->rect.w + 4)), 0, |
91 |
- MAX(0, (int16_t)(outputs_walk->rect.w - statusline_width - traypx - 4)), 3, |
92 |
- MIN(outputs_walk->rect.w - traypx - 4, (int)statusline_width), font.height + 2); |
93 |
+ MAX(0, (int16_t)(outputs_walk->rect.w - statusline_width - traypx - 4)), 0, |
94 |
+ MIN(outputs_walk->rect.w - traypx - 4, (int)statusline_width), bar_height); |
95 |
} |
96 |
|
97 |
if (!config.disable_ws) { |