st-box-layout: Pass correct allocation box to layout manager
StBoxLayout implements StScrollable, which, semantically, means that the StBoxLayout size may not match the minimum size reported by the layout manager. In this specific case, the layout manager by is a ClutterBoxLayout by default. For example: +--------------+ | Viewport | +------+--------------+-----------------+ | | | | | | | Content | | | | | +------+--------------+-----------------+ | | +--------------+ So, assuming that: - ContentSize = the minimum size of the content; - ViewportSize = the allocated size of the viewport; When allocating StBoxLayout, it must assume ViewportSize, but must pass ContentSize to the layout manager. That way, the children of StBoxLayout are correctly placed within it, even if it's bigger than ViewportSize. And here's the problem: right now, StBoxLayout assumes ViewportSize AND also passes it to layout manager. Commit 77c4c6b6d specifically exposed this bug by relying entirely on StBoxLayout to arrange the app and window icons. Fix that by using ViewportSize to allocate StBoxLayout itself, but passing ContentSize to the layout manager. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/153
This commit is contained in:
parent
c6cea277eb
commit
2717ca9d08
@ -282,13 +282,12 @@ st_box_layout_allocate (ClutterActor *actor,
|
|||||||
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (actor)->priv;
|
StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (actor)->priv;
|
||||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||||
ClutterLayoutManager *layout = clutter_actor_get_layout_manager (actor);
|
ClutterLayoutManager *layout = clutter_actor_get_layout_manager (actor);
|
||||||
|
ClutterActorBox viewport_content_box;
|
||||||
ClutterActorBox content_box;
|
ClutterActorBox content_box;
|
||||||
gfloat avail_width, avail_height, min_width, natural_width, min_height, natural_height;
|
gfloat avail_width, avail_height, min_width, natural_width, min_height, natural_height;
|
||||||
|
|
||||||
CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->allocate (actor, box, flags);
|
st_theme_node_get_content_box (theme_node, box, &viewport_content_box);
|
||||||
|
clutter_actor_box_get_size (&viewport_content_box, &avail_width, &avail_height);
|
||||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
|
||||||
clutter_actor_box_get_size (&content_box, &avail_width, &avail_height);
|
|
||||||
|
|
||||||
clutter_layout_manager_get_preferred_width (layout, CLUTTER_CONTAINER (actor),
|
clutter_layout_manager_get_preferred_width (layout, CLUTTER_CONTAINER (actor),
|
||||||
avail_height,
|
avail_height,
|
||||||
@ -297,6 +296,18 @@ st_box_layout_allocate (ClutterActor *actor,
|
|||||||
MAX (avail_width, min_width),
|
MAX (avail_width, min_width),
|
||||||
&min_height, &natural_height);
|
&min_height, &natural_height);
|
||||||
|
|
||||||
|
/* Because StBoxLayout implements StScrollable, the allocation box passed here
|
||||||
|
* may not match the minimum sizes reported by the layout manager. When that
|
||||||
|
* happens, the content box needs to be adjusted to match the reported minimum
|
||||||
|
* sizes before being passed to clutter_layout_manager_allocate() */
|
||||||
|
clutter_actor_set_allocation (actor, box, flags);
|
||||||
|
|
||||||
|
content_box = viewport_content_box;
|
||||||
|
content_box.x2 += MAX (0, min_width - avail_width);
|
||||||
|
content_box.y2 += MAX (0, min_height - avail_height);
|
||||||
|
|
||||||
|
clutter_layout_manager_allocate (layout, CLUTTER_CONTAINER (actor),
|
||||||
|
&content_box, flags);
|
||||||
|
|
||||||
/* update adjustments for scrolling */
|
/* update adjustments for scrolling */
|
||||||
if (priv->vadjustment)
|
if (priv->vadjustment)
|
||||||
|
Loading…
Reference in New Issue
Block a user