[gnome-settings-daemon] main: Ensure session registration happens before other idles



commit dcb54d8a1c4ecacf6fbe17bdffefdca3b1e6d2d5
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 22 10:16:42 2012 +0200

    main: Ensure session registration happens before other idles
    
    We're deferring some slower operations to idles, in plugins,
    to have it happen after session registration and not slow down
    login - but I've observed that the ordering is unreliable.
    
    Sometimes we end up doing the RegisterClient call after the
    initial set of idles.
    
    Ensure that the session registration happens before other idles by
    making the idle higher priority than the plugins.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686579

 gnome-settings-daemon/main.c |   44 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/gnome-settings-daemon/main.c b/gnome-settings-daemon/main.c
index fdcb497..efd29a7 100644
--- a/gnome-settings-daemon/main.c
+++ b/gnome-settings-daemon/main.c
@@ -352,6 +352,48 @@ name_lost_handler (GDBusConnection *connection,
         gtk_main_quit ();
 }
 
+static gboolean
+do_register_client (GDBusProxy *proxy)
+{
+        const char *startup_id;
+
+        g_assert (proxy != NULL);
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        g_dbus_proxy_call (proxy,
+                           "RegisterClient",
+                           g_variant_new ("(ss)", "gnome-settings-daemon", startup_id ? startup_id : ""),
+                           G_DBUS_CALL_FLAGS_NONE,
+                           -1,
+                           NULL,
+                           (GAsyncReadyCallback) on_client_registered,
+                           manager);
+
+        return FALSE;
+}
+
+static void
+queue_register_client (void)
+{
+        GDBusConnection *bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+        GDBusProxy *proxy;
+
+        if (!bus)
+                return;
+
+        proxy = gnome_settings_session_get_session_proxy ();
+        if (proxy == NULL) {
+                g_debug ("Could not connect to the Session manager");
+                return;
+        }
+
+        /* Register the daemon with gnome-session */
+        g_signal_connect (G_OBJECT (proxy), "g-signal",
+                          G_CALLBACK (on_session_over), NULL);
+
+        g_idle_add_full (G_PRIORITY_DEFAULT, (GSourceFunc) do_register_client, proxy, NULL);
+}
+
 static void
 bus_register (void)
 {
@@ -445,6 +487,8 @@ main (int argc, char *argv[])
 
         notify_init ("gnome-settings-daemon");
 
+        queue_register_client ();
+
         bus_register ();
 
         gnome_settings_profile_start ("gnome_settings_manager_new");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]