Stopping the autoread when last object in context is reached
authorMichal Skorupinski <m.skorupinsk@samsung.com>
Mon, 3 Aug 2015 11:51:38 +0000 (13:51 +0200)
committerTomasz Olszak <t.olszak@samsung.com>
Mon, 3 Aug 2015 14:46:22 +0000 (23:46 +0900)
Change-Id: I1c37c32e665177b4629a78633ed39317a0f3f679
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
include/flat_navi.h
src/flat_navi.c
src/navigator.c

index 1f86cb8..4aa097e 100644 (file)
@@ -184,8 +184,14 @@ int flat_navi_context_current_children_count_visible_get( FlatNaviContext *ctx);
  * @param ctx FlatNaviContext
  * @return Pointer to the first item in context
  */
-AtspiAccessible *flat_navi_context_first_get(FlatNaviContext *ctx);
+const AtspiAccessible *flat_navi_context_first_get(FlatNaviContext *ctx);
 
+/**
+ * Returns the last item in context;
+ * @param ctx FlatNaviContext
+ * @return Pointer to the last item in context
+ */
+const AtspiAccessible *flat_navi_context_last_get(FlatNaviContext *ctx);
 
 Eina_Bool flat_navi_is_valid(FlatNaviContext *context, AtspiAccessible *new_root);
 
index 0d12208..dcca42d 100644 (file)
@@ -140,25 +140,25 @@ static AtspiAccessible* _get_object_in_relation(AtspiAccessible *source, AtspiRe
    AtspiRelationType type;
    int i;
    if (source)
-     {
-        DEBUG("CHECKING RELATIONS");
-        relations = atspi_accessible_get_relation_set(source, NULL);
-        for (i = 0; i < relations->len; i++)
-          {
-             DEBUG("ALL RELATIONS FOUND: %d",relations->len);
-             relation = g_array_index (relations, AtspiRelation*, i);
-             type = atspi_relation_get_relation_type(relation);
-             DEBUG("RELATION:  %d",type);
-
-             if (type == search_type)
-               {
-                  ret = atspi_relation_get_target(relation, 0);
-                  DEBUG("SEARCHED RELATION FOUND");
-                  break;
-               }
-          }
+      {
+         DEBUG("CHECKING RELATIONS");
+         relations = atspi_accessible_get_relation_set(source, NULL);
+         for (i = 0; i < relations->len; i++)
+            {
+               DEBUG("ALL RELATIONS FOUND: %d",relations->len);
+               relation = g_array_index (relations, AtspiRelation*, i);
+               type = atspi_relation_get_relation_type(relation);
+               DEBUG("RELATION:  %d",type);
+
+               if (type == search_type)
+                  {
+                     ret = atspi_relation_get_target(relation, 0);
+                     DEBUG("SEARCHED RELATION FOUND");
+                     break;
+                  }
+            }
          g_array_free(relations, TRUE);
-     }
+      }
    return ret;
 }
 
@@ -459,89 +459,89 @@ AtspiAccessible * _directional_depth_first_search(AtspiAccessible *root, AtspiAc
             DEBUG("Start is defunct!");
       }
 
