diff options
Diffstat (limited to 'swaybar/render.c')
-rw-r--r-- | swaybar/render.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/swaybar/render.c b/swaybar/render.c index a296112a..1113ca44 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -693,15 +693,6 @@ static uint32_t render_to_cairo(struct render_context *ctx) { | |||
693 | struct swaybar_output *output = ctx->output; | 693 | struct swaybar_output *output = ctx->output; |
694 | struct swaybar *bar = output->bar; | 694 | struct swaybar *bar = output->bar; |
695 | struct swaybar_config *config = bar->config; | 695 | struct swaybar_config *config = bar->config; |
696 | cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); | ||
697 | if (output->focused) { | ||
698 | ctx->background_color = config->colors.focused_background; | ||
699 | } else { | ||
700 | ctx->background_color = config->colors.background; | ||
701 | } | ||
702 | |||
703 | cairo_set_source_u32(cairo, ctx->background_color); | ||
704 | cairo_paint(cairo); | ||
705 | 696 | ||
706 | int th; | 697 | int th; |
707 | get_text_size(cairo, config->font_description, NULL, &th, NULL, 1, false, ""); | 698 | get_text_size(cairo, config->font_description, NULL, &th, NULL, 1, false, ""); |
@@ -763,8 +754,17 @@ void render_frame(struct swaybar_output *output) { | |||
763 | 754 | ||
764 | free_hotspots(&output->hotspots); | 755 | free_hotspots(&output->hotspots); |
765 | 756 | ||
757 | uint32_t background_color; | ||
758 | if (output->focused) { | ||
759 | background_color = output->bar->config->colors.focused_background; | ||
760 | } else { | ||
761 | background_color = output->bar->config->colors.background; | ||
762 | } | ||
763 | |||
766 | struct render_context ctx = { 0 }; | 764 | struct render_context ctx = { 0 }; |
767 | ctx.output = output; | 765 | ctx.output = output; |
766 | // initial background color used for deciding the best way to antialias text | ||
767 | ctx.background_color = background_color; | ||
768 | 768 | ||
769 | cairo_surface_t *recorder = cairo_recording_surface_create( | 769 | cairo_surface_t *recorder = cairo_recording_surface_create( |
770 | CAIRO_CONTENT_COLOR_ALPHA, NULL); | 770 | CAIRO_CONTENT_COLOR_ALPHA, NULL); |
@@ -786,10 +786,11 @@ void render_frame(struct swaybar_output *output) { | |||
786 | ctx.textaa_sharp = fo; | 786 | ctx.textaa_sharp = fo; |
787 | } | 787 | } |
788 | 788 | ||
789 | cairo_save(cairo); | 789 | |
790 | cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR); | 790 | cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); |
791 | cairo_set_source_u32(cairo, background_color); | ||
791 | cairo_paint(cairo); | 792 | cairo_paint(cairo); |
792 | cairo_restore(cairo); | 793 | |
793 | uint32_t height = render_to_cairo(&ctx); | 794 | uint32_t height = render_to_cairo(&ctx); |
794 | int config_height = output->bar->config->height; | 795 | int config_height = output->bar->config->height; |
795 | if (config_height > 0) { | 796 | if (config_height > 0) { |
@@ -834,7 +835,7 @@ void render_frame(struct swaybar_output *output) { | |||
834 | wl_surface_damage(output->surface, 0, 0, | 835 | wl_surface_damage(output->surface, 0, 0, |
835 | output->width, output->height); | 836 | output->width, output->height); |
836 | 837 | ||
837 | uint32_t bg_alpha = ctx.background_color & 0xFF; | 838 | uint32_t bg_alpha = background_color & 0xFF; |
838 | if (bg_alpha == 0xFF) { | 839 | if (bg_alpha == 0xFF) { |
839 | struct wl_region *region = | 840 | struct wl_region *region = |
840 | wl_compositor_create_region(output->bar->compositor); | 841 | wl_compositor_create_region(output->bar->compositor); |