diff options
-rw-r--r-- | sway/tree/container.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 90ca9b2c..3ec58a5d 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -576,8 +576,19 @@ static void update_title_texture(struct sway_container *con, | |||
576 | return; | 576 | return; |
577 | } | 577 | } |
578 | 578 | ||
579 | int width = con->width * output->sway_output->wlr_output->scale; | 579 | double scale = output->sway_output->wlr_output->scale; |
580 | int height = config->font_height * output->sway_output->wlr_output->scale; | 580 | int width = 0; |
581 | int height = config->font_height * scale; | ||
582 | |||
583 | cairo_t *c = cairo_create(NULL); | ||
584 | get_text_size(c, config->font, &width, NULL, scale, false, "%s", con->name); | ||
585 | cairo_destroy(c); | ||
586 | |||
587 | int borders = (con->type == C_VIEW ? con->sway_view->border_thickness : | ||
588 | config->border_thickness) * 2 * scale; | ||
589 | if (width > con->width * scale - borders) { | ||
590 | width = con->width * scale - borders; | ||
591 | } | ||
581 | 592 | ||
582 | cairo_surface_t *surface = cairo_image_surface_create( | 593 | cairo_surface_t *surface = cairo_image_surface_create( |
583 | CAIRO_FORMAT_ARGB32, width, height); | 594 | CAIRO_FORMAT_ARGB32, width, height); |
@@ -591,8 +602,7 @@ static void update_title_texture(struct sway_container *con, | |||
591 | class->text[2], class->text[3]); | 602 | class->text[2], class->text[3]); |
592 | cairo_move_to(cairo, 0, 0); | 603 | cairo_move_to(cairo, 0, 0); |
593 | 604 | ||
594 | pango_printf(cairo, config->font, output->sway_output->wlr_output->scale, | 605 | pango_printf(cairo, config->font, scale, false, "%s", con->name); |
595 | false, "%s", con->name); | ||
596 | 606 | ||
597 | cairo_surface_flush(surface); | 607 | cairo_surface_flush(surface); |
598 | unsigned char *data = cairo_image_surface_get_data(surface); | 608 | unsigned char *data = cairo_image_surface_get_data(surface); |