-    AtspiAccessible *node = (start && start_is_not_defunct)
-                            ? g_object_ref(start)
-                            : (root ? g_object_ref(root) : NULL);
-
-    if (!node) return NULL;
-
-    AtspiAccessible *next_related_in_direction = (next_sibling_idx_modifier > 0)
-                                                 ? _get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO)
-                                                 : _get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM);
-
-    Eina_Bool relation_mode = EINA_FALSE;
-    if (next_related_in_direction)
-       {
-          relation_mode = EINA_TRUE;
-          g_object_unref(next_related_in_direction);
-       }
-
-    while (1)
-    {
-       AtspiAccessible *prev_related_in_direction = (next_sibling_idx_modifier > 0)
-                                                    ? _get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM)
-                                                    : _get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO);
-
-       if (node != start && (relation_mode || !prev_related_in_direction) && stop_condition(node))
-          {
-             g_object_unref(prev_related_in_direction);
-             return node;
-          }
-
-       AtspiAccessible *next_related_in_direction = (next_sibling_idx_modifier > 0)
-                                                    ? _get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO)
-                                                    : _get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM);
-
-       DEBUG("RELATION MODE: %d",relation_mode);
-       if (!prev_related_in_direction)
-          DEBUG("PREV IN RELATION NULL");
-       if (!next_related_in_direction)
-          DEBUG("NEXT IN RELATION NULL");
-
-
-       if ((!relation_mode && !prev_related_in_direction && next_related_in_direction) || (relation_mode && next_related_in_direction))
-          {
-              DEBUG("APPLICABLE FOR RELATION NAVIG");
-              g_object_unref(prev_related_in_direction);
-              relation_mode = EINA_TRUE;
-              g_object_unref(node);
-              node = next_related_in_direction;
-          }
-        else
-           {
-              g_object_unref(prev_related_in_direction);
-              g_object_unref(next_related_in_direction);
-              relation_mode = EINA_FALSE;
-              int cc = atspi_accessible_get_child_count(node, NULL);
-              if (cc > 0) // walk down
-                 {
-                    int idx = next_sibling_idx_modifier > 0 ? 0 : cc-1;
-                    g_object_unref(node);
-                    node = atspi_accessible_get_child_at_index (node,idx, NULL);
-                    DEBUG("DFS DOWN");
-                 }
-              else
-                 {
-                    while (!_has_next_sibling(node, next_sibling_idx_modifier) || node==root) // no next sibling
-                          {
-                             DEBUG("DFS NO SIBLING");
-                             if (node == root)
-                                {
-                                   DEBUG("DFS ROOT")
-                                   g_object_unref(node);
-                                   return NULL;
-                                }
-                             g_object_unref(node);
-                             node = atspi_accessible_get_parent(node, NULL);       // walk up...
-                             DEBUG("DFS UP");
-                          }
-                    int idx = atspi_accessible_get_index_in_parent(node, NULL);
-                    g_object_unref(node);
-                    node = atspi_accessible_get_child_at_index(atspi_accessible_get_parent(node, NULL), idx + next_sibling_idx_modifier, NULL);     //... and next
-                    DEBUG("DFS NEXT %d",idx + next_sibling_idx_modifier);
-                 }
-          }
-    }
+   AtspiAccessible *node = (start && start_is_not_defunct)
+                           ? g_object_ref(start)
+                           : (root ? g_object_ref(root) : NULL);
+
+   if (!node) return NULL;
+
+   AtspiAccessible *next_related_in_direction = (next_sibling_idx_modifier > 0)
+         ? _get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO)
+         : _get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM);
+
+   Eina_Bool relation_mode = EINA_FALSE;
+   if (next_related_in_direction)
+      {
+         relation_mode = EINA_TRUE;
+         g_object_unref(next_related_in_direction);
+      }
+
+   while (1)
+      {
+         AtspiAccessible *prev_related_in_direction = (next_sibling_idx_modifier > 0)
+               ? _get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM)
+               : _get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO);
+
+         if (node != start && (relation_mode || !prev_related_in_direction) && stop_condition(node))
+            {
+               g_object_unref(prev_related_in_direction);
+               return node;
+            }
+
+         AtspiAccessible *next_related_in_direction = (next_sibling_idx_modifier > 0)
+               ? _get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO)
+               : _get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM);
+
+         DEBUG("RELATION MODE: %d",relation_mode);
+         if (!prev_related_in_direction)
+            DEBUG("PREV IN RELATION NULL");
+         if (!next_related_in_direction)
+            DEBUG("NEXT IN RELATION NULL");
+
+
+         if ((!relation_mode && !prev_related_in_direction && next_related_in_direction) || (relation_mode && next_related_in_direction))
+            {
+               DEBUG("APPLICABLE FOR RELATION NAVIG");
+               g_object_unref(prev_related_in_direction);
+               relation_mode = EINA_TRUE;
+               g_object_unref(node);
+               node = next_related_in_direction;
+            }
+         else
+            {
+               g_object_unref(prev_related_in_direction);
+               g_object_unref(next_related_in_direction);
+               relation_mode = EINA_FALSE;
+               int cc = atspi_accessible_get_child_count(node, NULL);
+               if (cc > 0) // walk down
+                  {
+                     int idx = next_sibling_idx_modifier > 0 ? 0 : cc-1;
+                     g_object_unref(node);
+                     node = atspi_accessible_get_child_at_index (node,idx, NULL);
+                     DEBUG("DFS DOWN");
+                  }
+               else
+                  {
+                     while (!_has_next_sibling(node, next_sibling_idx_modifier) || node==root) // no next sibling
+                        {
+                           DEBUG("DFS NO SIBLING");
+                           if (node == root)
+                              {
+                                 DEBUG("DFS ROOT")
+                                 g_object_unref(node);
+                                 return NULL;
+                              }
+                           g_object_unref(node);
+                           node = atspi_accessible_get_parent(node, NULL);       // walk up...
+                           DEBUG("DFS UP");
+                        }
+                     int idx = atspi_accessible_get_index_in_parent(node, NULL);
+                     g_object_unref(node);
+                     node = atspi_accessible_get_child_at_index(atspi_accessible_get_parent(node, NULL), idx + next_sibling_idx_modifier, NULL);     //... and next
+                     DEBUG("DFS NEXT %d",idx + next_sibling_idx_modifier);
+                  }
+            }
+      }
 }
 
 AtspiAccessible *_first(FlatNaviContext *ctx)
