Handle single one finger tap and hover on accessible objects vol.2 by Lukasz Oleksak
authorPatryk Kaczmarek <patryk.k@samsung.com>
Fri, 29 May 2015 12:35:49 +0000 (14:35 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Fri, 5 Jun 2015 08:40:37 +0000 (17:40 +0900)
Change-Id: I66a2eb847535f35fb02eea31fdf7b1bf4c433794
Signed-off-by: Patryk Kaczmarek <patryk.k@samsung.com>
include/flat_navi.h
src/flat_navi.c
src/navigator.c
tests/atspi/atspi.c
tests/atspi/atspi.h

index dbc09b1..ddcb4b4 100644 (file)
@@ -146,4 +146,21 @@ AtspiAccessible *flat_navi_context_line_first(FlatNaviContext *ctx);
  */
 AtspiAccessible *flat_navi_context_line_last(FlatNaviContext *ctx);
 
+/**
+ * Set current context at given position.
+ *
+ * @param ctx FlatNaviContext
+ *
+ * @param x_cord gint X coordinate
+ *
+ * @param y_cord gint Y coordinate
+ *
+ * @param obj AtspiAccessible Reference to object on point
+ *
+ * @return Eina_Bool true on success
+ *
+ * @note current element will be first of line.
+ */
+Eina_Bool flat_navi_context_current_at_x_y_set( FlatNaviContext *ctx, gint x_cord, gint y_cord , AtspiAccessible **obj);
+
 #endif /* end of include guard: FLAT_NAVI_H_ */
index bff3989..ab0b300 100644 (file)
@@ -260,6 +260,56 @@ debug(FlatNaviContext *ctx)
    DEBUG("===============================");
 }
 
+static Eina_Bool
+_contains(AtspiAccessible *obj, gint x, gint y)
+{
+   const ObjectCache *oc = object_cache_get(obj);
+
+   if (x >= oc->bounds->x && x <= oc->bounds->x + oc->bounds->width
+         && y >= oc->bounds->y && y <= oc->bounds->y + oc->bounds->height)
+      {
+         DEBUG("INSIDE");
+         return EINA_TRUE;
+      }
+
+   return EINA_FALSE;
+
+}
+
+Eina_Bool flat_navi_context_current_at_x_y_set( FlatNaviContext *ctx, gint x_cord, gint y_cord , AtspiAccessible **target)
+{
+   if(!ctx || !target) return EINA_FALSE;
+
+   AtspiAccessible *current = flat_navi_context_current_get(ctx);
+   if (current && _contains(current, x_cord, y_cord))
+      {
+         *target = current;
+         return EINA_TRUE;
+      }
+
+   Eina_List *l, *l2, *line;
+   Eina_Bool found = EINA_FALSE;
+   AtspiAccessible *obj;
+   EINA_LIST_FOREACH(ctx->lines, l, line)
+   {
+      EINA_LIST_FOREACH(line, l2, obj)
+      if (_contains(obj, x_cord, y_cord))
+         {
+            found = EINA_TRUE;
+            break;
+         }
+      if (found)
+         {
+            *target = obj;
+            ctx->current_line = l;
+            ctx->current = l2;
+            break;
+         }
+   }
+
+   return found;
+}
+
 FlatNaviContext *flat_navi_context_create(AtspiAccessible *root)
 {
    FlatNaviContext *ret;
index d7c51a3..29a34b9 100644 (file)
@@ -37,6 +37,7 @@ typedef struct
    int x,y;
 } last_focus_t;
 
+static last_focus_t last_focus = {-1,-1};
 static AtspiAccessible *current_obj;
 static AtspiAccessible *top_window;
 //static AtspiScrollable *scrolled_obj;
@@ -497,40 +498,32 @@ static AtspiAccessible *get_nearest_widget(AtspiAccessible* app_obj, gint x_cord
 }
 #endif
 
-#if 0
 static void _focus_widget(Gesture_Info *info)
 {
    DEBUG("START");
-   AtspiAccessible *target_widget;
-   AtspiComponent *window_component;
-   GError *err = NULL;
 
-   window_component = atspi_accessible_get_component_iface(top_window);
-   if(!window_component)
-      return;
-   if ((last_focus.x == info->x_begin) && (last_focus.y == info->y_begin))
+   if ((last_focus.x == info->x_beg) && (last_focus.y == info->y_beg))
       return;
 
-   target_widget = atspi_component_get_accessible_at_point(window_component, info->x_begin, info->y_begin, ATSPI_COORD_TYPE_WINDOW, &err);
-   GERROR_CHECK(err)
-   if (target_widget)
+   AtspiAccessible *obj;
+
+   if (flat_navi_context_current_at_x_y_set(context, info->x_beg, info->y_beg, &obj))
       {
-         DEBUG("WIDGET FOUND:%s", atspi_accessible_get_name(target_widget, NULL));
-         if (flat_navi_context_current_set(context, target_widget))
+         if (obj == current_obj)
             {
-               _current_highlight_object_set(target_widget);
-               last_focus.x = info->x_begin;
-               last_focus.y = info->y_begin;
+               DEBUG("The same object");
+               return;
             }
-         else
-            ERROR("Hoveed object not found in window context[%dx%d][%s]", info->x_begin, info->y_begin, atspi_accessible_get_role_name(top_window, &err));
+         last_focus.x = info->x_beg;
+         last_focus.y = info->y_beg;
+         _current_highlight_object_set(obj);
       }
    else
-      DEBUG("NO widget under (%d, %d) found",
-            info->x_begin, info->y_begin);
+      DEBUG("NO widget under (%d, %d) found or the same widget under hover",
+            info->x_beg, info->y_beg);
+
    DEBUG("END");
 }
-#endif
 
 static void _focus_next(void)
 {
@@ -559,6 +552,7 @@ static void _focus_next(void)
    DEBUG("END");
 }
 
+
 static void _focus_prev(void)
 {
    AtspiAccessible *obj;
@@ -1034,7 +1028,7 @@ static void on_gesture_detected(void *data, Gesture_Info *info)
    switch(info->type)
       {
       case ONE_FINGER_HOVER:
-         //_focus_widget(info);
+         _focus_widget(info);
          break;
       case TWO_FINGERS_HOVER:
 //          _widget_scroll(info);
@@ -1052,7 +1046,7 @@ static void on_gesture_detected(void *data, Gesture_Info *info)
          _value_dec_widget();
          break;
       case ONE_FINGER_SINGLE_TAP:
-         //_focus_widget(info);
+         _focus_widget(info);
          break;
       case ONE_FINGER_DOUBLE_TAP:
          _activate_widget();
index 95db8f5..c6d4677 100644 (file)
@@ -185,6 +185,11 @@ gboolean atspi_component_clear_highlight (AtspiComponent *obj, GError **error)
    return FALSE;
 }
 
+gboolean atspi_component_contains (AtspiComponent *obj, gint x, gint y, AtspiCoordType ctype, GError **error)
+{
+   return TRUE;
+}
+
 GArray *atspi_state_set_get_states (AtspiStateSet *set)
 {
    gint i = 0;
index 48b8495..765ab86 100644 (file)
@@ -399,6 +399,8 @@ AtspiRelationType atspi_relation_get_relation_type (AtspiRelation *obj);
 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_exit(void);
 
 #endif /*__ATSPI_H__*/