From 53acff167b2ccb60203b9de0e436be8dfa9f570d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 4 Nov 2021 13:28:45 +0100 Subject: [PATCH] Revert "label: Never measure more than max-width-chars" This reverts commit ba44e7a228534ff066694ad97d25eaa23ec5f3af. The change was meant to revert to old GTK3 behavior but it actually broke new GTK4 behavior that is in use where max-width-chars is used to determine an ideal size, but where we don't want to limit the width to that size. So what happens is the reintroduction of GTK3-style lots of whitepsace bugs, and we really don't want those. We also don't want to break backwards compat if we can avoid it. So let's revert this. The reftest that was made for this purpose has been adapted. Fixes #4399 --- gtk/gtklabel.c | 15 +-------------- ...dth-chars-and-halign-and-infinite-width.ref.ui | 4 +--- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 661902a275..b9886dd471 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -1045,20 +1045,7 @@ get_height_for_width (GtkLabel *self, PangoLayout *layout; int text_height, baseline; - width *= PANGO_SCALE; - if (self->max_width_chars > -1) - { - int char_pixels, width_chars; - - layout = gtk_label_get_measuring_layout (self, NULL, -1); - char_pixels = get_char_pixels (GTK_WIDGET (self), layout); - if (self->width_chars > self->max_width_chars) - width_chars = self->width_chars; - else - width_chars = self->max_width_chars; - width = MIN (char_pixels * width_chars, width); - } - layout = gtk_label_get_measuring_layout (self, NULL, width); + layout = gtk_label_get_measuring_layout (self, NULL, width * PANGO_SCALE); pango_layout_get_pixel_size (layout, NULL, &text_height); diff --git a/testsuite/reftests/label-max-width-chars-and-halign-and-infinite-width.ref.ui b/testsuite/reftests/label-max-width-chars-and-halign-and-infinite-width.ref.ui index 68c5d0a112..d3f075290b 100644 --- a/testsuite/reftests/label-max-width-chars-and-halign-and-infinite-width.ref.ui +++ b/testsuite/reftests/label-max-width-chars-and-halign-and-infinite-width.ref.ui @@ -8,9 +8,7 @@ start end 0 - ABCDE -ABCD - 4 + ABCDE ABCD