diff options
author | Bastien Nocera <hadess@hadess.net> | 2016-11-17 14:03:37 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2016-11-17 14:08:06 +0100 |
commit | ccd363432aed51ddd622268501c3636595ef18bf (patch) | |
tree | 95cfa3d603df8d1fb24b13c6c29838858c503968 | |
parent | a8e12d6ec5f77f1eb955355c3cbab435f7dd64cd (diff) | |
download | gnome-settings-daemon-gnome-3-18.tar.gz |
media-keys: Fix shutdown dialog delay when using kbd shortcutgnome-3-18
After pressing the Ctrl+Alt+Del shortcut, the shutdown dialog doesn't
appear on screen for a couple of seconds.
The media-keys daemon calls the 'Shutdown' method synchronously. After that
gnome-session calls the daemon with 'QueryEndSession'. The daemon cannot
reply as it's blocked waiting for the reply to the Shutdown method.
Sending the message asynchronously fixes that delay.
Based on report by Xiaoguang Wang <xwang@suse.com>
https://bugzilla.gnome.org/show_bug.cgi?id=774452
-rw-r--r-- | plugins/media-keys/gsd-media-keys-manager.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c index ae34db9b..4341a2a1 100644 --- a/plugins/media-keys/gsd-media-keys-manager.c +++ b/plugins/media-keys/gsd-media-keys-manager.c @@ -781,26 +781,42 @@ do_media_action (GsdMediaKeysManager *manager, } static void +gnome_session_shutdown_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GVariant *result; + GError *error = NULL; + + result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), + res, + &error); + if (result == NULL) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("Failed to call Shutdown on session manager: %s", + error->message); + g_error_free (error); + } else { + g_variant_unref (result); + } +} + +static void gnome_session_shutdown (GsdMediaKeysManager *manager) { - GError *error = NULL; - GVariant *variant; GDBusProxy *proxy; proxy = G_DBUS_PROXY (gnome_settings_bus_get_session_proxy ()); - variant = g_dbus_proxy_call_sync (proxy, - "Shutdown", - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error); - if (variant == NULL) { - g_warning ("Failed to call Shutdown on session manager: %s", error->message); - g_error_free (error); - return; - } - g_variant_unref (variant); + + g_dbus_proxy_call (proxy, + "Shutdown", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + manager->priv->bus_cancellable, + gnome_session_shutdown_cb, + NULL); + g_object_unref (proxy); } |