summaryrefslogtreecommitdiffstats
path: root/swaybar/render.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/render.c')
-rw-r--r--swaybar/render.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/swaybar/render.c b/swaybar/render.c
index dc31a5ea..097eb462 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -296,11 +296,15 @@ static uint32_t render_status_line(cairo_t *cairo,
296 296
297static uint32_t render_binding_mode_indicator(cairo_t *cairo, 297static uint32_t render_binding_mode_indicator(cairo_t *cairo,
298 struct swaybar_output *output, double x) { 298 struct swaybar_output *output, double x) {
299 const char *mode = output->bar->mode;
300 if (!mode) {
301 return 0;
302 }
303
299 struct swaybar_config *config = output->bar->config; 304 struct swaybar_config *config = output->bar->config;
300 const char *mode = config->mode;
301 int text_width, text_height; 305 int text_width, text_height;
302 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 306 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
303 output->scale, config->mode_pango_markup, 307 output->scale, output->bar->mode_pango_markup,
304 "%s", mode); 308 "%s", mode);
305 309
306 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; 310 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale;
@@ -333,8 +337,8 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
333 double text_y = height / 2.0 - text_height / 2.0; 337 double text_y = height / 2.0 - text_height / 2.0;
334 cairo_set_source_u32(cairo, config->colors.binding_mode.text); 338 cairo_set_source_u32(cairo, config->colors.binding_mode.text);
335 cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y)); 339 cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y));
336 pango_printf(cairo, config->font, output->scale, config->mode_pango_markup, 340 pango_printf(cairo, config->font, output->scale,
337 "%s", mode); 341 output->bar->mode_pango_markup, "%s", mode);
338 return output->height; 342 return output->height;
339} 343}
340 344
@@ -465,7 +469,7 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaybar_output *output) {
465 max_height = h > max_height ? h : max_height; 469 max_height = h > max_height ? h : max_height;
466 } 470 }
467 } 471 }
468 if (config->binding_mode_indicator && config->mode) { 472 if (config->binding_mode_indicator) {
469 uint32_t h = render_binding_mode_indicator(cairo, output, x); 473 uint32_t h = render_binding_mode_indicator(cairo, output, x);
470 max_height = h > max_height ? h : max_height; 474 max_height = h > max_height ? h : max_height;
471 } 475 }
@@ -490,16 +494,12 @@ static const struct wl_callback_listener output_frame_listener = {
490 494
491void render_frame(struct swaybar_output *output) { 495void render_frame(struct swaybar_output *output) {
492 assert(output->surface != NULL); 496 assert(output->surface != NULL);
493 497 if (!output->layer_surface) {
494 struct swaybar_hotspot *hotspot, *tmp; 498 return;
495 wl_list_for_each_safe(hotspot, tmp, &output->hotspots, link) {
496 if (hotspot->destroy) {
497 hotspot->destroy(hotspot->data);
498 }
499 wl_list_remove(&hotspot->link);
500 free(hotspot);
501 } 499 }
502 500
501 free_hotspots(&output->hotspots);
502
503 cairo_surface_t *recorder = cairo_recording_surface_create( 503 cairo_surface_t *recorder = cairo_recording_surface_create(
504 CAIRO_CONTENT_COLOR_ALPHA, NULL); 504 CAIRO_CONTENT_COLOR_ALPHA, NULL);
505 cairo_t *cairo = cairo_create(recorder); 505 cairo_t *cairo = cairo_create(recorder);
@@ -519,10 +519,12 @@ void render_frame(struct swaybar_output *output) {
519 if (config_height >= 0 && height < (uint32_t)config_height) { 519 if (config_height >= 0 && height < (uint32_t)config_height) {
520 height = config_height; 520 height = config_height;
521 } 521 }
522 if (height != output->height) { 522 if (height != output->height || output->width == 0) {
523 // Reconfigure surface 523 // Reconfigure surface
524 zwlr_layer_surface_v1_set_size(output->layer_surface, 0, height); 524 zwlr_layer_surface_v1_set_size(output->layer_surface, 0, height);
525 zwlr_layer_surface_v1_set_exclusive_zone(output->layer_surface, height); 525 if (strcmp(output->bar->config->mode, "dock") == 0) {
526 zwlr_layer_surface_v1_set_exclusive_zone(output->layer_surface, height);
527 }
526 // TODO: this could infinite loop if the compositor assigns us a 528 // TODO: this could infinite loop if the compositor assigns us a
527 // different height than what we asked for 529 // different height than what we asked for
528 wl_surface_commit(output->surface); 530 wl_surface_commit(output->surface);