@@ -29,6 +29,7 @@ struct render_context {
29
29
cairo_font_options_t * textaa_sharp ;
30
30
cairo_font_options_t * textaa_safe ;
31
31
uint32_t background_color ;
32
+ bool has_transparency ;
32
33
};
33
34
34
35
static void choose_text_aa_mode (struct render_context * ctx , uint32_t fontcolor ) {
@@ -265,6 +266,7 @@ static uint32_t render_status_block(struct render_context *ctx,
265
266
266
267
uint32_t bg_color = block -> urgent
267
268
? config -> colors .urgent_workspace .background : block -> background ;
269
+ ctx -> has_transparency |= (bg_color & 0xFF ) != 0xFF ;
268
270
if (bg_color ) {
269
271
render_sharp_rectangle (cairo , bg_color , x_pos , y_pos ,
270
272
block_width , render_height );
@@ -574,6 +576,7 @@ static uint32_t render_binding_mode_indicator(struct render_context *ctx,
574
576
cairo_set_operator (cairo , CAIRO_OPERATOR_SOURCE );
575
577
cairo_set_source_u32 (cairo , config -> colors .binding_mode .background );
576
578
ctx -> background_color = config -> colors .binding_mode .background ;
579
+ ctx -> has_transparency |= (config -> colors .binding_mode .background & 0xFF ) != 0xFF ;
577
580
cairo_rectangle (cairo , x , 0 , width , height );
578
581
cairo_fill (cairo );
579
582
@@ -653,6 +656,7 @@ static uint32_t render_workspace_button(struct render_context *ctx,
653
656
cairo_set_operator (cairo , CAIRO_OPERATOR_SOURCE );
654
657
cairo_set_source_u32 (cairo , box_colors .background );
655
658
ctx -> background_color = box_colors .background ;
659
+ ctx -> has_transparency |= (box_colors .background & 0xFF ) != 0xFF ;
656
660
cairo_rectangle (cairo , * x , 0 , width , height );
657
661
cairo_fill (cairo );
658
662
@@ -760,10 +764,12 @@ void render_frame(struct swaybar_output *output) {
760
764
background_color = output -> bar -> config -> colors .background ;
761
765
}
762
766
763
- struct render_context ctx = { 0 };
764
- ctx .output = output ;
765
- // initial background color used for deciding the best way to antialias text
766
- ctx .background_color = background_color ;
767
+ struct render_context ctx = {
768
+ .output = output ,
769
+ // initial background color used for deciding the best way to antialias text
770
+ .background_color = background_color ,
771
+ .has_transparency = (background_color & 0xFF ) != 0xFF ,
772
+ };
767
773
768
774
cairo_surface_t * recorder = cairo_recording_surface_create (
769
775
CAIRO_CONTENT_COLOR_ALPHA , NULL );
@@ -834,8 +840,7 @@ void render_frame(struct swaybar_output *output) {
834
840
wl_surface_damage (output -> surface , 0 , 0 ,
835
841
output -> width , output -> height );
836
842
837
- uint32_t bg_alpha = background_color & 0xFF ;
838
- if (bg_alpha == 0xFF ) {
843
+ if (!ctx .has_transparency ) {
839
844
struct wl_region * region =
840
845
wl_compositor_create_region (output -> bar -> compositor );
841
846
wl_region_add (region , 0 , 0 , INT32_MAX , INT32_MAX );
0 commit comments