From f2f89d9b46e655e65dd5e0cbcfe1d71597f673b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 26 Oct 2019 09:44:01 +0200 Subject: [PATCH] clutter/actor: Respect CONTENT_SIZE request mode in get_preferred_* APIs Right now the CONTENT_SIZE request mode for a ClutterActor is only respected by `clutter_actor_get_preferred_size()`, but not by `get_preferred_width()` and `get_preferred_height()`. Those simply try to ask the layout manager and will return [0, 0] for actors without children. So be consistent and also return the content size in those two functions. https://gitlab.gnome.org/GNOME/mutter/merge_requests/1019 --- clutter/clutter/clutter-actor.c | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 79a92196a..d711f0607 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -9725,6 +9725,23 @@ clutter_actor_get_preferred_width (ClutterActor *self, return; } + /* if the request mode is CONTENT_SIZE we simply return the content width */ + if (priv->request_mode == CLUTTER_REQUEST_CONTENT_SIZE) + { + float content_width = 0.f; + + if (priv->content != NULL) + clutter_content_get_preferred_size (priv->content, &content_width, NULL); + + if (min_width_p != NULL) + *min_width_p = content_width; + + if (natural_width_p != NULL) + *natural_width_p = content_width; + + return; + } + CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IN_PREF_WIDTH); /* the remaining cases are: @@ -9873,6 +9890,23 @@ clutter_actor_get_preferred_height (ClutterActor *self, return; } + /* if the request mode is CONTENT_SIZE we simply return the content height */ + if (priv->request_mode == CLUTTER_REQUEST_CONTENT_SIZE) + { + float content_height = 0.f; + + if (priv->content != NULL) + clutter_content_get_preferred_size (priv->content, NULL, &content_height); + + if (min_height_p != NULL) + *min_height_p = content_height; + + if (natural_height_p != NULL) + *natural_height_p = content_height; + + return; + } + CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IN_PREF_HEIGHT); /* the remaining cases are: