From e6209de96258ab4edf9a6ab03f8ceacdbfbce8cd Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 27 Aug 2020 00:30:38 +0200 Subject: [PATCH] gdk/wayland: Look for font settings in gsettings-desktop-schemas Prefer this location, but also look for the old location in settings-daemon for backwards compatibility. This applies to both direct settings lookups and via the settings portal. --- gdk/wayland/gdkscreen-wayland.c | 62 ++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c index cb60d3a0fd..6c8ca044b7 100644 --- a/gdk/wayland/gdkscreen-wayland.c +++ b/gdk/wayland/gdkscreen-wayland.c @@ -351,25 +351,56 @@ update_xft_settings (GdkScreen *screen) { TranslationEntry *entry; - entry = find_translation_entry_by_schema ("org.gnome.settings-daemon.plugins.xsettings", "antialiasing"); - antialiasing = entry->fallback.i; + entry = find_translation_entry_by_schema ("org.gnome.desktop.interface", "font-antialiasing"); - entry = find_translation_entry_by_schema ("org.gnome.settings-daemon.plugins.xsettings", "hinting"); - hinting = entry->fallback.i; + if (entry->valid) + { + antialiasing = entry->fallback.i; - entry = find_translation_entry_by_schema ("org.gnome.settings-daemon.plugins.xsettings", "rgba-order"); - order = entry->fallback.i; + entry = find_translation_entry_by_schema ("org.gnome.desktop.interface", "font-hinting"); + hinting = entry->fallback.i; + + entry = find_translation_entry_by_schema ("org.gnome.desktop.interface", "font-rgba-order"); + order = entry->fallback.i; + } + else + { + entry = find_translation_entry_by_schema ("org.gnome.settings-daemon.plugins.xsettings", "antialiasing"); + antialiasing = entry->fallback.i; + + entry = find_translation_entry_by_schema ("org.gnome.settings-daemon.plugins.xsettings", "hinting"); + hinting = entry->fallback.i; + + entry = find_translation_entry_by_schema ("org.gnome.settings-daemon.plugins.xsettings", "rgba-order"); + order = entry->fallback.i; + } entry = find_translation_entry_by_schema ("org.gnome.desktop.interface", "text-scaling-factor"); dpi = 96.0 * entry->fallback.i / 65536.0 * 1024; /* Xft wants 1/1024th of an inch */ } else { - settings = g_hash_table_lookup (screen_wayland->settings, - "org.gnome.settings-daemon.plugins.xsettings"); + GSettingsSchemaSource *source; + GSettingsSchema *schema; - if (settings) + source = g_settings_schema_source_get_default (); + schema = g_settings_schema_source_lookup (source, + "org.gnome.desktop.interface", + FALSE); + + if (schema && g_settings_schema_has_key (schema, "font-antialiasing")) { + settings = g_hash_table_lookup (screen_wayland->settings, + "org.gnome.desktop.interface"); + antialiasing = g_settings_get_enum (settings, "font-antialiasing"); + hinting = g_settings_get_enum (settings, "font-hinting"); + order = g_settings_get_enum (settings, "font-rgba-order"); + } + else if (g_hash_table_contains (screen_wayland->settings, + "org.gnome.settings-daemon.plugins.xsettings")) + { + settings = g_hash_table_lookup (screen_wayland->settings, + "org.gnome.settings-daemon.plugins.xsettings"); antialiasing = g_settings_get_enum (settings, "antialiasing"); hinting = g_settings_get_enum (settings, "hinting"); order = g_settings_get_enum (settings, "rgba-order"); @@ -513,6 +544,10 @@ static TranslationEntry translations[] = { { FALSE, "org.gnome.desktop.privacy", "remember-recent-files", "gtk-recent-files-enabled", G_TYPE_BOOLEAN, { .b = TRUE } }, { FALSE, WM_SETTINGS_SCHEMA, "button-layout", "gtk-decoration-layout", G_TYPE_STRING, { .s = "menu:close" } }, { FALSE, CLASSIC_WM_SETTINGS_SCHEMA, "button-layout", "gtk-decoration-layout", G_TYPE_STRING, { .s = "menu:close" } }, + { FALSE, "org.gnome.desktop.interface", "font-antialiasing", "gtk-xft-antialias", G_TYPE_NONE, { .i = 0 } }, + { FALSE, "org.gnome.desktop.interface", "font-hinting", "gtk-xft-hinting", G_TYPE_NONE, { .i = 0 } }, + { FALSE, "org.gnome.desktop.interface", "font-hinting", "gtk-xft-hintstyle", G_TYPE_NONE, { .i = 0 } }, + { FALSE, "org.gnome.desktop.interface", "font-rgba-order", "gtk-xft-rgba", G_TYPE_NONE, { .i = 0 } }, { FALSE, "org.gnome.settings-daemon.plugins.xsettings", "antialiasing", "gtk-xft-antialias", G_TYPE_NONE, { .i = 0 } }, { FALSE, "org.gnome.settings-daemon.plugins.xsettings", "hinting", "gtk-xft-hinting", G_TYPE_NONE, { .i = 0 } }, { FALSE, "org.gnome.settings-daemon.plugins.xsettings", "hinting", "gtk-xft-hintstyle", G_TYPE_NONE, { .i = 0 } }, @@ -604,11 +639,14 @@ apply_portal_setting (TranslationEntry *entry, entry->fallback.b = g_variant_get_boolean (value); break; case G_TYPE_NONE: - if (strcmp (entry->key, "antialiasing") == 0) + if (strcmp (entry->key, "antialiasing") == 0 || + strcmp (entry->key, "font-antialiasing") == 0) entry->fallback.i = get_antialiasing (g_variant_get_string (value, NULL)); - else if (strcmp (entry->key, "hinting") == 0) + else if (strcmp (entry->key, "hinting") == 0 || + strcmp (entry->key, "font-hinting") == 0) entry->fallback.i = get_hinting (g_variant_get_string (value, NULL)); - else if (strcmp (entry->key, "rgba-order") == 0) + else if (strcmp (entry->key, "rgba-order") == 0 || + strcmp (entry->key, "font-rgba-order") == 0) entry->fallback.i = get_order (g_variant_get_string (value, NULL)); else if (strcmp (entry->key, "text-scaling-factor") == 0) entry->fallback.i = (int) (g_variant_get_double (value) * 65536.0);