diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-05-03 09:02:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-03 09:02:53 -0400 |
commit | 4fd3996d7761c8ff4716463ffe18399a8894577e (patch) | |
tree | 25cf82e816cf1e27ce07a4d80d6246c6a0c5de5f | |
parent | 85396b90fb55b73f000b2ecd943a3d225c95b265 (diff) | |
parent | ed0d606c2aa73f334b670b7b4c958920a6e07d64 (diff) |
Merge pull request #1905 from RyanDwyer/fix-title-width
Fix title texture 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, return; } - int width = con->width * output->sway_output->wlr_output->scale; - int height = config->font_height * output->sway_output->wlr_output->scale; + double scale = output->sway_output->wlr_output->scale; + int width = 0; + int height = config->font_height * scale; + + cairo_t *c = cairo_create(NULL); + get_text_size(c, config->font, &width, NULL, scale, false, "%s", con->name); + cairo_destroy(c); + + int borders = (con->type == C_VIEW ? con->sway_view->border_thickness : + config->border_thickness) * 2 * scale; + if (width > con->width * scale - borders) { + width = con->width * scale - borders; + } cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, width, height); @@ -591,8 +602,7 @@ static void update_title_texture(struct sway_container *con, class->text[2], class->text[3]); cairo_move_to(cairo, 0, 0); - pango_printf(cairo, config->font, output->sway_output->wlr_output->scale, - false, "%s", con->name); + pango_printf(cairo, config->font, scale, false, "%s", con->name); cairo_surface_flush(surface); unsigned char *data = cairo_image_surface_get_data(surface); |