File at-spi2-register-on-session-running.patch of Package at-spi2-core

diff -Npur at-spi2-core-2.10.2.bak/registryd/registry-main.c at-spi2-core-2.10.2.new/registryd/registry-main.c
--- at-spi2-core-2.10.2.bak/registryd/registry-main.c	2014-04-25 05:31:19.784025353 +0800
+++ at-spi2-core-2.10.2.new/registryd/registry-main.c	2014-04-28 06:53:24.862337160 +0800
@@ -59,9 +59,10 @@ static GDBusProxy      *client_proxy = N
 #define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
 
 static void registry_session_init (const char *previous_client_id, const char *exe);
+static gboolean register_client (void);
 
 static void
-on_session_over (GDBusProxy *proxy,
+on_session_signal (GDBusProxy *proxy,
                  gchar      *sender_name,
                  gchar      *signal_name,
                  GVariant   *parameters,
@@ -69,20 +70,38 @@ on_session_over (GDBusProxy *proxy,
 {
         if (g_strcmp0 (signal_name, "SessionOver") == 0) {
                 g_main_loop_quit (mainloop);
+        } else if (g_strcmp0 (signal_name, "SessionRunning") == 0) {
+                if (!register_client ())
+                        g_warning ("Unable to register client with session manager");
         }
 }
 
 static gboolean
 session_manager_connect (void)
 {
+        GVariant *res;
+        gboolean is_running;
 
         sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, 0, NULL,
                                               SM_DBUS_NAME,
                                               SM_DBUS_PATH,
                                               SM_DBUS_INTERFACE, NULL, NULL);
 
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                 "IsSessionRunning", NULL,
+                                  0, 1000, NULL, NULL);
+       
+        if (res) {
+	        g_variant_get (res, "(b)", &is_running);
+        	g_variant_unref (res);
+                if (is_running) {
+                        if (!register_client ())
+                                g_warning ("Unable to register client with session manager");
+                }
+	}
+
         g_signal_connect (G_OBJECT (sm_proxy), "g-signal",
-                          G_CALLBACK (on_session_over), NULL);
+                          G_CALLBACK (on_session_signal), NULL);
 
         return (sm_proxy != NULL);
 }
@@ -96,7 +115,7 @@ stop_cb (gpointer data)
 static gboolean
 end_session_response (gboolean is_okay, const gchar *reason)
 {
-  GVariant *ret;
+        GVariant *ret;
         GError *error = NULL;
 
         if (!reason)
@@ -141,7 +160,7 @@ static gboolean
 register_client (void)
 {
         GError     *error;
-  GVariant *res;
+        GVariant *res;
         const char *startup_id;
         const char *app_id;
 
@@ -243,9 +262,6 @@ main (int argc, char **argv)
     {
       if (!session_manager_connect ())
           g_warning ("Unable to connect to session manager");
-
-      if (!register_client ())
-          g_warning ("Unable to register client with session manager");
     }
 
   g_main_loop_run (mainloop);
openSUSE Build Service is sponsored by