From 5616bbd45b13ec9b76619c2a594cdc9a930edca1 Mon Sep 17 00:00:00 2001 From: Adel Gadllah Date: Thu, 13 Mar 2014 13:56:02 +0100 Subject: [PATCH] hidpi: Listen for gtk-xft-dpi instead of monitors-changed Currently we update the scale factor on startup and when we get a monitors-changed signal, which is not the only cases where the setting changes. We cannot listen for gdk-window-scaling-factor changes because it is not exported to gdk. So use gtk-xft-dpi which also indicates a scale factor change. When someone changes gtk-xft-dpi directly without changing the scale factor we will just re-read the gdk-window-scaling-factor so no harm is done. https://bugzilla.gnome.org/show_bug.cgi?id=726238 --- src/shell-global.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/shell-global.c b/src/shell-global.c index d44d5520a..e0555486d 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -748,7 +748,9 @@ global_stage_after_paint (gpointer data) static void -update_scale_factor (GdkScreen *screen, gpointer data) +update_scale_factor (GtkSettings *settings, + GParamSpec *pspec, + gpointer data) { ShellGlobal *global = SHELL_GLOBAL (data); ClutterStage *stage = CLUTTER_STAGE (global->stage); @@ -938,19 +940,18 @@ _shell_global_set_plugin (ShellGlobal *global, g_signal_connect (global->meta_display, "notify::focus-window", G_CALLBACK (focus_window_changed), global); - /* - * We connect to GdkScreen's monitors-changed here to avoid - * a race condition. GdkScreen's monitors-changed signal is - * emitted *after* the xsetting has been updated. + /* gdk-window-scaling-factor is not exported to gtk-settings + * because it is handled inside gdk, so we use gtk-xft-dpi instead + * which also changes when the scale factor changes. */ - g_signal_connect (global->gdk_screen, "monitors-changed", + g_signal_connect (gtk_settings_get_default (), "notify::gtk-xft-dpi", G_CALLBACK (update_scale_factor), global); gdk_event_handler_set (gnome_shell_gdk_event_handler, global, NULL); global->focus_manager = st_focus_manager_get_for_stage (global->stage); - update_scale_factor (global->gdk_screen, global); + update_scale_factor (gtk_settings_get_default (), NULL, global); } GjsContext *