st/scroll-view: Hide scroll bar from layout when its hidden

We hide scrollbars with POLICY_AUTOMATIC when the content of the scroll
view fits completely inside the view without having to scroll. In this case
it seems like a good idea to give the content the full available size
without subtracting scroll bars from that size.

So subtract the scroll bar from the size we give to the child only when
the scroll bar is actually visible, when it's invisible subtract 0 instead.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2190>
This commit is contained in:
Jonas Dreßler 2022-02-16 16:16:49 +01:00
parent a59a992daa
commit 65e56183b1

View file

@ -636,19 +636,14 @@ st_scroll_view_allocate (ClutterActor *actor,
clutter_actor_allocate (priv->hscroll, &empty_box);
}
/* In case the scrollbar policy is NEVER or EXTERNAL or scrollbars
* should be overlaid, we don't trim the content box allocation by
* the scrollbar size.
/* In case the scrollbar is hidden or scrollbars should be overlaid,
* we don't trim the content box allocation by the scrollbar size.
* Fold this into the scrollbar sizes to simplify the rest of the
* computations.
*/
if (priv->hscrollbar_policy == ST_POLICY_NEVER ||
priv->hscrollbar_policy == ST_POLICY_EXTERNAL ||
priv->overlay_scrollbars)
if (!hscrollbar_visible || priv->overlay_scrollbars)
sb_height = 0;
if (priv->vscrollbar_policy == ST_POLICY_NEVER ||
priv->vscrollbar_policy == ST_POLICY_EXTERNAL ||
priv->overlay_scrollbars)
if (!vscrollbar_visible || priv->overlay_scrollbars)
sb_width = 0;
/* Child */