Accessiblity highlight index support added
authorPatryk Kaczmarek <patryk.k@samsung.com>
Mon, 15 Jun 2015 14:13:35 +0000 (16:13 +0200)
committerPatryk Kaczmarek <patryk.k@samsung.com>
Wed, 17 Jun 2015 08:28:16 +0000 (17:28 +0900)
      * Accessibility highlight index allows to reorder highlight chain

Change-Id: Ie817b49b5ff770dba9bf339b82d4761b398a55b8
Signed-off-by: Patryk Kaczmarek <patryk.k@samsung.com>
src/navigator.c
src/position_sort.c
tests/atspi/atspi.c
tests/atspi/atspi.h

index 35bac0a..22acedc 100644 (file)
@@ -156,11 +156,13 @@ display_info_about_object(AtspiAccessible *obj)
    char *state_name = NULL;
    AtspiStateSet *st = atspi_accessible_get_state_set (obj);
    GArray *states = atspi_state_set_get_states (st);
+   AtspiComponent *comp = atspi_accessible_get_component_iface(obj);
 
    DEBUG("NAME:%s", name);
    DEBUG("ROLE:%s", role)
    DEBUG("DESCRIPTION:%s", description);
    DEBUG("CHILDS:%d", atspi_accessible_get_child_count(obj, NULL));
+   DEBUG("HIGHLIGHT_INDEX:%d", atspi_component_get_highlight_index(comp, NULL));
    DEBUG("STATES:");
    int a;
    AtspiStateType stat;
@@ -490,6 +492,7 @@ static void find_objects(AtspiAccessible* parent, gint x, gint y, gint radius, d
       }
 }
 
+
 static AtspiAccessible *get_nearest_widget(AtspiAccessible* app_obj, gint x_cord, gint y_cord, gint radius)
 {
    int xn = 0, yn = 0;
@@ -542,6 +545,7 @@ static void _focus_next(void)
          ERROR("No navigation context created");
          return;
       }
+
    obj = flat_navi_context_next(context);
    // try next line
    if (!obj)
@@ -629,6 +633,7 @@ static void _focus_prev(void)
          ERROR("No navigation context created");
          return;
       }
+
    obj = flat_navi_context_prev(context);
    // try previous line
    if (!obj)
index cf9dc28..5f0a0c8 100644 (file)
@@ -61,6 +61,83 @@ _sort_horizontally(const void *a, const void *b)
       return -1;
 }
 
+static int
+_sort_index(const void *a, const void *b)
+{
+   AtspiAccessible *objA, *objB;
+   int ia, ib;
+
+   objA = (AtspiAccessible*)a;
+   objB = (AtspiAccessible*)b;
+
+   DEBUG("objA:%s objB:%s", atspi_accessible_get_name(objA, NULL), atspi_accessible_get_name(objB, NULL));
+
+   AtspiComponent *comp1;
+   AtspiComponent *comp2;
+   comp1 = atspi_accessible_get_component_iface(objA);
+   comp2 = atspi_accessible_get_component_iface(objB);
+
+   ia = atspi_component_get_highlight_index(comp1, NULL);
+   ib = atspi_component_get_highlight_index(comp2, NULL);
+
+   DEBUG("ia:%d ib:%d", ia, ib);
+
+   if (ia == ib)
+      return 0;
+   else if (ia > ib)
+      return 1;
+   else
+      return -1;
+}
+
+static Eina_List*
+_get_rest(const Eina_List *objs)
+{
+   Eina_List *candidates = NULL;
+   const Eina_List *l;
+   AtspiAccessible *obj;
+   AtspiComponent *comp;
+
+   EINA_LIST_FOREACH(objs, l, obj)
+   {
+      if ((comp = atspi_accessible_get_component_iface(obj)) != NULL)
+         {
+            if (atspi_component_get_highlight_index(comp, NULL) == 0)
+               candidates = eina_list_append(candidates, obj);
+         }
+      else
+         DEBUG("No component interface: skipping %s %s",
+               atspi_accessible_get_name(obj, NULL),
+               atspi_accessible_get_role_name(obj, NULL));
+   }
+
+   return candidates;
+}
+
+static Eina_List*
+_get_priorities(const Eina_List *objs)
+{
+   Eina_List *candidates = NULL;
+   const Eina_List *l;
+   AtspiAccessible *obj;
+   AtspiComponent *comp;
+
+   EINA_LIST_FOREACH(objs, l, obj)
+   {
+      if ((comp = atspi_accessible_get_component_iface(obj)) != NULL)
+         {
+            if (atspi_component_get_highlight_index(comp, NULL) > 0)
+               candidates = eina_list_append(candidates, obj);
+         }
+      else
+         DEBUG("No component interface: skipping %s %s",
+               atspi_accessible_get_name(obj, NULL),
+               atspi_accessible_get_role_name(obj, NULL));
+   }
+
+   return eina_list_sort(candidates, 0, _sort_index);
+}
+
 static Eina_List*
 _get_zones(const Eina_List *objs)
 {
@@ -148,12 +225,18 @@ _get_lines(const Eina_List *objs)
 
 Eina_List *position_sort(const Eina_List *objs)
 {
-   Eina_List *l, *line, *zones, *lines = NULL;
+   Eina_List *l, *line, *zones, *priority, *lines = NULL;
+   Eina_List *candidates = NULL;
    int i = 0;
 
+   priority = _get_priorities(objs);
+   DEBUG("With positive index it is: %d", eina_list_count(priority));
+
+   candidates = _get_rest(objs);
+
    // Get list of objects occupying place on the screen
-   DEBUG("PositionSort: Candidates; %d", eina_list_count(objs));
-   zones = _get_zones(objs);
+   DEBUG("PositionSort: Candidates; %d", eina_list_count(candidates));
+   zones = _get_zones(candidates);
 
    // Cluster all zones into lines - verticaly
    DEBUG("PositionSort: Zones; %d", eina_list_count(zones));
@@ -168,6 +251,9 @@ Eina_List *position_sort(const Eina_List *objs)
       eina_list_data_set(l, line);
    }
 
+   if (eina_list_count(priority) > 0)
+      lines = eina_list_prepend(lines, priority);
+
    if (zones) eina_list_free(zones);
 
    return lines;
index cd59fef..3d7cf77 100644 (file)
@@ -413,6 +413,11 @@ AtspiAccessible * atspi_accessible_get_parent (AtspiAccessible *obj, GError **er
    return obj->accessible_parent;
 }
 
+int atspi_component_get_highlight_index(AtspiComponent *obj, GError **error)
+{
+   return 0;
+}
+
 int atspi_exit(void)
 {
    return 1;
index 765ab86..30a1f12 100644 (file)
@@ -400,6 +400,7 @@ gint atspi_relation_get_n_targets (AtspiRelation *obj);
 AtspiAccessible * atspi_relation_get_target (AtspiRelation *obj, gint i);
 AtspiAccessible * atspi_accessible_get_parent (AtspiAccessible *obj, GError **error);
 gboolean atspi_component_contains (AtspiComponent *obj, gint x, gint y, AtspiCoordType ctype, GError **error);
+int atspi_component_get_highlight_index(AtspiComponent *obj, GError **error);
 
 int atspi_exit(void);