2 #include <atspi/atspi.h>
5 #include "window_tracker.h"
6 #include "keyboard_tracker.h"
7 #include "pivot_chooser.h"
8 #include "structural_navi.h"
9 #include "object_cache.h"
10 #include "flat_navi.h"
11 #include "app_tracker.h"
13 #define QUICKPANEL_DOWN TRUE
14 #define QUICKPANEL_UP FALSE
20 #define GERROR_CHECK(error)\
23 ERROR("Error_log:%s",error->message);\
28 static AtspiAccessible *top_window;
29 static gboolean _window_cache_builded;
30 static FlatNaviContext *context;
33 _current_highlight_object_set(AtspiAccessible *obj)
36 //speak virtually focused widget
39 void test_debug(AtspiAccessible *current_widget)
45 AtspiAccessible *child_iter = NULL;
46 AtspiAccessible *parent = atspi_accessible_get_parent(current_widget, &err);
51 count_child = atspi_accessible_get_child_count(parent, &err);
53 DEBUG("Total childs in parent: %d\n", count_child);
57 for(jdx = 0; jdx < count_child; jdx++)
59 child_iter = atspi_accessible_get_child_at_index(parent, jdx, &err);
62 if(current_widget == child_iter)
64 role = atspi_accessible_get_role_name(parent, &err);
65 DEBUG("Childen found in parent: %s at index: %d\n", role, jdx);
69 role = atspi_accessible_get_role_name(parent, &err);
70 DEBUG("Childen not found in parent: %s at index: %d\n", role, jdx);
77 static void _focus_next(void)
82 ERROR("No navigation context created");
85 obj = flat_navi_context_next(context);
88 obj = flat_navi_context_line_next(context);
89 // try 'cycle' objects in context
92 flat_navi_context_line_first(context);
93 obj = flat_navi_context_first(context);
96 _current_highlight_object_set(obj);
98 DEBUG("Next widget not found. Abort");
101 static void _focus_prev(void)
103 AtspiAccessible *obj;
106 ERROR("No navigation context created");
109 obj = flat_navi_context_prev(context);
113 obj = flat_navi_context_line_prev(context);
115 obj = flat_navi_context_last(context);
117 // try 'cycle' objects in context
120 flat_navi_context_line_last(context);
121 obj = flat_navi_context_last(context);
124 _current_highlight_object_set(obj);
126 DEBUG("Previous widget not found. Abort");
130 _on_cache_builded(void *data)
132 DEBUG("Cache building");
133 _window_cache_builded = TRUE;
134 AtspiAccessible *pivot = NULL;
137 pivot = flat_navi_context_current_get(context);
138 flat_navi_context_free(context);
140 context = flat_navi_context_create(top_window);
142 // try to set previous object in new context
143 if (flat_navi_context_current_set(context, pivot))
144 _current_highlight_object_set(pivot);
146 _current_highlight_object_set(flat_navi_context_current_get(context));
147 DEBUG("Cache building finished");
151 _view_content_changed(AppTrackerEventType type, void *user_data)
153 DEBUG("View content changed");
154 _window_cache_builded = FALSE;
156 object_cache_build_async(top_window, 5, _on_cache_builded, NULL);
159 static void on_window_activate(void *data, AtspiAccessible *window)
162 DEBUG("... on window activate ...");
164 app_tracker_callback_unregister(top_window, APP_TRACKER_EVENT_VIEW_CHANGED, _view_content_changed, NULL);
168 app_tracker_callback_register(window, APP_TRACKER_EVENT_VIEW_CHANGED, _view_content_changed, NULL);
169 name = atspi_accessible_get_name(window, NULL);
170 DEBUG("Window name: %s", name);
171 _window_cache_builded = FALSE;
172 object_cache_build_async(window, 5, _on_cache_builded, NULL);
177 ERROR("No top window found!");
182 void kb_tracker (void *data, Key k)
193 DEBUG("Key %d not supported \n", k);
197 void navigator_init(void)
199 window_tracker_init();
200 window_tracker_register(on_window_activate, NULL);
201 window_tracker_active_window_request();
203 keyboard_tracker_init();
204 keyboard_tracker_register(kb_tracker, NULL);
207 void navigator_shutdown(void)
211 flat_navi_context_free(context);
214 object_cache_shutdown();
215 app_tracker_shutdown();
216 window_tracker_shutdown();
217 keyboard_tracker_shutdown();