[gnome-settings-daemon] media-keys: Fix shutdown dialog delay when using kbd shortcut



commit 21fb652101fbf81d16f76178da9614dcd547686a
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Nov 17 14:03:37 2016 +0100

    media-keys: Fix shutdown dialog delay when using kbd shortcut
    
    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

 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 aec094b..c178752 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -813,26 +813,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);
 }
 


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