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
This commit is contained in:
Sebastian Keller 2020-12-16 19:10:31 +01:00
parent 6c5489ab25
commit 0165cce645

View File

@ -2916,6 +2916,14 @@ gtk_render_insertion_cursor (GtkStyleContext *context,
"gtk-cursor-aspect-ratio", &aspect_ratio, "gtk-cursor-aspect-ratio", &aspect_ratio,
NULL); 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))); 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); 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, "gtk-cursor-aspect-ratio", &aspect_ratio,
NULL); 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, draw_insertion_cursor (context, cr,
location->x, location->y, location->height, location->x, location->y, location->height,
aspect_ratio, aspect_ratio,