Merge branch 'matthiasc/for-main' into 'main'

wayland: Fix handling of the font-rendering setting

Closes #6855

See merge request GNOME/gtk!7443
This commit is contained in:
Matthias Clasen 2024-07-12 00:55:02 +00:00
commit 80df6e2b8d
2 changed files with 22 additions and 6 deletions

View File

@ -1513,6 +1513,18 @@ get_order (const char *s)
return 0;
}
static int
get_font_rendering (const char *s)
{
const char *names[] = { "automatic", "manual" };
for (int i = 0; i < G_N_ELEMENTS (names); i++)
if (strcmp (s, names[i]) == 0)
return i;
return 0;
}
static double
get_dpi_from_gsettings (GdkWaylandDisplay *display_wayland)
{
@ -1839,9 +1851,12 @@ apply_portal_setting (TranslationEntry *entry,
entry->fallback.s = g_intern_string (g_variant_get_string (value, NULL));
break;
case G_TYPE_INT:
case G_TYPE_ENUM:
entry->fallback.i = g_variant_get_int32 (value);
break;
case G_TYPE_ENUM:
if (strcmp (entry->key, "font-rendering") == 0)
entry->fallback.i = get_font_rendering (g_variant_get_string (value, NULL));
break;
case G_TYPE_BOOLEAN:
entry->fallback.b = g_variant_get_boolean (value);
break;

View File

@ -777,7 +777,7 @@ gtk_style_context_resolve_color (GtkStyleContext *context,
GdkRGBA *result)
{
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
GtkCssValue *val;
GtkCssValue *val, *val2;
GtkCssComputeContext ctx = { NULL, };
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
@ -789,13 +789,14 @@ gtk_style_context_resolve_color (GtkStyleContext *context,
if (gtk_css_node_get_parent (priv->cssnode))
ctx.parent_style = gtk_css_node_get_style (gtk_css_node_get_parent (priv->cssnode));
val = gtk_css_value_resolve (color, &ctx, _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
val = gtk_css_value_compute (color, GTK_CSS_PROPERTY_COLOR, &ctx);
val2 = gtk_css_value_resolve (val, &ctx, _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
if (val == NULL)
return FALSE;
*result = *gtk_css_color_value_get_rgba (val2);
*result = *gtk_css_color_value_get_rgba (val);
gtk_css_value_unref (val);
gtk_css_value_unref (val2);
return TRUE;
}