summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-04-26 18:04:20 +0200
committerBenjamin Berg <bberg@redhat.com>2021-04-27 21:38:07 +0200
commitf51153498246378586420912d2eb2a4a89415a57 (patch)
tree0579aa17ef5d2b0ae4905f8a633323aa59a10311
parentf84ea29179b2965aa42b6af37863ea7642f876ca (diff)
downloadgnome-session-f51153498246378586420912d2eb2a4a89415a57.tar.gz
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
-rw-r--r--gnome-session/gsm-presence.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/gnome-session/gsm-presence.c b/gnome-session/gsm-presence.c
index cdfa3ccd..0e012c69 100644
--- a/gnome-session/gsm-presence.c
+++ b/gnome-session/gsm-presence.c
@@ -230,6 +230,34 @@ 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;
+ gboolean is_active;
+
+ 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)", &is_active);
+ if (presence->priv->screensaver_active != is_active) {
+ presence->priv->screensaver_active = is_active;
+ set_session_idle (presence, is_active);
+ }
+}
+
+static void
on_screensaver_name_owner_changed (GDBusProxy *screensaver_proxy,
GParamSpec *pspec,
GsmPresence *presence)
@@ -240,9 +268,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 +365,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 +484,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);
}