#include "navigator.h"
#include "gesture_tracker.h"
#include "window_tracker.h"
+#include "border.h"
+
+static AtspiAccessible *current_obj;
+static AtspiAccessible *top_window;
+
+static Eina_List *focusable_obj_list;
+static Eina_Bool is_first = EINA_FALSE;
+static void _get_focusable_fillers_list(AtspiAccessible* obj);
+
+static void _scroll_action(void) // NOT YET IMPLEMENTED
+{
+
+}
+
+static void _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)
+ {
+ ERROR("Focus was changed\n");
+ current_obj = target_widget;
+ border_set(current_obj);
+ }
+ }
+}
+
+static AtspiAccessible *_focused_next_widget(void)
+{
+ AtspiAccessible *current_widget = NULL;
+ AtspiComponent *focus_component = NULL;
+ GArray *relations = NULL;
+ AtspiRelation *relation = NULL;
+ AtspiRelationType type;
+ int i;
+
+ if(current_obj)
+ current_widget = current_obj;
+ else
+ return NULL;
+
+ 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)
+ {
+ ERROR("Focus component is not null\n");
+ if (atspi_component_grab_focus(focus_component, NULL) == TRUE)
+ ERROR("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;
+
+ if(current_obj)
+ current_widget = current_obj;
+ else
+ return NULL;
+
+ 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)
+ ERROR("Focus was changed\n");
+
+ }
+
+ return current_widget;
+}
+
+static void _focus_next(void)
+{
+ AtspiAccessible *current_widget = NULL;
+
+ current_obj = _focused_next_widget();
+ if(current_obj)
+ border_set(current_obj);
+}
+
+static void _focus_prev(void)
+{
+ AtspiAccessible *current_widget = NULL;
+
+ current_obj = _focused_prev_widget();
+ if(current_obj)
+ border_set(current_obj);
+}
+
+static void _value_inc_widget(void)
+{
+ AtspiAccessible* current_widget = NULL;
+ if(current_obj)
+ current_widget = current_obj;
+ else
+ return;
+
+ 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 = NULL;
+ if(current_obj)
+ current_widget = current_obj;
+ else
+ return;
+
+ 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);
+ ERROR("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;
+
+ if(current_obj)
+ current_widget = current_obj;
+ else
+ return;
+
+ gchar *roleName;
+ gchar *actionName;
+ roleName = atspi_accessible_get_role_name(current_widget, NULL);
+ ERROR("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);
+ ERROR("Number of available action = %d\n", number);
+/*
+ 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;
+
+ if(current_obj)
+ current_widget = current_obj;
+ else
+ return;
+
+ gchar *roleName;
+ gchar *actionName;
+ roleName = atspi_accessible_get_role_name(current_widget, NULL);
+ ERROR("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);
+ ERROR("Number of available action = %d\n", number);
+
+ GArray *array = atspi_accessible_get_interfaces(current_widget);
+ ERROR("TAB LEN = %d \n", array->len);
+
+ for (k=0; k < array->len; k++)
+ ERROR("Interface = %s\n", g_array_index( array, gchar *, k ));
+
+ for (i=0; i<number; i++)
+ {
+ actionName = atspi_action_get_name(action, i, NULL);
+ ERROR("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 _get_first_focusable_widget(AtspiAccessible* obj)
+{
+ AtspiAccessible *current_widget = NULL;
+ AtspiStateSet *state_set = NULL;
+ AtspiComponent *focus_component = NULL;
+ int i;
+
+ gint nChild = NULL;
+ gchar *winName = NULL;
+ gchar *widgetName = NULL;
+ gchar *roleName = NULL;
+
+ if (obj == NULL)
+ {
+ ERROR("No window on top");
+ return;
+ }
+
+ winName = atspi_accessible_get_name(obj, NULL);
+ ERROR("Win name: %s\n", winName);
+
+ nChild = atspi_accessible_get_child_count(obj, NULL);
+ ERROR("Child count of top win: %d\n", nChild);
+
+ for (i = 0; i < nChild; i++)
+ {
+ current_widget = atspi_accessible_get_child_at_index(obj, i, NULL);
+ widgetName = atspi_accessible_get_name(current_widget, NULL);
+ ERROR("Widget name: %s\n", widgetName);
+
+ roleName = atspi_accessible_get_role_name(current_widget, NULL);
+ ERROR("Widget role: %s\n", roleName);
+
+ state_set = atspi_accessible_get_state_set(current_widget);
+ if (ATSPI_IS_STATE_SET(state_set))
+ {
+
+ if (atspi_state_set_contains(ATSPI_STATE_SET(state_set),ATSPI_STATE_FOCUSABLE))
+ {
+ ERROR("FOCUSABLE widget name: %s \n", widgetName);
+
+ current_obj = current_widget;
+
+ focus_component = atspi_accessible_get_component(current_widget);
+ if (focus_component != NULL)
+ {
+ ERROR("Focus component is not null\n");
+ if (atspi_component_grab_focus(focus_component, NULL) == TRUE)
+ ERROR("Focus was changed\n");
+ return;
+ }
+ }
+ }
+ }
+
+ ERROR("Not found any focusable widget");
+
+ return;
+}
+
+
static void on_window_activate(void *data, AtspiAccessible *window)
{
- ERROR("OK: %s", atspi_accessible_get_name(window, NULL));
+ top_window = window;
+ if(top_window)
+ {
+ ERROR("Window name: %s", atspi_accessible_get_name(window, NULL));
+ _get_first_focusable_widget(top_window);
+ }
+ else
+ top_window = NULL;
}
void navigator_init(void)
// register on active_window
window_tracker_register(on_window_activate, NULL);
window_tracker_active_window_request();
+ border_init();
}
void navigator_shutdown(void)
{