summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Ham <bob.ham@puri.sm>2019-09-06 14:59:07 +0100
committerAlexander Mikhaylenko <alexm@gnome.org>2020-10-19 14:51:19 +0500
commit6f6b5faaa216feed666b659d1cdfacd0c5c393d9 (patch)
tree2051a2647b6af770e4697d6684f0904bcee83d7d
parentddb7cab4acfe86ecdfa88eb0fc1c16dfb1efeeac (diff)
downloadgtk+-6f6b5faaa216feed666b659d1cdfacd0c5c393d9.tar.gz
gtkapplication-dbus: Initialise screensaver-active property
When GtkApplication starts listening to the screensaver's D-Bus status, the screensaver-active property is not initialised and applications making use of the property are out of sync until the first state change. Any application starting when the screensaver is active will think it's inactive. To fix this, we set the property when we first start monitoring the screensaver. See https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1091
-rw-r--r--gtk/gtkapplication-dbus.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gtk/gtkapplication-dbus.c b/gtk/gtkapplication-dbus.c
index dc141cfa5f..a270354119 100644
--- a/gtk/gtkapplication-dbus.c
+++ b/gtk/gtkapplication-dbus.c
@@ -329,8 +329,31 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
if (dbus->ss_proxy)
{
+ GVariant *active_var;
+ gboolean active;
+
g_signal_connect (dbus->ss_proxy, "g-signal",
G_CALLBACK (screensaver_signal_session), impl->application);
+
+ active_var = g_dbus_proxy_call_sync (dbus->ss_proxy,
+ "GetActive",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &error);
+ if (!active_var)
+ {
+ g_debug ("Error calling GetActive on GNOME screensaver: %s",
+ error->message);
+ g_clear_error (&error);
+ }
+ else
+ {
+ g_variant_get (active_var, "(b)", &active);
+ g_variant_unref (active_var);
+ gtk_application_set_screensaver_active (dbus->impl.application, active);
+ }
}
g_debug ("Registering client '%s' '%s'", dbus->application_id, client_id);