@@ -643,6 +643,20 @@ AtspiAccessible *flat_navi_context_root_get(FlatNaviContext *ctx)
    return ctx->root;
 }
 
+const AtspiAccessible *flat_navi_context_first_get(FlatNaviContext *ctx)
+{
+   if(!ctx) return NULL;
+
+   return _first(ctx);
+}
+
+const AtspiAccessible *flat_navi_context_last_get(FlatNaviContext *ctx)
+{
+   if(!ctx) return NULL;
+
+   return _last(ctx);
+}
+
 AtspiAccessible *flat_navi_context_current_get(FlatNaviContext *ctx)
 {
    if(!ctx) return NULL;
index 1a7fe30..81e7ea4 100644 (file)
@@ -1366,9 +1366,16 @@ void auto_review_highlight_set(void)
 
    if(!obj)
       {
+         DEBUG("obj == NULL");
          s_auto_review.auto_review_on = false;
          return;
       }
+   else if(obj == flat_navi_context_last_get(context))
+      {
+         DEBUG("obj == flat_navi_context_last_get()");
+         s_auto_review.auto_review_on = false;
+      }
+
 
    _current_highlight_object_set(obj);
 
@@ -1760,16 +1767,18 @@ _move_slider(Gesture_Info *gi)
 AtspiAction *_get_main_window(void)
 {
    AtspiAccessible *win = flat_navi_context_root_get(context);
-   if (!win) {
-               ERROR("win == NULL");
-               return NULL;
-   }
+   if (!win)
+      {
+         ERROR("win == NULL");
+         return NULL;
+      }
 
    AtspiAction *action = atspi_accessible_get_action_iface(win);
-   if (!action) {
-               ERROR("action == NULL");
-               return NULL;
-       }
+   if (!action)
+      {
+         ERROR("action == NULL");
+         return NULL;
+      }
 
    return action;
 }
@@ -1801,9 +1810,9 @@ static void _start_stop_signal_send(void)
    char *action_name = "pause_play";
    AtspiAction *action = _get_main_window();
    if(!action)
-   {
-          ERROR("Could not get the action inteface");
-   }
+      {
+         ERROR("Could not get the action inteface");
+      }
 
    if(!action)
       {
@@ -1813,10 +1822,10 @@ static void _start_stop_signal_send(void)
 
    action_index = _find_action_index(action, action_name);
    if(action_index < 0)
-   {
-          ERROR("Pause_play action not found");
-          return;
-   }
+      {
+         ERROR("Pause_play action not found");
+         return;
+      }
 
    DEBUG("ACTION: %s has index: %d", action_name, action_index);
    atspi_action_do_action(action, action_index, NULL);
@@ -1949,35 +1958,35 @@ static AtspiAccessible* _get_modal_descendant(AtspiAccessible *root)
    atspi_state_set_add (states, ATSPI_STATE_MODAL);
    DEBUG("GET MODAL: STATE SET PREPARED");
    AtspiMatchRule *rule = atspi_match_rule_new (states,
-                                                ATSPI_Collection_MATCH_ANY,
-                                                NULL,
-                                                ATSPI_Collection_MATCH_INVALID,
-                                                NULL,
-                                                ATSPI_Collection_MATCH_INVALID,
-                                                NULL,
-                                                ATSPI_Collection_MATCH_INVALID,
-                                                0);
+                          ATSPI_Collection_MATCH_ANY,
+                          NULL,
+                          ATSPI_Collection_MATCH_INVALID,
+                          NULL,
+                          ATSPI_Collection_MATCH_INVALID,
+                          NULL,
+                          ATSPI_Collection_MATCH_INVALID,
+                          0);
    DEBUG("GET MODAL: MATCHING RULE PREPARED");
    AtspiAccessible *ret = NULL;
    AtspiCollection *col_iface = atspi_accessible_get_collection_iface(root);
    GArray *result = atspi_collection_get_matches (col_iface,
-                                                  rule,
-                                                  ATSPI_Collection_SORT_ORDER_INVALID,
-                                                  1,
-                                                  1,
-                                                  &err);
+                    rule,
+                    ATSPI_Collection_SORT_ORDER_INVALID,
+                    1,
+                    1,
+                    &err);
    GERROR_CHECK(err);
    DEBUG("GET MODAL: QUERY PERFORMED");
    g_object_unref(states);
    g_object_unref(rule);
    g_object_unref(col_iface);
    if (result && result->len > 0)
