diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-03 22:51:14 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-03 22:51:14 +1000 |
commit | ed0d606c2aa73f334b670b7b4c958920a6e07d64 (patch) | |
tree | 25cf82e816cf1e27ce07a4d80d6246c6a0c5de5f | |
parent | Fix unfocused.text default (diff) | |
download | sway-ed0d606c2aa73f334b670b7b4c958920a6e07d64.tar.gz sway-ed0d606c2aa73f334b670b7b4c958920a6e07d64.tar.zst sway-ed0d606c2aa73f334b670b7b4c958920a6e07d64.zip |
Fix title texture width
Use max of the container width or text width.
-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); |