Use deputy object sent by "GetNavigableAtPoint"
[platform/upstream/at-spi2-core.git] / atspi / atspi-accessible.c
index 02a526c..bafe114 100644 (file)
@@ -340,13 +340,39 @@ atspi_accessible_get_navigable_at_point (AtspiAccessible *root,
   DBusMessage *reply;
   AtspiAccessible *return_value = NULL;
   unsigned char recurse = 0;
+  DBusMessageIter iter;
+  AtspiAccessible *deputy = NULL;
 
   g_return_val_if_fail (root != NULL, NULL);
   do {
     reply = _atspi_dbus_call_partial (root, atspi_interface_accessible, "GetNavigableAtPoint", error, "iiu", d_x, d_y, d_ctype);
 
-    AtspiAccessible *tmp = _atspi_dbus_return_accessible_and_recurse_info_from_message (reply, &recurse);
-    if (!tmp) break;
+    _ATSPI_DBUS_CHECK_SIG (reply, "(so)y(so)", NULL, NULL);
+
+    dbus_message_iter_init (reply, &iter);
+    AtspiAccessible *tmp = _atspi_dbus_return_accessible_from_iter (&iter);
+
+    unsigned char value = 0;
+    dbus_message_iter_get_basic (&iter, &value);
+    dbus_message_iter_next (&iter);
+    recurse = (value != 0);
+
+    /* keep deputy if tmp has deputy */
+    if (!deputy)
+      deputy = _atspi_dbus_return_accessible_from_iter (&iter);
+
+    dbus_message_unref(reply);
+
+    if (!tmp) {
+      if (deputy) {
+        /* TODO: need to check deputy works for return value */
+        if (return_value)
+          g_object_unref(return_value);
+        return deputy;
+      }
+      break;
+    }
+
     if (return_value)
       g_object_unref(return_value);
     return_value = root = tmp;
@@ -584,11 +610,22 @@ atspi_accessible_get_neighbor (AtspiAccessible *root,
   unsigned char recurse;
   GetNeighborSearchMode search_mode = NEIGHBOR_SEARCH_MODE_NORMAL;
   GQueue *children_root_stack = g_queue_new();
+  DBusMessageIter iter;
 
   while(1) {
     const char *path = are_objects_on_the_same_bus(root, start) ? root_path : "";
     DBusMessage *reply = _atspi_dbus_call_partial (start, atspi_interface_accessible, "GetNeighbor", error, "sii", path, (int)direction, (int)search_mode);
-    AtspiAccessible *ret = _atspi_dbus_return_accessible_and_recurse_info_from_message (reply, &recurse);
+
+    dbus_message_iter_init (reply, &iter);
+    AtspiAccessible *ret = _atspi_dbus_return_accessible_from_iter (&iter);
+
+    unsigned char value = 0;
+    dbus_message_iter_get_basic (&iter, &value);
+    dbus_message_iter_next (&iter);
+    recurse = (value != 0);
+
+    dbus_message_unref(reply);
+
     // got return value and request for recursive search, it means ret is on another bridge, than start
     // thus we're recursing. should the recurse failed to find anything it will end with
     if (ret && recurse) {
@@ -611,6 +648,7 @@ atspi_accessible_get_neighbor (AtspiAccessible *root,
     if (!g_queue_is_empty(children_root_stack)) {
       g_object_unref(G_OBJECT(start));
       start = g_queue_pop_tail(children_root_stack);
+
       search_mode = NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING;
       continue;
     }
@@ -624,6 +662,7 @@ atspi_accessible_get_neighbor (AtspiAccessible *root,
         g_object_unref(G_OBJECT(start));
         start = parent;
       }
+
       // going up thru parents put us in weird place (we didnt meet root on the way)
       // so we bail out
       if (!start)