[screen-reader] Checking for attributes for readings happening on diffrent atspi... 11/82511/4
authorPrasoon Singh <prasoon.16@samsung.com>
Wed, 3 Aug 2016 13:33:28 +0000 (19:03 +0530)
committerPrasoon Singh <prasoon.16@samsung.com>
Wed, 31 Aug 2016 10:28:12 +0000 (15:58 +0530)
Change-Id: Ife03f287580b14e4e9d73705e96f353d8e0dd9b2

include/app_tracker.h
src/app_tracker.c
src/navigator.c

index 8e2ad7c13b7f9d347e0319f904f494213e21a914..34c338667d4b8dd2dd7f506c7daf47b2f38fd6b6 100644 (file)
@@ -4,6 +4,14 @@
 #include <string.h>
 #include <atspi/atspi.h>
 
+enum Reading_Info
+{
+   ACCESSIBLE_INFO_NAME = 1 << 0,
+   ACCESSIBLE_INFO_ROLE = 1 << 1,
+   ACCESSIBLE_INFO_DESCRIPTION = 1 << 2,
+   ACCESSIBLE_INFO_STATE = 1 << 3
+};
+
 /**
  * @brief Callback
  */
index 2d6cf9db0e447106ab24a90acec35582f34f17c9..038e61131a8a31d0b77b2e0cdcb4eadda2ab194e 100644 (file)
@@ -154,10 +154,47 @@ static void _read_value(AtspiValue * value)
        tts_speak(buf, EINA_TRUE);
 }
 
+static unsigned short int _get_objects_attributes(AtspiAccessible* obj)
+{
+       char **list;
+       unsigned int n = 0;
+       int i = 0;
+       unsigned short int attribute = 0;
+       GHashTable *hash_table = NULL;
+       gchar *reading_info = NULL;
+
+       hash_table = atspi_accessible_get_attributes(obj, NULL);
+       if (hash_table) {
+               reading_info = g_hash_table_lookup(hash_table, "reading_information");
+               if (reading_info) {
+                       list = eina_str_split_full(reading_info, "|", 100, &n);
+                       for (i = 0; i < n; i++) {
+                               if (!strcmp(list[i], "name"))
+                                       attribute = attribute | (ACCESSIBLE_INFO_NAME);
+                               else if (!strcmp(list[i], "role"))
+                                       attribute = attribute | (ACCESSIBLE_INFO_ROLE);
+                               else if (!strcmp(list[i], "description"))
+                                       attribute = attribute | (ACCESSIBLE_INFO_DESCRIPTION);
+                               else if (!strcmp(list[i], "state"))
+                                       attribute = attribute | (ACCESSIBLE_INFO_STATE);
+                       }
+               }
+       }
+       if (!hash_table || !reading_info) {
+               attribute = attribute | (ACCESSIBLE_INFO_NAME) |
+                               (ACCESSIBLE_INFO_ROLE) | (ACCESSIBLE_INFO_DESCRIPTION) | (ACCESSIBLE_INFO_STATE);
+       }
+       if (reading_info) g_free(reading_info);
+       if (hash_table) g_hash_table_unref(hash_table);
+
+       return attribute;
+}
+
 static void _on_atspi_event_cb(const AtspiEvent * event)
 {
        GList *l;
        SubTreeRootData *std;
+       unsigned short int attribute = 0;
 
        if (!event)
                return;
@@ -171,6 +208,8 @@ static void _on_atspi_event_cb(const AtspiEvent * event)
        }
 
        _print_event_object_info(event);
+       attribute = _get_objects_attributes(event->source);
+
 #ifndef X11_ENABLED
        if (!strcmp(event->type, "object:bounds-changed")
                && (atspi_accessible_get_role(event->source, NULL) == ATSPI_ROLE_INPUT_METHOD_WINDOW)) {
@@ -239,7 +278,7 @@ static void _on_atspi_event_cb(const AtspiEvent * event)
                }
 
        }
-       if (!strcmp(event->type, "object:property-change:accessible-name") && _object_has_highlighted_state(event->source)) {
+       if (!strcmp(event->type, "object:property-change:accessible-name") && _object_has_highlighted_state(event->source) && (attribute & ACCESSIBLE_INFO_NAME)) {
                gchar *name = atspi_accessible_get_name(event->source, NULL);
                DEBUG("New name for object, read:%s", name);
                tts_speak_customized(name, EINA_TRUE, EINA_TRUE, event->source);
@@ -262,7 +301,7 @@ static void _on_atspi_event_cb(const AtspiEvent * event)
        }
        //
 
-       if (!strcmp(event->type, "object:state-changed:animated") && (atspi_accessible_get_role(event->source, NULL) == ATSPI_ROLE_LIST_ITEM)) {
+       if (!strcmp(event->type, "object:state-changed:animated") && (atspi_accessible_get_role(event->source, NULL) == ATSPI_ROLE_LIST_ITEM) && (attribute & ACCESSIBLE_INFO_DESCRIPTION)) {
                GError *err = NULL;
                char buf[256] = "\0";
                gint idx = atspi_accessible_get_index_in_parent(event->source, &err);
@@ -274,7 +313,7 @@ static void _on_atspi_event_cb(const AtspiEvent * event)
                g_error_free(err);
        }
 
-       if (!strcmp(event->type, "object:state-changed:checked")) {
+       if (!strcmp(event->type, "object:state-changed:checked") && (attribute & ACCESSIBLE_INFO_STATE)) {
                char buf[256] = "\0";
                gchar *name = atspi_accessible_get_name(event->source, NULL);
                strncat(buf, name, sizeof(buf) - strlen(buf) - 1);
@@ -287,7 +326,7 @@ static void _on_atspi_event_cb(const AtspiEvent * event)
                g_free(name);
        }
 
-       if (!strcmp(event->type, "object:state-changed:selected") && (atspi_accessible_get_role(event->source, NULL) == ATSPI_ROLE_MENU_ITEM)) {
+       if (!strcmp(event->type, "object:state-changed:selected") && (atspi_accessible_get_role(event->source, NULL) == ATSPI_ROLE_MENU_ITEM) && (attribute & ACCESSIBLE_INFO_STATE)) {
                char buf[256] = "\0";
                char tab_index[16] = "\0";
                AtspiAccessible *parent = atspi_accessible_get_parent(event->source, NULL);
index c1caf143c47c2f544f781a9f034b455165b96f06..86df901e788ef34fb922cab48e8ecc2906a5e071 100644 (file)
@@ -78,14 +78,6 @@ typedef struct {
        int x, y;
 } last_focus_t;
 
-enum Reading_Info
-{
-   ACCESSIBLE_INFO_NAME = 1 << 0,
-   ACCESSIBLE_INFO_ROLE = 1 << 1,
-   ACCESSIBLE_INFO_DESCRIPTION = 1 << 2,
-   ACCESSIBLE_INFO_STATE = 1 << 3
-};
-
 /* The Highlight_Type will be used for access object working for embedded
 toolkit such as Dali does not support at-spi interface. This kind of work
 will make screen-reader be slow. They have to implement the interface */