[gtk/gtk-3-24: 2/4] stylecontext: Add style property fallback for gtk-cursor-aspect-ratio




commit 0165cce6456a749e02aadcfc88a5d6d82089f199
Author: Sebastian Keller <skeller gnome org>
Date:   Wed Dec 16 19:10:31 2020 +0100

    stylecontext: Add style property fallback for gtk-cursor-aspect-ratio
    
    The gtk-cursor-aspect-ratio GtkSetting was only recently introduced and
    replaced the cursor-aspect-ratio style property. This was causing old
    configurations that used CSS to modify this property to no longer apply.
    This commit introduces a fallback from the GtkSetting to the style
    property if the value of the setting is unchanged.
    
    Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/3441

 gtk/gtkstylecontext.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 1dd0576ae7..a96395ca46 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -2916,6 +2916,14 @@ gtk_render_insertion_cursor (GtkStyleContext *context,
                 "gtk-cursor-aspect-ratio", &aspect_ratio,
                 NULL);
 
+  /* Fall back to style property if the GtkSetting property is unchanged */
+  if (aspect_ratio == 0.04f)
+    {
+      gtk_style_context_get_style (context,
+                                   "cursor-aspect-ratio", &aspect_ratio,
+                                   NULL);
+    }
+
   keymap_direction = gdk_keymap_get_direction (gdk_keymap_get_for_display (gdk_screen_get_display 
(priv->screen)));
 
   pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos);
@@ -3003,6 +3011,14 @@ gtk_draw_insertion_cursor (GtkWidget          *widget,
                 "gtk-cursor-aspect-ratio", &aspect_ratio,
                 NULL);
 
+  /* Fall back to style property if the GtkSetting property is unchanged */
+  if (aspect_ratio == 0.04f)
+    {
+      gtk_style_context_get_style (context,
+                                   "cursor-aspect-ratio", &aspect_ratio,
+                                   NULL);
+    }
+
   draw_insertion_cursor (context, cr,
                          location->x, location->y, location->height,
                          aspect_ratio,


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