[mutter] clutter/text: Also queue relayout if the actor has no valid allocation
- From: verdre <jonasd src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] clutter/text: Also queue relayout if the actor has no valid allocation
- Date: Wed, 27 May 2020 09:24:03 +0000 (UTC)
commit 0b6a3166ed2758a8769f07dcc6f9a962cfd9ab5e
Author: Jonas Dreßler <verdre v0yd nl>
Date: Tue Mar 24 23:43:52 2020 +0100
clutter/text: Also queue relayout if the actor has no valid allocation
In clutter_text_queue_redraw_or_relayout() we check whether the size
of the layout has changed and queue a relayout if it did, otherwise we
only queue a redraw and save some resources.
The current check for this also queues a redraw if the actor has no
valid allocation. That seems right on the first glance since the actor
will be allocated anyway, but we actually want to call
clutter_actor_queue_relayout() again here because that also invalidates
the size cache of the actor which might have been updated and marked
valid in the meantime.
So make sure the size cache is always properly invalidated after the
size of the layout changed and also call clutter_actor_queue_relayout()
in case the actor has no allocation.
This fixes a bug where getting the preferred width of a non-allocated
ClutterText, then changing the string of the ClutterText, and then
getting the preferred width again would return the old cached width (the
width before we changed the string).
The only place where this bug is currently happening is in the overview,
where we call get_preferred_width() on the unallocated ClutterText of
the window clone title: When the window title changes while the
ClutterText is unallocated the size of the title is going to be wrong
and the text might end up ellipsized or too large.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1150
clutter/clutter/clutter-text.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c
index 2886016fb6..444786125b 100644
--- a/clutter/clutter/clutter-text.c
+++ b/clutter/clutter/clutter-text.c
@@ -4786,11 +4786,11 @@ clutter_text_queue_redraw_or_relayout (ClutterText *self)
clutter_text_get_preferred_height (actor, preferred_width, NULL, &preferred_height);
if (clutter_actor_has_allocation (actor) &&
- (fabsf (preferred_width - clutter_actor_get_width (actor)) > 0.001 ||
- fabsf (preferred_height - clutter_actor_get_height (actor)) > 0.001))
- clutter_actor_queue_relayout (actor);
- else
+ fabsf (preferred_width - clutter_actor_get_width (actor)) <= 0.001 &&
+ fabsf (preferred_height - clutter_actor_get_height (actor)) <= 0.001)
clutter_text_queue_redraw (actor);
+ else
+ clutter_actor_queue_relayout (actor);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]