From f64aa2bbd4ba4fffeeff09f5225946649fab530e Mon Sep 17 00:00:00 2001 From: Mike Gorse Date: Tue, 12 Apr 2022 08:40:12 -0500 Subject: Expose the accessible hierarchy via dbus introspection --- atk-adaptor/bridge.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c index f808acb..8cb6ecc 100644 --- a/atk-adaptor/bridge.c +++ b/atk-adaptor/bridge.c @@ -715,14 +715,53 @@ static GOptionEntry atspi_option_entries[] = { {NULL} }; +static void +add_objects_for_introspection (AtkObject *obj, GString *str) +{ + gchar *path; + AtkStateSet *set; + char *p; + gint i; + gint count; + + if (!obj) + return; + + path = spi_register_object_to_path (spi_global_register, G_OBJECT (obj)); + p = strrchr (path, '/') + 1; + g_string_append_printf (str, "\n", p); + g_free (path); + + if (ATK_IS_SOCKET (obj)) + return; + + set = atk_object_ref_state_set (obj); + if (atk_state_set_contains_state (set, ATK_STATE_MANAGES_DESCENDANTS)) + { + g_object_unref (set); + return; + } + g_object_unref (set); + + count = atk_object_get_n_accessible_children (obj); + for (i = 0; i < count; i++) + { + AtkObject *child = atk_object_ref_accessible_child (obj, i); + add_objects_for_introspection (child, str); + g_object_unref (child); + } +} + static gchar * introspect_children_cb (const char *path, void *data) { if (!strcmp (path, "/org/a11y/atspi/accessible")) { - return g_strdup ("\n"); - /* TODO: Should we place the whole hierarchy here? */ + GString *str = g_string_new (NULL); + add_objects_for_introspection (spi_global_app_data->root, str); + return g_string_free (str, FALSE); } + return NULL; } -- cgit v1.2.1