summaryrefslogtreecommitdiff
path: root/swaybar/render.c
diff options
context:
space:
mode:
authorReza Jelveh <[email protected]>2024-04-15 13:39:41 +0800
committerGitHub <[email protected]>2024-04-15 01:39:41 -0400
commitfb86ed6b0588dfdebfb66ce875bc63cfa0a897f6 (patch)
tree29857a1769107adc58696f08d379f608aa4e29a2 /swaybar/render.c
parenta5e79676c4bd22fc5902182acf0667907202a465 (diff)
feat: 1.9 merge (#277)
Co-authored-by: William McKinnon <[email protected]> Co-authored-by: Erik Reider <[email protected]>
Diffstat (limited to 'swaybar/render.c')
-rw-r--r--swaybar/render.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/swaybar/render.c b/swaybar/render.c
index ccf36563..1113ca44 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -693,15 +693,6 @@ static uint32_t render_to_cairo(struct render_context *ctx) {
struct swaybar_output *output = ctx->output;
struct swaybar *bar = output->bar;
struct swaybar_config *config = bar->config;
- cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
- if (output->focused) {
- ctx->background_color = config->colors.focused_background;
- } else {
- ctx->background_color = config->colors.background;
- }
-
- cairo_set_source_u32(cairo, ctx->background_color);
- cairo_paint(cairo);
int th;
get_text_size(cairo, config->font_description, NULL, &th, NULL, 1, false, "");
@@ -763,8 +754,17 @@ void render_frame(struct swaybar_output *output) {
free_hotspots(&output->hotspots);
+ uint32_t background_color;
+ if (output->focused) {
+ background_color = output->bar->config->colors.focused_background;
+ } else {
+ background_color = output->bar->config->colors.background;
+ }
+
struct render_context ctx = { 0 };
ctx.output = output;
+ // initial background color used for deciding the best way to antialias text
+ ctx.background_color = background_color;
cairo_surface_t *recorder = cairo_recording_surface_create(
CAIRO_CONTENT_COLOR_ALPHA, NULL);
@@ -774,24 +774,23 @@ void render_frame(struct swaybar_output *output) {
ctx.cairo = cairo;
cairo_font_options_t *fo = cairo_font_options_create();
- cairo_font_options_set_hint_style(fo, CAIRO_HINT_STYLE_FULL);
cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_GRAY);
ctx.textaa_safe = fo;
if (output->subpixel == WL_OUTPUT_SUBPIXEL_NONE) {
ctx.textaa_sharp = ctx.textaa_safe;
} else {
fo = cairo_font_options_create();
- cairo_font_options_set_hint_style(fo, CAIRO_HINT_STYLE_FULL);
cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_SUBPIXEL);
cairo_font_options_set_subpixel_order(fo,
to_cairo_subpixel_order(output->subpixel));
ctx.textaa_sharp = fo;
}
- cairo_save(cairo);
- cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR);
+
+ cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_u32(cairo, background_color);
cairo_paint(cairo);
- cairo_restore(cairo);
+
uint32_t height = render_to_cairo(&ctx);
int config_height = output->bar->config->height;
if (config_height > 0) {
@@ -836,13 +835,15 @@ void render_frame(struct swaybar_output *output) {
wl_surface_damage(output->surface, 0, 0,
output->width, output->height);
- uint32_t bg_alpha = ctx.background_color & 0xFF;
+ uint32_t bg_alpha = background_color & 0xFF;
if (bg_alpha == 0xFF) {
struct wl_region *region =
wl_compositor_create_region(output->bar->compositor);
wl_region_add(region, 0, 0, INT32_MAX, INT32_MAX);
wl_surface_set_opaque_region(output->surface, region);
wl_region_destroy(region);
+ } else {
+ wl_surface_set_opaque_region(output->surface, NULL);
}
struct wl_callback *frame_callback = wl_surface_frame(output->surface);