From 82accecf71860313932e556f1ee34c2924892426 Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Tue, 19 Sep 2017 19:59:53 +0900 Subject: [PATCH] Add atspi_accessible_get_default_label_info It is not possible to support default label feature using current at-spi2-core APIs without much of IPC. The following would be difficult case to cover. (top of accessible tree) - (bottom side) PageTab1 - Panel1 - PageTab2 - Panel2 - PageTab3 - Panel3(currently showing) Application could make as below: PageTab1 - Panel1 - PageTab3 - Panel3 - PageTab2 - Panel2(currently showing) or following tree would normally be possilbe: PageTab1 - Panel1 - PageTab2 - Panel2(currently showing) There are much of complicated case over there. So we are handling the default label object stack on toolkit(Elementary) side. The atspi_accessible_get_default_label_info returns default label information to be used screen-reader side. This is not stable. And this depends on toolkit side UI definition. The candidate of default label object could be changed by UI definition. AtspiAccessibleDefaultLabelInfo *dli; dli = atspi_accessible_get_default_label_info(root, &error); You have to free alocated resource as below, if it is not necessary any more. g_object_unref(dli->obj); free(dli); Change-Id: I444906e6d020ea6fe2536a73473e0e796a015d05 --- atspi/atspi-accessible.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ atspi/atspi-accessible.h | 8 ++++++++ atspi/atspi-types.h | 1 + 3 files changed, 57 insertions(+) diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c index 752001c..cb329dc 100644 --- a/atspi/atspi-accessible.c +++ b/atspi/atspi-accessible.c @@ -560,6 +560,54 @@ atspi_accessible_get_reading_material (AtspiAccessible *obj, GError **error) return reading_material; } +/** + * atspi_accessible_get_default_label_info: + * @obj: a pointer to the #AtspiAccessible object would be window. + * + * Gets default label information + * + * Returns: default label information to be used screen-reader side. + * This is not stable. And this depends on toolkit side UI definition. + * The candidate of default label object could be changed by UI definition. + * You have to handle all alocated memory as below on screen-reader side. + * + * AtspiAccessibleDefaultLabelInfo *dli + * g_object_unref(dli->obj); + * free(dli); + **/ +AtspiAccessibleDefaultLabelInfo * +atspi_accessible_get_default_label_info (AtspiAccessible *obj, GError **error) +{ + AtspiAccessibleDefaultLabelInfo *default_label_info = NULL; + AtspiAccessible *default_label_object; + dbus_uint32_t role; + DBusMessage *reply; + DBusMessageIter iter; + + g_return_val_if_fail (obj != NULL, NULL); + + reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetDefaultLabelInfo", error, ""); + + _ATSPI_DBUS_CHECK_SIG (reply, "(so)u", NULL, NULL); + + default_label_info = calloc(1, sizeof(AtspiAccessibleDefaultLabelInfo)); + if (!default_label_info) + { + return default_label_info; + } + + dbus_message_iter_init (reply, &iter); + + default_label_object = _atspi_dbus_return_accessible_from_iter (&iter); + default_label_info->obj = default_label_object; + + dbus_message_iter_get_basic (&iter, &role); + default_label_info->role = role; + dbus_message_iter_next (&iter); + + return default_label_info; +} + static unsigned char are_objects_on_the_same_bus(AtspiAccessible *obj1, AtspiAccessible *obj2) { const char *bus_name_1 = obj1->parent.app->bus_name; diff --git a/atspi/atspi-accessible.h b/atspi/atspi-accessible.h index 0b5152b..9efc168 100644 --- a/atspi/atspi-accessible.h +++ b/atspi/atspi-accessible.h @@ -45,6 +45,12 @@ G_BEGIN_DECLS typedef struct _AtspiAccessiblePrivate AtspiAccessiblePrivate; +struct _AtspiAccessibleDefaultLabelInfo +{ + AtspiAccessible *obj; + AtspiRole role; +}; + struct _AtspiAccessibleReadingMaterial { AtspiAccessible *parent; @@ -115,6 +121,8 @@ AtspiAccessible *atspi_accessible_get_neighbor (AtspiAccessible *root, AtspiAcce AtspiAccessibleReadingMaterial *atspi_accessible_get_reading_material (AtspiAccessible *obj, GError **error); +AtspiAccessibleDefaultLabelInfo *atspi_accessible_get_default_label_info (AtspiAccessible *obj, GError **error); + AtspiAccessible * atspi_accessible_get_parent (AtspiAccessible *obj, GError **error); gint atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error); diff --git a/atspi/atspi-types.h b/atspi/atspi-types.h index 45b815c..d09a972 100644 --- a/atspi/atspi-types.h +++ b/atspi/atspi-types.h @@ -44,6 +44,7 @@ typedef struct _AtspiTableCell AtspiTableCell; typedef struct _AtspiText AtspiText; typedef struct _AtspiValue AtspiValue; typedef struct _AtspiAccessibleReadingMaterial AtspiAccessibleReadingMaterial; +typedef struct _AtspiAccessibleDefaultLabelInfo AtspiAccessibleDefaultLabelInfo; typedef guint AtspiControllerEventMask; -- 2.7.4