summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinwoo Kim <cinoo.kim@samsung.com>2018-01-22 21:49:06 +0900
committerShinwoo Kim <cinoo.kim@samsung.com>2018-01-22 21:50:02 +0900
commit5e532745a39101a20fa76116c17a4e3919089ce6 (patch)
tree2eb145e658e7a37bfaac6a4e6b6fbaaab9c4b527
parent0fb6f0c120f08a48bcf5b44cb44afb0f4a90fb2e (diff)
Show highlight selected accessibility node
-rw-r--r--atspi_viewer.c93
1 files changed, 53 insertions, 40 deletions
diff --git a/atspi_viewer.c b/atspi_viewer.c
index 1ff3737..0795d05 100644
--- a/atspi_viewer.c
+++ b/atspi_viewer.c
@@ -1,4 +1,5 @@
1/* gcc -o atspi_viewer ./atspi_viewer.c `pkg-config --cflags --libs ecore atspi-2 eldbus gobject-2.0 elementary evas` */ 1/* edje_cc ./atspi_viewer.edc
2 gcc -o atspi_viewer ./atspi_viewer.c `pkg-config --cflags --libs ecore atspi-2 eldbus gobject-2.0 elementary evas` */
2 3
3#include <stdio.h> 4#include <stdio.h>
4#include <Ecore.h> 5#include <Ecore.h>
@@ -15,6 +16,8 @@
15 fprintf(stderr, fmt, ##__VA_ARGS__); \ 16 fprintf(stderr, fmt, ##__VA_ARGS__); \
16 fprintf(stderr, "\n"); 17 fprintf(stderr, "\n");
17 18
19Ecore_Timer *window_timer = NULL;
20
18static Eina_Bool _dbus_set_property_bool(Eldbus_Connection_Type connection_type, 21static Eina_Bool _dbus_set_property_bool(Eldbus_Connection_Type connection_type,
19 const char *bus, 22 const char *bus,
20 const char *path, 23 const char *path,
@@ -90,41 +93,6 @@ Eina_Bool screen_reader_switch_enabled_set(Eina_Bool value)
90 "ScreenReaderEnabled", value); 93 "ScreenReaderEnabled", value);
91} 94}
92 95
93static void
94viewer_information_get(void)
95{
96 AtspiAccessible *desktop = atspi_get_desktop(0);
97 if (!desktop)
98 {
99 ERROR("No desktop!");
100 return;
101 }
102
103 int n_children = atspi_accessible_get_child_count(desktop, NULL);
104 DEBUG("children: %d", n_children);
105
106 int i;
107 for (i = 0; i < n_children; i++)
108 {
109 AtspiAccessible *app = atspi_accessible_get_child_at_index(desktop, i, NULL);
110 if (!app) continue;
111
112 gchar *name = atspi_accessible_get_name(app, NULL);
113 int n_app_children = atspi_accessible_get_child_count(app, NULL);
114 int j;
115 DEBUG("%d. %s", i, name);
116 for (j = 0; j < n_app_children; j++)
117 {
118 AtspiAccessible *win = atspi_accessible_get_child_at_index(app, j, NULL);
119 name = atspi_accessible_get_name(win, NULL);
120 DEBUG(" %s", name);
121 g_object_unref(win);
122 }
123 g_object_unref(app);
124 }
125 g_object_unref(desktop);
126}
127
128static char * 96static char *
129gl_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) 97gl_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
130{ 98{
@@ -241,6 +209,48 @@ char *state_to_char(AtspiStateType state)
241 } 209 }
242} 210}
243 211
212static Eina_Bool
213_window_timer_cb(void *data)
214{
215 Evas_Object *win = data;
216
217 evas_object_hide(win);
218 evas_object_del(win);
219
220 window_timer = NULL;
221 return ECORE_CALLBACK_CANCEL;
222}
223
224static void
225_highlight_show(AtspiRect *rect)
226{
227 Evas_Object *win;
228
229 if (rect->width <= 0 || rect->height <= 0) return;
230
231 win = elm_win_add(NULL, "highlight window", ELM_WIN_DIALOG_BASIC);
232 elm_win_autodel_set(win, EINA_TRUE);
233 elm_win_override_set(win, EINA_TRUE);
234
235 evas_object_resize(win, rect->width, rect->height);
236 evas_object_move(win, rect->x, rect->y);
237 elm_win_alpha_set(win, EINA_TRUE);
238 evas_object_show(win);
239
240 Evas_Object *highlight = evas_object_rectangle_add(evas_object_evas_get(win));
241 evas_object_color_set(highlight, 125, 0, 0, 125);
242 evas_object_show(highlight);
243 elm_win_resize_object_add(win, highlight);
244
245 if (window_timer)
246 {
247 Evas_Object *prev_win = ecore_timer_del(window_timer);
248 evas_object_hide(prev_win);
249 evas_object_del(prev_win);
250 }
251 window_timer = ecore_timer_add(1.0, _window_timer_cb, win);
252}
253
244static void 254static void
245gl4_sel(void *data EINA_UNUSED, Evas_Object *obj, void *event_info) 255gl4_sel(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
246{ 256{
@@ -266,6 +276,8 @@ gl4_sel(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
266 comp = atspi_accessible_get_component_iface(accessible); 276 comp = atspi_accessible_get_component_iface(accessible);
267 rect = atspi_component_get_extents(comp, ATSPI_COORD_TYPE_SCREEN, NULL); 277 rect = atspi_component_get_extents(comp, ATSPI_COORD_TYPE_SCREEN, NULL);
268 278
279 _highlight_show(rect);
280
269 snprintf(txt, sizeof(txt), "<br/>[Extents:Screen]<br/>%d, %d, %d, %d<br/>", rect->x, rect->y, rect->width, rect->height); 281 snprintf(txt, sizeof(txt), "<br/>[Extents:Screen]<br/>%d, %d, %d, %d<br/>", rect->x, rect->y, rect->width, rect->height);
270 eina_strbuf_append_length(buf, txt, strlen(txt)); 282 eina_strbuf_append_length(buf, txt, strlen(txt));
271 free(rect); 283 free(rect);
@@ -457,6 +469,7 @@ ui_create(void)
457 NULL/* func data */); 469 NULL/* func data */);
458 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); 470 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
459 } 471 }
472
460 g_object_unref(desktop); 473 g_object_unref(desktop);
461 474
462 elm_genlist_item_class_free(itc1); 475 elm_genlist_item_class_free(itc1);
@@ -487,14 +500,14 @@ int main(int argc, char **argv)
487 screen_reader_switch_enabled_set(EINA_TRUE); 500 screen_reader_switch_enabled_set(EINA_TRUE);
488 elm_init(argc, argv); 501 elm_init(argc, argv);
489 502
490 //viewer_information_get();
491 ui_create(); 503 ui_create();
492 504
493 elm_run(); 505 elm_run();
506 elm_shutdown();
494 507
495 //screen_reader_switch_enabled_set(EINA_FALSE); 508 screen_reader_switch_enabled_set(EINA_FALSE);
496 //atspi_exit(); 509 atspi_exit();
497 //ecore_shutdown(); 510 ecore_shutdown();
498 511
499 return 0; 512 return 0;
500} 513}