[gnome-shell/gnome-40] st/scroll-view: Only update fade effect on CSS changes if CSS sets it



commit 65b67905d178bc59f524c4a9c54d519cd1fd7636
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Wed Feb 16 12:56:49 2022 +0100

    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>
    (cherry picked from commit 0b9b13942a16d0d71a06f293ce23484f6251a415)

 src/st/st-scroll-view.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/src/st/st-scroll-view.c b/src/st/st-scroll-view.c
index 606701565d..b10ae44b42 100644
--- a/src/st/st-scroll-view.c
+++ b/src/st/st-scroll-view.c
@@ -753,17 +753,24 @@ st_scroll_view_style_changed (StWidget *widget)
 {
   StScrollView *self = ST_SCROLL_VIEW (widget);
   StScrollViewPrivate *priv = self->priv;
+  gboolean has_vfade, has_hfade;
+  double vfade_offset = 0.0;
+  double hfade_offset = 0.0;
 
   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");
-  st_scroll_view_update_fade_effect (self,
-                                     &(ClutterMargin) {
-                                       .top = vfade_offset,
-                                       .bottom = vfade_offset,
-                                       .left = hfade_offset,
-                                       .right = 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,
+                                         &(ClutterMargin) {
+                                           .top = vfade_offset,
+                                           .bottom = vfade_offset,
+                                           .left = hfade_offset,
+                                           .right = hfade_offset,
+                                         });
+    }
 
   st_widget_style_changed (ST_WIDGET (priv->hscroll));
   st_widget_style_changed (ST_WIDGET (priv->vscroll));


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