diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2014-07-11 16:42:38 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-07-13 15:35:23 -0400 |
commit | fc6e2cc4b27403707bf2a9f4717442842914e626 (patch) | |
tree | 5d911997ef8c1ba99f257ab43198ec8fc4bc9ddc /gtk/gtksettings.c | |
parent | cef6f34fb7585fc423ec999822d515d6da0e6d6f (diff) | |
download | gtk+-fc6e2cc4b27403707bf2a9f4717442842914e626.tar.gz |
Handle resolution changes in the GDK backend code
gdk_x11_display_set_window_scale() affects the interpretation of the
Xft/DPI XSETTING - it is substituted inside GDK with the value of
Gdk/UnscaledDPI xsetting. However, this change is not propagated to
GTK+ and from GTK+ back to gdk_screen_set_resolution() until the
main loop is run.
Fix this by handling the screen resolution directly in gdk/x11.
This requires duplication of code between GDK and GTK+ since we still
have to handle DPI in GTK+ in the case that GdkSettings:gtk-xft-dpi
is set by the application.
https://bugzilla.gnome.org/show_bug.cgi?id=733076
Diffstat (limited to 'gtk/gtksettings.c')
-rw-r--r-- | gtk/gtksettings.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 64912ceeaf..7549c8d9ab 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -2944,24 +2944,31 @@ settings_update_resolution (GtkSettings *settings) const char *scale_env; double scale; - g_object_get (settings, - "gtk-xft-dpi", &dpi_int, - NULL); + /* We handle this here in the case that the dpi was set on the GtkSettings + * object by the application. Other cases are handled in + * xsettings-client.c:read-settings(). See comment there for the rationale. + */ + if (priv->property_values[PROP_XFT_DPI - 1].source == GTK_SETTINGS_SOURCE_APPLICATION) + { + g_object_get (settings, + "gtk-xft-dpi", &dpi_int, + NULL); - if (dpi_int > 0) - dpi = dpi_int / 1024.; - else - dpi = -1.; + if (dpi_int > 0) + dpi = dpi_int / 1024.; + else + dpi = -1.; - scale_env = g_getenv ("GDK_DPI_SCALE"); - if (scale_env) - { - scale = g_ascii_strtod (scale_env, NULL); - if (scale != 0 && dpi > 0) - dpi *= scale; - } + scale_env = g_getenv ("GDK_DPI_SCALE"); + if (scale_env) + { + scale = g_ascii_strtod (scale_env, NULL); + if (scale != 0 && dpi > 0) + dpi *= scale; + } - gdk_screen_set_resolution (priv->screen, dpi); + gdk_screen_set_resolution (priv->screen, dpi); + } } static void |