[gnome-shell/gbsneto/remove-generic-container: 16/39] st-box-layout: Pass correct allocation box to layout manager



commit 2350daeb451878fc466c17cea0bb4f309bcc8921
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Aug 23 21:41:00 2018 -0300

    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

 src/st/st-box-layout.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/st/st-box-layout.c b/src/st/st-box-layout.c
index 3acb15c40..1b7127e69 100644
--- a/src/st/st-box-layout.c
+++ b/src/st/st-box-layout.c
@@ -282,13 +282,12 @@ st_box_layout_allocate (ClutterActor          *actor,
   StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (actor)->priv;
   StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
   ClutterLayoutManager *layout = clutter_actor_get_layout_manager (actor);
+  ClutterActorBox viewport_content_box;
   ClutterActorBox content_box;
   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, &content_box);
-  clutter_actor_box_get_size (&content_box, &avail_width, &avail_height);
+  st_theme_node_get_content_box (theme_node, box, &viewport_content_box);
+  clutter_actor_box_get_size (&viewport_content_box, &avail_width, &avail_height);
 
   clutter_layout_manager_get_preferred_width (layout, CLUTTER_CONTAINER (actor),
                                               avail_height,
@@ -297,6 +296,18 @@ st_box_layout_allocate (ClutterActor          *actor,
                                                MAX (avail_width, min_width),
                                                &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 */
   if (priv->vadjustment)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]