From dc76c52c307ff023f150712ac06530f76684729c Mon Sep 17 00:00:00 2001 From: Jarkko Oranen Date: Fri, 13 Mar 2020 21:33:05 +0200 Subject: [PATCH] Don't use title content in size calculations This prevents distracting screen flashing and seems to work fine for larger glyphs as well (Tested with Japanese). This is perhaps not the best solution, but it's much less noticeable than the current behaviour. Fixes #4992 --- sway/tree/container.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sway/tree/container.c b/sway/tree/container.c index afb0f9272..3a8eb727a 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -513,8 +513,16 @@ void container_calculate_title_height(struct sway_container *container) { cairo_t *cairo = cairo_create(NULL); int height; int baseline; - get_text_size(cairo, config->font, NULL, &height, &baseline, 1, + /* Calculate height using regular ASCII characters and allow larger glyphs to + * "leak" into the margins. This avoids distracting height changes if switching + * between containers that have differently sized text. + * Larger characters might get cut off, but affected users can work around it by + * increasing the title margins */ + get_text_size(cairo, config->font, NULL, &height, NULL, 1, + config->pango_markup, "%s", "ASCII Baseline"); + get_text_size(cairo, config->font, NULL, NULL, &baseline, 1, config->pango_markup, "%s", container->formatted_title); + cairo_destroy(cairo); container->title_height = height; container->title_baseline = baseline;