[gnome-settings-daemon] xsettings: Use gnome_rr_screen_new_async()
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] xsettings: Use gnome_rr_screen_new_async()
- Date: Fri, 14 Mar 2014 14:37:32 +0000 (UTC)
commit 478b47873cdd917ae4974b2ffd8502145a3bdbc5
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Thu Mar 13 15:16:18 2014 -0400
xsettings: Use gnome_rr_screen_new_async()
Since gnome-settings-daemon starts before Mutter, we need to use
gnome_rr_screen_new_async() to wait for Mutter to start and provide
the screen information over D-Bus.
https://bugzilla.gnome.org/show_bug.cgi?id=709859
plugins/xsettings/gsd-xsettings-manager.c | 67 +++++++++++++++++++++++-----
1 files changed, 55 insertions(+), 12 deletions(-)
---
diff --git a/plugins/xsettings/gsd-xsettings-manager.c b/plugins/xsettings/gsd-xsettings-manager.c
index 91f1eb5..14f9dc5 100644
--- a/plugins/xsettings/gsd-xsettings-manager.c
+++ b/plugins/xsettings/gsd-xsettings-manager.c
@@ -266,6 +266,8 @@ struct GnomeXSettingsManagerPrivate
GsdRemoteDisplayManager *remote_display;
+ GnomeRRScreen *rr_screen;
+
guint shell_name_watch_id;
gboolean have_shell;
@@ -500,6 +502,17 @@ primary_monitor_on_hdmi (GnomeRROutput *primary)
return TRUE;
}
+static gboolean
+primary_monitor_should_skip_resolution_check (GnomeRROutput *primary)
+{
+ if (!primary_monitor_at_native_resolution (primary))
+ return TRUE;
+ if (!primary_monitor_is_4k (primary) && primary_monitor_on_hdmi (primary))
+ return TRUE;
+
+ return FALSE;
+}
+
static int
get_window_scale (GnomeXSettingsManager *manager)
{
@@ -511,26 +524,19 @@ get_window_scale (GnomeXSettingsManager *manager)
int width_mm, height_mm;
int monitor_scale;
double dpi_x, dpi_y;
- GnomeRRScreen *rr_screen = NULL;
interface_settings = g_hash_table_lookup (manager->priv->settings, INTERFACE_SETTINGS_SCHEMA);
window_scale =
g_settings_get_uint (interface_settings, SCALING_FACTOR_KEY);
if (window_scale == 0) {
int primary;
- GnomeRROutput *output;
+ GnomeRROutput *output = NULL;
window_scale = 1;
- rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL);
- if (!rr_screen)
- goto out;
- output = get_primary_output (rr_screen);
- if (!output)
- goto out;
- if (!primary_monitor_at_native_resolution (output))
- goto out;
- if (!primary_monitor_is_4k (output) && primary_monitor_on_hdmi (output))
+ if (manager->priv->rr_screen)
+ output = get_primary_output (manager->priv->rr_screen);
+ if (output && primary_monitor_should_skip_resolution_check (output))
goto out;
display = gdk_display_get_default ();
@@ -554,7 +560,6 @@ get_window_scale (GnomeXSettingsManager *manager)
}
out:
- g_clear_object (&rr_screen);
return window_scale;
}
@@ -1063,6 +1068,33 @@ force_disable_animation_changed (GObject *gobject,
}
}
+static void
+on_rr_screen_changed (GnomeRRScreen *screen,
+ GnomeXSettingsManager *manager)
+{
+ update_xft_settings (manager);
+ queue_notify (manager);
+}
+
+static void
+on_rr_screen_acquired (GObject *object,
+ GAsyncResult *result,
+ gpointer data)
+{
+ GnomeXSettingsManager *manager = data;
+ GnomeRRScreen *rr_screen;
+
+ rr_screen = gnome_rr_screen_new_finish (result, NULL);
+ if (!rr_screen)
+ return;
+
+ manager->priv->rr_screen = rr_screen;
+ g_signal_connect (rr_screen, "changed",
+ G_CALLBACK (on_rr_screen_changed), manager);
+
+ on_rr_screen_changed (rr_screen, manager);
+}
+
gboolean
gnome_xsettings_manager_start (GnomeXSettingsManager *manager,
GError **error)
@@ -1085,6 +1117,10 @@ gnome_xsettings_manager_start (GnomeXSettingsManager *manager,
g_signal_connect (G_OBJECT (manager->priv->remote_display), "notify::force-disable-animations",
G_CALLBACK (force_disable_animation_changed), manager);
+ gnome_rr_screen_new_async (gdk_screen_get_default (),
+ on_rr_screen_acquired,
+ manager);
+
manager->priv->settings = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL, (GDestroyNotify) g_object_unref);
@@ -1174,6 +1210,13 @@ gnome_xsettings_manager_stop (GnomeXSettingsManager *manager)
g_clear_object (&manager->priv->remote_display);
+ if (manager->priv->rr_screen != NULL) {
+ g_signal_handlers_disconnect_by_func (manager->priv->rr_screen,
+ (gpointer) on_rr_screen_changed,
+ manager);
+ g_clear_object (&manager->priv->rr_screen);
+ }
+
if (p->shell_name_watch_id > 0)
g_bus_unwatch_name (p->shell_name_watch_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]