diff options
Diffstat (limited to 'swaybar/render.c')
-rw-r--r-- | swaybar/render.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/swaybar/render.c b/swaybar/render.c index a9f1991d..2eae997f 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -49,7 +49,7 @@ static void render_sharp_line(cairo_t *cairo, uint32_t color, double x, double y | |||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | static void render_block(struct window *window, struct config *config, struct status_block *block, double *x, bool edge) { | 52 | static void render_block(struct window *window, struct config *config, struct status_block *block, double *x, bool edge, bool is_focused) { |
53 | int width, height, sep_width; | 53 | int width, height, sep_width; |
54 | get_text_size(window->cairo, window->font, &width, &height, | 54 | get_text_size(window->cairo, window->font, &width, &height, |
55 | window->scale, block->markup, "%s", block->full_text); | 55 | window->scale, block->markup, "%s", block->full_text); |
@@ -159,7 +159,11 @@ static void render_block(struct window *window, struct config *config, struct st | |||
159 | 159 | ||
160 | // render separator | 160 | // render separator |
161 | if (!edge && block->separator) { | 161 | if (!edge && block->separator) { |
162 | cairo_set_source_u32(window->cairo, config->colors.separator); | 162 | if (is_focused) { |
163 | cairo_set_source_u32(window->cairo, config->colors.focused_separator); | ||
164 | } else { | ||
165 | cairo_set_source_u32(window->cairo, config->colors.separator); | ||
166 | } | ||
163 | if (config->sep_symbol) { | 167 | if (config->sep_symbol) { |
164 | offset = pos + (block->separator_block_width - sep_width) / 2; | 168 | offset = pos + (block->separator_block_width - sep_width) / 2; |
165 | cairo_move_to(window->cairo, offset, margin); | 169 | cairo_move_to(window->cairo, offset, margin); |
@@ -275,6 +279,7 @@ void render(struct output *output, struct config *config, struct status_line *li | |||
275 | 279 | ||
276 | struct window *window = output->window; | 280 | struct window *window = output->window; |
277 | cairo_t *cairo = window->cairo; | 281 | cairo_t *cairo = window->cairo; |
282 | bool is_focused = output->focused; | ||
278 | 283 | ||
279 | // Clear | 284 | // Clear |
280 | cairo_save(cairo); | 285 | cairo_save(cairo); |
@@ -285,11 +290,20 @@ void render(struct output *output, struct config *config, struct status_line *li | |||
285 | cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); | 290 | cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); |
286 | 291 | ||
287 | // Background | 292 | // Background |
288 | cairo_set_source_u32(cairo, config->colors.background); | 293 | if (is_focused) { |
294 | cairo_set_source_u32(cairo, config->colors.focused_background); | ||
295 | } else { | ||
296 | cairo_set_source_u32(cairo, config->colors.background); | ||
297 | } | ||
289 | cairo_paint(cairo); | 298 | cairo_paint(cairo); |
290 | 299 | ||
291 | // Command output | 300 | // Command output |
292 | cairo_set_source_u32(cairo, config->colors.statusline); | 301 | if (is_focused) { |
302 | cairo_set_source_u32(cairo, config->colors.focused_statusline); | ||
303 | } else { | ||
304 | cairo_set_source_u32(cairo, config->colors.statusline); | ||
305 | } | ||
306 | |||
293 | int width, height; | 307 | int width, height; |
294 | 308 | ||
295 | if (line->protocol == TEXT) { | 309 | if (line->protocol == TEXT) { |
@@ -305,7 +319,7 @@ void render(struct output *output, struct config *config, struct status_line *li | |||
305 | for (i = line->block_line->length - 1; i >= 0; --i) { | 319 | for (i = line->block_line->length - 1; i >= 0; --i) { |
306 | struct status_block *block = line->block_line->items[i]; | 320 | struct status_block *block = line->block_line->items[i]; |
307 | if (block->full_text && block->full_text[0]) { | 321 | if (block->full_text && block->full_text[0]) { |
308 | render_block(window, config, block, &pos, edge); | 322 | render_block(window, config, block, &pos, edge, is_focused); |
309 | edge = false; | 323 | edge = false; |
310 | } | 324 | } |
311 | } | 325 | } |