[gnome-session/benzea/do-not-start-screensaver-proxy] presence: Do not auto-start the GNOME Shell screensaver service




commit bd9f129bac10b3269730a7c3c834a0402fc1628b
Author: Benjamin Berg <bberg redhat com>
Date:   Mon Apr 26 18:04:20 2021 +0200

    presence: Do not auto-start the GNOME Shell screensaver service
    
    As is, we are requesting the screensaver proxy to be started too early
    in the login process. One issue that this is causing that login may hang
    for a long time, other possible issues appear to be that the screensaver
    service is not running at all in the end.
    
    Note that gnome-settings-daemon will request the startup later on.
    
    Thanks to Xiaoguang Wang <xwang suse com> for finding this issue and
    suggesting a fix!
    
    Closes: #88

 gnome-session/gsm-presence.c | 42 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/gnome-session/gsm-presence.c b/gnome-session/gsm-presence.c
index cdfa3ccd..08a5202e 100644
--- a/gnome-session/gsm-presence.c
+++ b/gnome-session/gsm-presence.c
@@ -229,6 +229,29 @@ on_screensaver_dbus_signal (GDBusProxy  *proxy,
         }
 }
 
+static void
+screensaver_get_active_cb (GDBusProxy  *screensaver_proxy,
+                           GAsyncResult *res,
+                           GsmPresence *presence)
+{
+        g_autoptr(GVariant) data = NULL;
+        g_autoptr(GError) error = NULL;
+
+        data = g_dbus_proxy_call_finish (screensaver_proxy, res, &error);
+        if (data) {
+                if (error) {
+                        g_warning ("Could not retrieve current screensaver active state: %s",
+                                   error->message);
+                } else {
+                        g_warning ("Could not retrieve current screensaver active state!");
+                }
+
+                return;
+        }
+
+        g_variant_get (data, "(b)", &presence->priv->screensaver_proxy);
+}
+
 static void
 on_screensaver_name_owner_changed (GDBusProxy  *screensaver_proxy,
                                    GParamSpec  *pspec,
@@ -240,9 +263,19 @@ on_screensaver_name_owner_changed (GDBusProxy  *screensaver_proxy,
         if (name_owner == NULL) {
                 g_debug ("Detected that screensaver has left the bus");
 
-                presence->priv->screensaver_proxy = NULL;
                 presence->priv->screensaver_active = FALSE;
                 set_session_idle (presence, FALSE);
+        } else {
+                g_debug ("Detected that screensaver has aquired the bus");
+
+                g_dbus_proxy_call (presence->priv->screensaver_proxy,
+                                   "GetActive",
+                                   NULL,
+                                   G_DBUS_CALL_FLAGS_NO_AUTO_START,
+                                   1000,
+                                   NULL,
+                                   (GAsyncReadyCallback) screensaver_get_active_cb,
+                                   presence);
         }
 
         g_free (name_owner);
@@ -327,8 +360,12 @@ gsm_presence_constructor (GType                  type,
                 g_warning ("Unable to register presence with session bus");
         }
 
+        /* This only connects to signals and resolves the current name owner
+         * synchronously. It is important to not auto-start the service!
+         */
         presence->priv->screensaver_proxy = g_dbus_proxy_new_sync (presence->priv->connection,
-                                                                   G_DBUS_PROXY_FLAGS_NONE,
+                                                                   G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
+                                                                   G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
                                                                    NULL,
                                                                    GS_NAME,
                                                                    GS_PATH,
@@ -442,6 +479,7 @@ gsm_presence_finalize (GObject *object)
 
         g_clear_pointer (&presence->priv->status_text, g_free);
         g_clear_object (&presence->priv->idle_monitor);
+        g_clear_object (&presence->priv->screensaver_proxy);
 
         G_OBJECT_CLASS (gsm_presence_parent_class)->finalize (object);
 }


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