[gnome-settings-daemon] power: Lazily connect to gnome-screensaver



commit b531fddec734c7a852563c48def4821d2048036a
Author: Martin Pitt <martin pitt ubuntu com>
Date:   Thu Jan 5 12:12:33 2012 +0100

    power: Lazily connect to gnome-screensaver
    
    Do not D-BUS activate gnome-screensaver right at startup, this unnecessarily
    slows down boot speed. Instead, D-BUS activate it the first time we actually
    need it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=667345

 plugins/power/gsd-power-manager.c |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 78876ce..e936443 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -3340,7 +3340,7 @@ gsd_power_manager_class_init (GsdPowerManagerClass *klass)
 }
 
 static void
-screensaver_proxy_ready_cb (GObject *source_object,
+sleep_cb_screensaver_proxy_ready_cb (GObject *source_object,
                             GAsyncResult *res,
                             gpointer user_data)
 {
@@ -3352,7 +3352,15 @@ screensaver_proxy_ready_cb (GObject *source_object,
                 g_warning ("Could not connect to gnome-screensaver: %s",
                            error->message);
                 g_error_free (error);
+                return;
         }
+
+        /* Finish the upower_notify_sleep_cb() call by locking the screen */
+        g_debug ("gnome-screensaver activated, doing gnome-screensaver lock");
+        g_dbus_proxy_call (manager->priv->screensaver_proxy,
+                           "Lock",
+                           NULL, G_DBUS_CALL_FLAGS_NONE, -1,
+                           NULL, NULL, NULL);
 }
 
 static void
@@ -3524,6 +3532,17 @@ upower_notify_sleep_cb (UpClient *client,
                                    "Lock",
                                    NULL, G_DBUS_CALL_FLAGS_NONE, -1,
                                    NULL, NULL, NULL);
+        } else {
+                /* connect to the screensaver first */
+                g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+                                          G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+                                          NULL,
+                                          GS_DBUS_NAME,
+                                          GS_DBUS_PATH,
+                                          GS_DBUS_INTERFACE,
+                                          NULL,
+                                          sleep_cb_screensaver_proxy_ready_cb,
+                                          manager);
         }
 }
 
@@ -3678,17 +3697,6 @@ gsd_power_manager_start (GsdPowerManager *manager,
                                   power_keyboard_proxy_ready_cb,
                                   manager);
 
-        /* connect to the screensaver */
-        g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
-                                  G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
-                                  NULL,
-                                  GS_DBUS_NAME,
-                                  GS_DBUS_PATH,
-                                  GS_DBUS_INTERFACE,
-                                  NULL,
-                                  screensaver_proxy_ready_cb,
-                                  manager);
-
         /* connect to the session */
         g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                                   G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,



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