st/scroll-view: Only update fade effect on CSS changes if CSS sets it

The fade effect can also be added to the scroll view programatically
instead of using CSS via the st_scroll_view_update_fade_effect() API.

We make use of this API in the appDisplay, but since commit ba547ec1d
the fade margins get overridden to 0.0 from the ::style-changed handler.
Fix this by only setting the fade margins when CSS actually defines a
custom vfade/hfade offset.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5079
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2189>
This commit is contained in:
Jonas Dreßler 2022-02-16 12:56:49 +01:00 committed by Marge Bot
parent 2607880bf6
commit 0b9b13942a

View File

@ -770,10 +770,16 @@ static void
st_scroll_view_style_changed (StWidget *widget) st_scroll_view_style_changed (StWidget *widget)
{ {
StScrollView *self = ST_SCROLL_VIEW (widget); StScrollView *self = ST_SCROLL_VIEW (widget);
gboolean has_vfade, has_hfade;
double vfade_offset = 0.0;
double hfade_offset = 0.0;
StThemeNode *theme_node = st_widget_get_theme_node (widget); StThemeNode *theme_node = st_widget_get_theme_node (widget);
gdouble vfade_offset = st_theme_node_get_length (theme_node, "-st-vfade-offset");
gdouble hfade_offset = st_theme_node_get_length (theme_node, "-st-hfade-offset"); has_vfade = st_theme_node_lookup_length (theme_node, "-st-vfade-offset", FALSE, &vfade_offset);
has_hfade = st_theme_node_lookup_length (theme_node, "-st-hfade-offset", FALSE, &hfade_offset);
if (has_vfade || has_hfade)
{
st_scroll_view_update_fade_effect (self, st_scroll_view_update_fade_effect (self,
&(ClutterMargin) { &(ClutterMargin) {
.top = vfade_offset, .top = vfade_offset,
@ -781,6 +787,7 @@ st_scroll_view_style_changed (StWidget *widget)
.left = hfade_offset, .left = hfade_offset,
.right = hfade_offset, .right = hfade_offset,
}); });
}
ST_WIDGET_CLASS (st_scroll_view_parent_class)->style_changed (widget); ST_WIDGET_CLASS (st_scroll_view_parent_class)->style_changed (widget);
} }