#include "gesture_tracker.h"
#include "window_tracker.h"
+static AtspiAccessible *current_obj;
+static AtspiAccessible *top_window;
+
+Prev_Scroll_Info scroll_info;
+
+static void _scroll_action(void) // NOT YET IMPLEMENTED
+{
+
+}
+
+static AtspiAccessible *_focus_widget(Gesture_Info *info)
+{
+ AtspiAccessible *target_widget = NULL;
+ AtspiComponent *target_component = NULL;
+ AtspiComponent *window_component = NULL;
+
+ window_component = atspi_accessible_get_component(top_window);
+ if(!window_component)
+ return;
+
+ target_widget = atspi_component_get_accessible_at_point(window_component, info->x_begin, info->y_begin, ATSPI_COORD_TYPE_WINDOW, NULL);
+ if(!target_widget)
+ return;
+
+ target_component = atspi_accessible_get_component(target_widget);
+ if(!target_component)
+ return;
+ else
+ {
+ if (atspi_component_grab_focus(target_component, NULL) == TRUE)
+ printf("Focus was changed\n");
+ }
+}
+
+static AtspiAccessible *_focused_next_widget(void)
+{
+ AtspiAccessible *current_widget = NULL;
+ AtspiComponent *focus_component = NULL;
+ GArray *relations = NULL;
+ AtspiRelation *relation = NULL;
+ AtspiRelationType type;
+ int i;
+
+ current_widget = current_obj;
+
+ relations = atspi_accessible_get_relation_set(current_widget, NULL);
+
+ if (relations->len)
+ {
+ for (i = 0; i < relations->len; i++)
+ {
+ relation = g_array_index (relations, AtspiRelation*, i);
+ type = atspi_relation_get_relation_type(relation);
+
+ if (type == ATSPI_RELATION_FLOWS_TO)
+ {
+ current_widget = atspi_relation_get_target(relation, 0);
+ }
+ }
+ }
+
+ focus_component = atspi_accessible_get_component(current_widget);
+
+ if (focus_component != NULL)
+ {
+ printf("Focus component is not null\n");
+ if (atspi_component_grab_focus(focus_component, NULL) == TRUE)
+ printf("Focus was changed\n");
+ }
+ return current_widget;
+}
+
+static AtspiAccessible *_focused_prev_widget(void)
+{
+ AtspiAccessible *current_widget = NULL;
+ AtspiComponent *focus_component = NULL;
+ GArray *relations = NULL;
+ AtspiRelation *relation = NULL;
+ AtspiRelationType type;
+ int i;
+
+
+ current_widget = current_obj;
+
+ relations = atspi_accessible_get_relation_set(current_widget, NULL);
+
+ if (relations->len)
+ {
+ for (i = 0; i < relations->len; i++)
+ {
+ relation = g_array_index (relations, AtspiRelation*, i);
+ type = atspi_relation_get_relation_type(relation);
+
+ if (type == ATSPI_RELATION_FLOWS_FROM)
+ {
+ current_widget = atspi_relation_get_target(relation, 0);
+ }
+ }
+ }
+
+ focus_component = atspi_accessible_get_component(current_widget);
+
+ if (focus_component != NULL)
+ {
+ if (atspi_component_grab_focus(focus_component, NULL) == TRUE)
+ printf("Focus was changed\n");
+ }
+
+ return current_widget;
+}
+
+static void _focus_next(void)
+{
+ char *txt;
+ AtspiAccessible *current_widget = NULL;
+
+ current_obj = _focused_next_widget();
+ current_widget = current_obj;
+
+ gchar *roleName;
+ roleName = atspi_accessible_get_role_name(current_widget, NULL);
+ printf("Widget role next: %s\n", roleName);
+}
+
+static void _focus_prev(void)
+{
+
+ char *txt;
+ AtspiAccessible *current_widget = NULL;
+
+ current_obj = _focused_prev_widget();
+ current_widget = current_obj;
+
+ gchar *roleName;
+ roleName = atspi_accessible_get_role_name(current_widget, NULL);
+ printf("Widget role prev: %s\n", roleName);
+}
+
+static void _value_inc_widget(void)
+{
+ AtspiAccessible* current_widget = current_obj;
+
+ AtspiValue *value_interface = atspi_accessible_get_value(current_widget);
+ if(value_interface)
+ {
+ gdouble current_val = atspi_value_get_current_value(value_interface, NULL);
+ gdouble minimum_inc = atspi_value_get_minimum_increment(value_interface, NULL);
+ atspi_value_set_current_value(value_interface, current_val + minimum_inc, NULL);
+ }
+}
+
+static void _value_dec_widget(void)
+{
+ AtspiAccessible* current_widget = current_obj;
+
+ AtspiValue *value_interface = atspi_accessible_get_value(current_widget);
+ if(value_interface)
+ {
+ gdouble current_val = atspi_value_get_current_value(value_interface, NULL);
+ gdouble minimum_inc = atspi_value_get_minimum_increment(value_interface, NULL);
+ atspi_value_set_current_value(value_interface, current_val - minimum_inc, NULL);
+ }
+}
+
+static Eina_Bool
+_timeout(void *data)
+{
+ AtspiAccessible *current_widget = data;
+ AtspiAction *action;
+ gint number;
+ gchar *actionName;
+ int i;
+
+ action = atspi_accessible_get_action(current_widget);
+ number = atspi_action_get_n_actions(action, NULL);
+ printf("Number of available action = %d\n", number);
+
+ for (i=0; i<number; i++)
+ {
+ actionName = atspi_action_get_name(action, i, NULL);
+
+ if (!strcmp("release", actionName))
+ atspi_action_do_action(action, i, NULL);
+ }
+ return EINA_FALSE;
+}
+
+static void _scroll_up_widget(void)
+{
+ AtspiAccessible *current_widget = NULL;
+
+ current_widget = current_obj;
+
+ gchar *roleName;
+ gchar *actionName;
+ roleName = atspi_accessible_get_role_name(current_widget, NULL);
+ printf("Widget role prev: %s\n", roleName);
+
+ AtspiAction *action;
+ gint number;
+ int i;
+ int k;
+
+ action = atspi_accessible_get_action(current_widget);
+ number = atspi_action_get_n_actions(action, NULL);
+ printf("Number of available action = %d\n", number);
+
+ actionName = atspi_action_get_name(action, i, NULL);
+ printf("Action name = %s\n", actionName);
+
+ if (!strcmp("scroll_up", actionName))
+ {
+ atspi_action_do_action(action, i, NULL);
+ }
+ else if (!strcmp("scroll_down", actionName))
+ {
+ atspi_action_do_action(action, i, NULL);
+ }
+}
+
+static void _activate_widget(void)
+{
+ //activate the widget
+ //only if activate mean click
+ //special behavior for entry, caret should move from first/last last/first
+
+ AtspiAccessible *current_widget = NULL;
+
+ current_widget = current_obj;
+
+ gchar *roleName;
+ gchar *actionName;
+ roleName = atspi_accessible_get_role_name(current_widget, NULL);
+ printf("Widget role prev: %s\n", roleName);
+
+ AtspiAction *action;
+ gint number;
+ int i;
+ int k;
+
+ action = atspi_accessible_get_action(current_widget);
+ number = atspi_action_get_n_actions(action, NULL);
+ printf("Number of available action = %d\n", number);
+
+ GArray *array = atspi_accessible_get_interfaces(current_widget);
+ printf("TAB LEN = %d \n", array->len);
+
+ for (k=0; k < array->len; k++)
+ printf("Interface = %s\n", g_array_index( array, gchar *, k ));
+
+ for (i=0; i<number; i++)
+ {
+ actionName = atspi_action_get_name(action, i, NULL);
+ printf("Action name = %s\n", actionName);
+
+ if (!strcmp("click", actionName))
+ {
+ atspi_action_do_action(action, i, NULL);
+ }
+ ecore_timer_add(0.1, _timeout, current_widget);
+ }
+}
+
static void on_gesture_detected(void *data, Gesture_Info *info)
{
- ERROR("OK");
-/**
switch(info->type)
{
case ONE_FINGER_HOVER:
- // call function from navigator
+ _focus_widget(info);
+ return;
+ case TWO_FINGERS_HOVER:
+ _scroll_up_widget();
+ return;
+ case ONE_FINGER_FLICK_LEFT:
+ _focus_prev();
+ return;
+ case ONE_FINGER_FLICK_RIGHT:
+ _focus_next();
+ return;
+ case ONE_FINGER_FLICK_UP:
+ _value_inc_widget();
+ return;
+ case ONE_FINGER_FLICK_DOWN:
+ _value_dec_widget();
+ return;
+ case ONE_FINGER_SINGLE_TAP:
+ _focus_widget(info);
+ return;
+ case ONE_FINGER_DOUBLE_TAP:
+ _activate_widget();
+ return;
+ case THREE_FINGERS_FLICK_LEFT:
+ // not implemented
+ return;
+ case THREE_FINGERS_FLICK_RIGHT:
+ // not implemented
+ return;
+ case THREE_FINGERS_FLICK_DOWN:
+ // indicator show
+ // not implemented
+ return;
+ case THREE_FINGERS_FLICK_UP:
+ // indicator hide
+ // not implemented
return;
default:
ERROR("Function not implemented for gesture type :%d", info->type);
}
-**/
}
static void on_window_activate(void *data, AtspiAccessible *window)
{
- ERROR("OK: %s", atspi_accessible_get_name(window, NULL));
+ if(top_window == window)
+ return;
+ else
+ top_window = window;
}
void navigator_init(void)
gesture_tracker_register(on_gesture_detected, NULL);
// register on active_window
window_tracker_register(on_window_activate, NULL);
- window_tracker_active_window_request();
+ return;
}
void navigator_shutdown(void)
{