2009-04-22 Mark Doffman <mark.doffman@codethink.co.uk>
authorMark Doffman <mdoff@silver-wind.(none)>
Wed, 22 Apr 2009 10:52:26 +0000 (11:52 +0100)
committerMark Doffman <mdoff@silver-wind.(none)>
Wed, 22 Apr 2009 11:07:04 +0000 (12:07 +0100)
        Add Device event registration as well as re-entrancy
        for the provider when delivering device-events.

atk-adaptor/event.c
pyatspi/deviceevent.py
pyatspi/registry.py

index 184cc36..3eababe 100644 (file)
@@ -46,6 +46,32 @@ static gint atk_bridge_focus_tracker_id;
 
 /*---------------------------------------------------------------------------*/
 
+static void
+set_reply (DBusPendingCall *pending, void *user_data)
+{
+    void **replyptr = (void **)user_data;
+
+    *replyptr = dbus_pending_call_steal_reply (pending);
+}
+
+static DBusMessage *
+send_and_allow_reentry (DBusConnection *bus, DBusMessage *message)
+{
+    DBusPendingCall *pending;
+    DBusMessage *reply = NULL;
+
+    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;
+}
+
 static gboolean
 Accessibility_DeviceEventController_notifyListenersSync(const Accessibility_DeviceEvent *key_event)
 {
@@ -53,16 +79,16 @@ Accessibility_DeviceEventController_notifyListenersSync(const Accessibility_Devi
   DBusError error;
   dbus_bool_t consumed = FALSE;
 
-  message = 
+  message =
   dbus_message_new_method_call(SPI_DBUS_NAME_REGISTRY, 
-                              SPI_DBUS_PATH_DEC,
-                              SPI_DBUS_INTERFACE_DEC,
-                              "notifyListenersSync");
+                               SPI_DBUS_PATH_DEC,
+                               SPI_DBUS_INTERFACE_DEC,
+                               "notifyListenersSync");
 
   dbus_error_init(&error);
   if (spi_dbus_marshal_deviceEvent(message, key_event))
   {
-    DBusMessage *reply = dbus_connection_send_with_reply_and_block(atk_adaptor_app_data->bus, message, 1000, &error);
+    DBusMessage *reply = send_and_allow_reentry (atk_adaptor_app_data->bus, message);
     if (reply)
     {
       DBusError error;
index 472bc92..4b26ba8 100644 (file)
@@ -543,7 +543,7 @@ class KeyboardDeviceEventListener(_service.Object):
                         return self._registry.handleDeviceEvent(event, self)
                 except Exception, e:
                         import traceback
-                        traceback.print_exe()
+                        traceback.print_exc()
                         return False
 
 #END---------------------------------------------------------------------------
index db374fa..66fcaf7 100644 (file)
@@ -349,7 +349,6 @@ class _Registry(object):
                         AT-SPI is in the foreground? (requires xevie)
                 @type global_: boolean
                 """
-                """
                 try:
                         # see if we already have an observer for this client
                         ob = self.deviceClients[client]
@@ -364,8 +363,6 @@ class _Registry(object):
                         mask = utils.allModifiers()
                 # register for new keystrokes on the observer
                 ob.register(self.dev, key_set, mask, kind)
-                """
-                pass
 
         def deregisterKeystrokeListener(self,
                                         client,