-     {
-        DEBUG("GET MODAL: MODAL FOUND");
-        g_array_set_clear_func(result, clear);
-        ret = g_object_ref(g_array_index(result, AtspiAccessible*, 0));
-        g_array_free(result, TRUE);
-     }
+      {
+         DEBUG("GET MODAL: MODAL FOUND");
+         g_array_set_clear_func(result, clear);
+         ret = g_object_ref(g_array_index(result, AtspiAccessible*, 0));
+         g_array_free(result, TRUE);
+      }
    return ret;
 }
 
@@ -1988,19 +1997,19 @@ static void on_window_activate(void *data, AtspiAccessible *window)
    app_tracker_callback_unregister(top_window, _view_content_changed, NULL);
 
    if (window)
-     {
-        DEBUG("Window name: %s", atspi_accessible_get_name(window, NULL));
-        app_tracker_callback_register(window, _view_content_changed, NULL);
-        // TODO: modal descendant of window should be used (if exists) otherwise window
-        AtspiAccessible *modal_descendant = _get_modal_descendant(window);
-        _view_content_changed(modal_descendant ? modal_descendant : window, NULL);
-        g_object_unref(modal_descendant);
-     }
+      {
+         DEBUG("Window name: %s", atspi_accessible_get_name(window, NULL));
+         app_tracker_callback_register(window, _view_content_changed, NULL);
+         // TODO: modal descendant of window should be used (if exists) otherwise window
+         AtspiAccessible *modal_descendant = _get_modal_descendant(window);
+         _view_content_changed(modal_descendant ? modal_descendant : window, NULL);
+         g_object_unref(modal_descendant);
+      }
    else
-     {
-        flat_navi_context_free(context);
-        ERROR("No top window found!");
-     }
+      {
+         flat_navi_context_free(context);
+         ERROR("No top window found!");
+      }
    top_window = window;
    DEBUG("END");
 }