Change the keystroke delivery methid re-entrancy from
authorMark Doffman <mark.doffman@codethink.co.uk>
Wed, 3 Feb 2010 00:58:56 +0000 (16:58 -0800)
committerMark Doffman <mark.doffman@codethink.co.uk>
Wed, 3 Feb 2010 00:58:56 +0000 (16:58 -0800)
looping over the bus to entering a g_main_loop.

Modification to the 'Embed' method so that the address of
the desktop object (Application parent) is stored.

atk-adaptor/accessible-cache.c
atk-adaptor/bridge.c
atk-adaptor/bridge.h
atk-adaptor/event.c
atk-adaptor/object.c

index c449657..813d03f 100644 (file)
@@ -155,6 +155,11 @@ remove_object (GObject * source, GObject * gobj, gpointer data)
   
   if (spi_cache_in (cache, gobj))
     {
+#ifdef SPI_ATK_DEBUG
+  g_debug ("CACHE REM - %s - %d - %s\n", atk_object_get_name (ATK_OBJECT (gobj)),
+            atk_object_get_role (ATK_OBJECT (gobj)),
+            spi_register_object_to_path (spi_global_register, gobj));
+#endif
       g_signal_emit (cache, cache_signals [OBJECT_REMOVED], 0, gobj);
       g_hash_table_remove (cache->objects, gobj);
     }
@@ -168,7 +173,7 @@ add_object (SpiCache * cache, GObject * gobj)
   g_hash_table_insert (cache->objects, gobj, NULL);
 
 #ifdef SPI_ATK_DEBUG
-  g_debug ("CACHE  - %s - %d - %s", atk_object_get_name (ATK_OBJECT (gobj)),
+  g_debug ("CACHE ADD - %s - %d - %s\n", atk_object_get_name (ATK_OBJECT (gobj)),
             atk_object_get_role (ATK_OBJECT (gobj)),
             spi_register_object_to_path (spi_global_register, gobj));
 #endif
index dfa537c..e29314c 100644 (file)
@@ -168,7 +168,7 @@ spi_atk_bridge_get_bus (void)
 static void
 register_application (SpiBridge * app)
 {
-  DBusMessage *message;
+  DBusMessage *message, *reply;
   DBusMessageIter iter;
   DBusError error;
 
@@ -178,13 +178,39 @@ register_application (SpiBridge * app)
                                           SPI_DBUS_PATH_ROOT,
                                           SPI_DBUS_INTERFACE_SOCKET,
                                           "Embed");
-  dbus_message_set_no_reply (message, TRUE);
 
   dbus_message_iter_init_append (message, &iter);
   spi_object_append_reference (&iter, app->root);
-  dbus_connection_send (app->bus, message, NULL);
+
+  reply = dbus_connection_send_with_reply_and_block (app->bus, message, -1, &error);
+
   if (message)
     dbus_message_unref (message);
+
+  if (reply)
+    {
+      DBusMessageIter iter, iter_struct;
+      gchar *app_name, *obj_path;
+
+      dbus_message_iter_init (reply, &iter);
+      dbus_message_iter_recurse (&iter, &iter_struct);
+      if (!(dbus_message_iter_get_arg_type (&iter_struct) == DBUS_TYPE_STRING))
+            g_error ("AT-SPI: Could not obtain desktop path or name\n");
+      dbus_message_iter_get_basic (&iter_struct, &app_name);
+      if (!dbus_message_iter_next (&iter_struct))
+            g_error ("AT-SPI: Could not obtain desktop name");
+      if (!(dbus_message_iter_get_arg_type (&iter_struct) == DBUS_TYPE_OBJECT_PATH))
+            g_error ("AT-SPI: Could not obtain desktop path");
+      dbus_message_iter_get_basic (&iter_struct, &obj_path);
+
+      app->desktop_name = g_strdup (app_name);
+      app->desktop_path = g_strdup (obj_path);
+    }
+  else
+    {
+      g_error ("AT-SPI: Could not embed inside desktop: %s\n", error.message);
+    }
+
 }
 
 /*---------------------------------------------------------------------------*/
index 2a95fcd..81abb92 100644 (file)
@@ -47,6 +47,8 @@ struct _SpiBridge
   SpiCache    *cache;
   SpiLeasing  *leasing;
 */
+  gchar *desktop_name;
+  gchar *desktop_path;
 };
 
 extern SpiBridge *spi_global_app_data;
index 3ba1ba8..0a523af 100644 (file)
@@ -46,31 +46,36 @@ static gint atk_bridge_focus_tracker_id;
 
 /*---------------------------------------------------------------------------*/
 
+typedef struct _SpiReentrantCallClosure 
+{
+  GMainLoop   *loop;
+  DBusMessage *reply;
+} SpiReentrantCallClosure;
+
 static void
 set_reply (DBusPendingCall * pending, void *user_data)
 {
-  void **replyptr = (void **) user_data;
+  SpiReentrantCallClosure* closure = (SpiReentrantCallClosure *) user_data; 
 
-  *replyptr = dbus_pending_call_steal_reply (pending);
+  closure->reply = dbus_pending_call_steal_reply (pending);
+  g_main_loop_quit (closure->loop);
 }
 
 static DBusMessage *
 send_and_allow_reentry (DBusConnection * bus, DBusMessage * message)
 {
   DBusPendingCall *pending;
-  DBusMessage *reply = NULL;
+  SpiReentrantCallClosure closure;
 
   if (!dbus_connection_send_with_reply (bus, message, &pending, -1))
-    {
       return NULL;
-    }
-  dbus_pending_call_set_notify (pending, set_reply, (void *) &reply, NULL);
-  while (!reply)
-    {
-      if (!dbus_connection_read_write_dispatch (bus, -1))
-        return NULL;
-    }
-  return reply;
+  dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL);
+  closure.loop = g_main_loop_new (NULL, FALSE);
+
+  g_main_loop_run  (closure.loop);
+  
+  g_main_loop_unref (closure.loop);
+  return closure.reply;
 }
 
 /*---------------------------------------------------------------------------*/
index f1a47f5..beeada4 100644 (file)
@@ -112,8 +112,8 @@ void
 spi_object_append_desktop_reference (DBusMessageIter * iter)
 {
   DBusMessageIter iter_struct;
-  const char *name = SPI_DBUS_NAME_REGISTRY;
-  const char *path = SPI_DBUS_PATH_ROOT;
+  const char *name = spi_global_app_data->desktop_name;
+  const char *path = spi_global_app_data->desktop_path;
 
   dbus_message_iter_open_container (iter, DBUS_TYPE_STRUCT, NULL,
                                     &iter_struct);