summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2014-02-07 08:53:24 -0800
committerU. Artie Eoff <ullysses.a.eoff@intel.com>2014-02-07 10:49:10 -0800
commit803553c253bc4ee140a4b447c29ffe35c31288ab (patch)
treeb1bbf0e0ab24bee62a0d9af672cd338036bd269c
parentcd9507ed6004044c57f164b151ea6bf43d25da2f (diff)
Revert "atspi: event broadcast added. Orca screen reader now ables to read UI."
Breaks elementary applications compilation See https://phab.enlightenment.org/T917 This reverts commit 71cd5a1a077807bc32a67d309fba9e1474fffa4d.
-rw-r--r--src/lib/elm_atspi_bridge.c726
-rw-r--r--src/lib/elm_atspi_object.c971
-rw-r--r--src/lib/elm_atspi_object_common.h23
-rw-r--r--src/lib/elm_atspi_object_eo.h90
-rw-r--r--src/lib/elm_atspi_object_legacy.h3
-rw-r--r--src/lib/elm_widget.c16
6 files changed, 468 insertions, 1361 deletions
diff --git a/src/lib/elm_atspi_bridge.c b/src/lib/elm_atspi_bridge.c
index cbede6cf4..5963e6a87 100644
--- a/src/lib/elm_atspi_bridge.c
+++ b/src/lib/elm_atspi_bridge.c
@@ -5,7 +5,6 @@
5#include <stdint.h> 5#include <stdint.h>
6#include <Elementary.h> 6#include <Elementary.h>
7#include "elm_priv.h" 7#include "elm_priv.h"
8#include <assert.h>
9 8
10#include "atspi/atspi-constants.h" 9#include "atspi/atspi-constants.h"
11 10
@@ -15,7 +14,6 @@
15#define A11Y_DBUS_NAME "org.a11y.Bus" 14#define A11Y_DBUS_NAME "org.a11y.Bus"
16#define A11Y_DBUS_PATH "/org/a11y/bus" 15#define A11Y_DBUS_PATH "/org/a11y/bus"
17#define A11Y_DBUS_INTERFACE "org.a11y.Bus" 16#define A11Y_DBUS_INTERFACE "org.a11y.Bus"
18#define ATSPI_DBUS_INTERFACE_EVENT_WINDOW "org.a11y.atspi.Event.Window"
19 17
20#define CACHE_ITEM_SIGNATURE "((so)(so)(so)a(so)assusau)" 18#define CACHE_ITEM_SIGNATURE "((so)(so)(so)a(so)assusau)"
21#define CACHE_INTERFACE_PATH "/org/a11y/atspi/cache" 19#define CACHE_INTERFACE_PATH "/org/a11y/atspi/cache"
@@ -25,137 +23,24 @@
25#define ELM_ACCESS_OBJECT_REFERENCE_TEMPLATE ELM_ACCESS_OBJECT_PATH_PREFIX "%llu" 23#define ELM_ACCESS_OBJECT_REFERENCE_TEMPLATE ELM_ACCESS_OBJECT_PATH_PREFIX "%llu"
26 24
27static int _init_count = 0; 25static int _init_count = 0;
28
29static Eldbus_Connection *_a11y_bus = NULL; 26static Eldbus_Connection *_a11y_bus = NULL;
30static Elm_Atspi_Object *_root; 27static Elm_Atspi_Object *_root;
31static Eina_Hash *_cache; 28static Eina_Hash *_cache;
32static Eldbus_Service_Interface *_cache_interface = NULL; 29static Eldbus_Service_Interface *_cache_interface = NULL;
33static Eldbus_Signal_Handler *_register_hdl;
34static Eldbus_Signal_Handler *_unregister_hdl;
35static unsigned short _object_property_broadcast_mask;
36static unsigned short _object_children_broadcast_mask;
37static unsigned long long _object_state_broadcast_mask;
38static unsigned long long _window_signal_broadcast_mask;
39
40static void _cache_update(void);
41static Elm_Atspi_Object * _access_object_from_path(const char *path); 30static Elm_Atspi_Object * _access_object_from_path(const char *path);
42static char * _path_from_access_object(Elm_Atspi_Object *eo); 31static char * _path_from_access_object(Elm_Atspi_Object *eo);
43static void object_append_reference(Eldbus_Message_Iter *iter, Elm_Atspi_Object *obj); 32static void object_append_reference(Eldbus_Message_Iter *iter, Elm_Atspi_Object *obj);
44static void object_append_desktop_reference(Eldbus_Message_Iter *iter); 33static void object_append_desktop_reference(Eldbus_Message_Iter *iter);
45static const Eldbus_Service_Interface_Desc accessible_iface_desc; 34static const Eldbus_Service_Interface_Desc accessible_iface_desc;
46static void _cache_object_register(Elm_Atspi_Object *node, Eina_Bool rec);
47
48
49enum _Atspi_Object_Child_Event_Type
50{
51 ATSPI_OBJECT_CHILD_ADDED = 0,
52 ATSPI_OBJECT_CHILD_REMOVED
53};
54
55enum _Atspi_Object_Property
56{
57 ATSPI_OBJECT_PROPERTY_NAME = 0,
58 ATSPI_OBJECT_PROPERTY_DESCRIPTION,
59 ATSPI_OBJECT_PROPERTY_VALUE,
60 ATSPI_OBJECT_PROPERTY_ROLE,
61 ATSPI_OBJECT_PROPERTY_PARENT,
62};
63
64enum _Atspi_Object_Signals {
65 ATSPI_OBJECT_EVENT_PROPERTY_CHANGED,
66 ATSPI_OBJECT_EVENT_BOUNDS_CHANGED,
67 ATSPI_OBJECT_EVENT_LINK_SELECTED,
68 ATSPI_OBJECT_EVENT_STATE_CHANGED,
69 ATSPI_OBJECT_EVENT_CHILDREN_CHANGED,
70 ATSPI_OBJECT_EVENT_VISIBLE_DATA_CHANGED,
71 ATSPI_OBJECT_EVENT_SELECTION_CHANGED,
72 ATSPI_OBJECT_EVENT_MODEL_CHANGED,
73 ATSPI_OBJECT_EVENT_ACTIVE_DESCENDANT_CHANGED,
74 ATSPI_OBJECT_EVENT_ROW_INSERTED,
75 ATSPI_OBJECT_EVENT_ROW_REORDERED,
76 ATSPI_OBJECT_EVENT_ROW_DELETED,
77 ATSPI_OBJECT_EVENT_COLUMN_INSERTED,
78 ATSPI_OBJECT_EVENT_COLUMN_REORDERED,
79 ATSPI_OBJECT_EVENT_COLUMN_DELETED,
80 ATSPI_OBJECT_EVENT_TEXT_BOUNDS_CHANGED,
81 ATSPI_OBJECT_EVENT_TEXT_SELECTION_CHANGED,
82 ATSPI_OBJECT_EVENT_TEXT_CHANGED,
83 ATSPI_OBJECT_EVENT_TEXT_ATTRIBUTES_CHANGED,
84 ATSPI_OBJECT_EVENT_TEXT_CARET_MOVED,
85 ATSPI_OBJECT_EVENT_ATTRIBUTES_CHANGED,
86};
87 35
88enum _Atspi_Window_Signals 36enum
89{ 37{
90 ATSPI_WINDOW_EVENT_PROPERTY_CHANGE, 38 ADD_ACCESSIBLE = 0,
91 ATSPI_WINDOW_EVENT_MINIMIZE, 39 REMOVE_ACCESSIBLE
92 ATSPI_WINDOW_EVENT_MAXIMIZE,
93 ATSPI_WINDOW_EVENT_RESTORE,
94 ATSPI_WINDOW_EVENT_CLOSE,
95 ATSPI_WINDOW_EVENT_CREATE,
96 ATSPI_WINDOW_EVENT_REPARENT,
97 ATSPI_WINDOW_EVENT_DESKTOPCREATE,
98 ATSPI_WINDOW_EVENT_DESKTOPDESTROY,
99 ATSPI_WINDOW_EVENT_DESTROY,
100 ATSPI_WINDOW_EVENT_ACTIVATE,
101 ATSPI_WINDOW_EVENT_DEACTIVATE,
102 ATSPI_WINDOW_EVENT_RAISE,
103 ATSPI_WINDOW_EVENT_LOWER,
104 ATSPI_WINDOW_EVENT_MOVE,
105 ATSPI_WINDOW_EVENT_RESIZE,
106 ATSPI_WINDOW_EVENT_SHADE,
107 ATSPI_WINDOW_EVENT_UUSHADE,
108 ATSPI_WINDOW_EVENT_RESTYLE,
109};
110
111static const Eldbus_Signal _event_obj_signals[] = {
112 [ATSPI_OBJECT_EVENT_PROPERTY_CHANGED] = {"PropertyChange", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
113 [ATSPI_OBJECT_EVENT_BOUNDS_CHANGED] = {"BoundsChange", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
114 [ATSPI_OBJECT_EVENT_LINK_SELECTED] = {"LinkSelected", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
115 [ATSPI_OBJECT_EVENT_STATE_CHANGED] = {"StateChanged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
116 [ATSPI_OBJECT_EVENT_CHILDREN_CHANGED] = {"ChildrenChanged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
117 [ATSPI_OBJECT_EVENT_VISIBLE_DATA_CHANGED] = {"VisibleDataChanged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
118 [ATSPI_OBJECT_EVENT_SELECTION_CHANGED] = {"SelectionChanged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
119 [ATSPI_OBJECT_EVENT_MODEL_CHANGED] = {"ModelChanged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
120 [ATSPI_OBJECT_EVENT_ACTIVE_DESCENDANT_CHANGED] = {"ActiveDescendantsChanged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
121 [ATSPI_OBJECT_EVENT_ROW_INSERTED] = {"RowInserted", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
122 [ATSPI_OBJECT_EVENT_ROW_REORDERED] = {"RowReordered", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
123 [ATSPI_OBJECT_EVENT_ROW_DELETED] = {"RowDeleted", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
124 [ATSPI_OBJECT_EVENT_COLUMN_INSERTED] = {"ColumnInserted", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
125 [ATSPI_OBJECT_EVENT_COLUMN_REORDERED] = {"ColumnReordered", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
126 [ATSPI_OBJECT_EVENT_COLUMN_DELETED] = {"ColumnDeleted", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
127 [ATSPI_OBJECT_EVENT_TEXT_BOUNDS_CHANGED] = {"TextBoundsChanged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
128 [ATSPI_OBJECT_EVENT_TEXT_SELECTION_CHANGED] = {"SelectionChanged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
129 [ATSPI_OBJECT_EVENT_TEXT_CHANGED] = {"TextChaged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
130 [ATSPI_OBJECT_EVENT_TEXT_ATTRIBUTES_CHANGED] = {"TextAttributesChanged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
131 [ATSPI_OBJECT_EVENT_TEXT_CARET_MOVED] = {"TextCaretMoved", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
132 [ATSPI_OBJECT_EVENT_ATTRIBUTES_CHANGED] = {"AttributesChanged", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
133};
134
135static const Eldbus_Signal _window_obj_signals[] = {
136 [ATSPI_WINDOW_EVENT_PROPERTY_CHANGE] = {"PropertyChange", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
137 [ATSPI_WINDOW_EVENT_MINIMIZE] = {"Minimize", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
138 [ATSPI_WINDOW_EVENT_MAXIMIZE] = {"Maximize", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
139 [ATSPI_WINDOW_EVENT_RESTORE] = {"Restore", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
140 [ATSPI_WINDOW_EVENT_CLOSE] = {"Close", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
141 [ATSPI_WINDOW_EVENT_CREATE] = {"Create", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
142 [ATSPI_WINDOW_EVENT_REPARENT] = {"Reparent", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
143 [ATSPI_WINDOW_EVENT_DESKTOPCREATE] = {"DesktopCreate", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
144 [ATSPI_WINDOW_EVENT_DESKTOPDESTROY] = {"DesktopDestroy", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
145 [ATSPI_WINDOW_EVENT_DESTROY] = {"Destroy", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
146 [ATSPI_WINDOW_EVENT_ACTIVATE] = {"Activate", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
147 [ATSPI_WINDOW_EVENT_DEACTIVATE] = {"Deactivate", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
148 [ATSPI_WINDOW_EVENT_RAISE] = {"Raise", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
149 [ATSPI_WINDOW_EVENT_LOWER] = {"Lower", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
150 [ATSPI_WINDOW_EVENT_MOVE] = {"Move", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
151 [ATSPI_WINDOW_EVENT_RESIZE] = {"Resize", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
152 [ATSPI_WINDOW_EVENT_SHADE] = {"Shade", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
153 [ATSPI_WINDOW_EVENT_UUSHADE] = {"uUshade", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
154 [ATSPI_WINDOW_EVENT_RESTYLE] = {"Restyle", ELDBUS_ARGS({"siiv(so)", NULL}), 0},
155}; 40};
156 41
157static Eldbus_Message * 42static Eldbus_Message *
158_accessible_get_role(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg) 43_accessible_get_role(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
159{ 44{
160 const char *obj_path = eldbus_service_object_path_get(iface); 45 const char *obj_path = eldbus_service_object_path_get(iface);
161 Elm_Atspi_Object *obj = _access_object_from_path(obj_path); 46 Elm_Atspi_Object *obj = _access_object_from_path(obj_path);
@@ -163,77 +48,64 @@ _accessible_get_role(const Eldbus_Service_Interface *iface, const Eldbus_Message
163 48
164 eo_do(obj, elm_atspi_obj_role_get(&role)); 49 eo_do(obj, elm_atspi_obj_role_get(&role));
165 Eldbus_Message *ret = eldbus_message_method_return_new(msg); 50 Eldbus_Message *ret = eldbus_message_method_return_new(msg);
166 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
167 eldbus_message_arguments_append(ret, "u", role); 51 eldbus_message_arguments_append(ret, "u", role);
168 return ret; 52 return ret;
169} 53}
170 54
171static Eldbus_Message * 55static Eldbus_Message *
172_accessible_get_role_name(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg) 56_accessible_get_role_name(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
173{ 57{
174 const char *role_name, *obj_path = eldbus_service_object_path_get(iface); 58 const char *role_name, *obj_path = eldbus_service_object_path_get(iface);
175 Elm_Atspi_Object *obj = _access_object_from_path(obj_path); 59 Elm_Atspi_Object *obj = _access_object_from_path(obj_path);
176 60
177 eo_do(obj, elm_atspi_obj_role_name_get(&role_name)); 61 eo_do(obj, elm_atspi_obj_role_name_get(&role_name));
178 Eldbus_Message *ret = eldbus_message_method_return_new(msg); 62 Eldbus_Message *ret = eldbus_message_method_return_new(msg);
179 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
180 eldbus_message_arguments_append(ret, "s", role_name); 63 eldbus_message_arguments_append(ret, "s", role_name);
181 64
182 return ret; 65 return ret;
183} 66}
184 67
185static Eldbus_Message * 68static Eldbus_Message *
186_accessible_get_localized_role_name(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg) 69_accessible_get_localized_role_name(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
187{ 70{
188 const char *l_role_name, *obj_path = eldbus_service_object_path_get(iface); 71 const char *l_role_name, *obj_path = eldbus_service_object_path_get(iface);
189 Elm_Atspi_Object *obj = _access_object_from_path(obj_path); 72 Elm_Atspi_Object *obj = _access_object_from_path(obj_path);
190 73
191 eo_do(obj, elm_atspi_obj_localized_role_name_get(&l_role_name)); 74 eo_do(obj, elm_atspi_obj_localized_role_name_get(&l_role_name));
192 Eldbus_Message *ret = eldbus_message_method_return_new(msg); 75 Eldbus_Message *ret = eldbus_message_method_return_new(msg);
193 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
194 eldbus_message_arguments_append(ret, "s", l_role_name); 76 eldbus_message_arguments_append(ret, "s", l_role_name);
195 77
196 return ret; 78 return ret;
197} 79}
198 80
199static Eldbus_Message * 81static Eldbus_Message *
200_accessible_get_children(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg) 82_accessible_get_children(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
201{ 83{
202 const char *obj_path = eldbus_service_object_path_get(iface); 84 const char *obj_path = eldbus_service_object_path_get(iface);
203 Elm_Atspi_Object *obj = _access_object_from_path(obj_path); 85 Elm_Atspi_Object *obj = _access_object_from_path(obj_path);
204 Eina_List *children_list = NULL, *l; 86 Eina_List *children_list = NULL, *l;
205 Eldbus_Message *ret; 87 Eldbus_Message *ret;
206
207 Eldbus_Message_Iter *iter, *iter_array; 88 Eldbus_Message_Iter *iter, *iter_array;
208 Elm_Atspi_Object *children; 89 Elm_Atspi_Object *children;
209 90
210 eo_do(obj, elm_atspi_obj_children_get(&children_list)); 91 eo_do(obj, elm_atspi_obj_children_get(&children_list));
211 92
212 ret = eldbus_message_method_return_new(msg); 93 ret = eldbus_message_method_return_new(msg);
213 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
214
215 iter = eldbus_message_iter_get(ret); 94 iter = eldbus_message_iter_get(ret);
216 iter_array = eldbus_message_iter_container_new(iter, 'a', "(so)"); 95 iter_array = eldbus_message_iter_container_new(iter, 'a', "(so)");
217 EINA_SAFETY_ON_NULL_GOTO(iter_array, fail);
218 96
219 EINA_LIST_FOREACH(children_list, l, children) 97 EINA_LIST_FOREACH(children_list, l, children)
220 object_append_reference(iter_array, children); 98 object_append_reference(iter_array, children);
221 99
222 eldbus_message_iter_container_close(iter, iter_array); 100 eldbus_message_iter_container_close(iter, iter_array);
223 eina_list_free(children_list); 101 eina_list_free(children_list);
224
225 return ret; 102 return ret;
226
227fail:
228 if (ret) eldbus_message_unref(ret);
229 return NULL;
230} 103}
231 104
232static Eldbus_Message * 105static Eldbus_Message *
233_accessible_get_application(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg) 106_accessible_get_application(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
234{ 107{
235 Eldbus_Message *ret = eldbus_message_method_return_new(msg); 108 Eldbus_Message *ret = eldbus_message_method_return_new(msg);
236 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
237 Eldbus_Message_Iter *iter = eldbus_message_iter_get(ret); 109 Eldbus_Message_Iter *iter = eldbus_message_iter_get(ret);
238 object_append_reference(iter, _root); 110 object_append_reference(iter, _root);
239 111
@@ -241,42 +113,17 @@ _accessible_get_application(const Eldbus_Service_Interface *iface EINA_UNUSED, c
241} 113}
242 114
243static Eldbus_Message * 115static Eldbus_Message *
244_accessible_get_state(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg) 116_accessible_get_state(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
245{ 117{
246 Eldbus_Message *ret; 118 Eldbus_Message *ret = eldbus_message_method_return_new(msg);
247 Eldbus_Message_Iter *iter, *iter_array; 119 Eldbus_Message_Iter *iter = eldbus_message_iter_get(ret);
248 Elm_Atspi_State states; 120 Eldbus_Message_Iter *iter_array;
249
250 const char *obj_path = eldbus_service_object_path_get(iface);
251 Elm_Atspi_Object *obj = _access_object_from_path(obj_path);
252
253 if (!obj)
254 {
255 ERR("Atspi Object %s not found in cache!", obj_path);
256 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid object path.");
257 }
258
259 ret = eldbus_message_method_return_new(msg);
260 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
261 121
262 iter = eldbus_message_iter_get(ret);
263 iter_array = eldbus_message_iter_container_new(iter, 'a', "u"); 122 iter_array = eldbus_message_iter_container_new(iter, 'a', "u");
264 EINA_SAFETY_ON_NULL_GOTO(iter_array, fail); 123 /* TODO: states are not implemented yet*/
265
266 eo_do(obj, elm_atspi_obj_state_get(&states));
267
268 unsigned int s1 = states & 0xFFFFFFFF;
269 unsigned int s2 = (states >> 32) & 0xFFFFFFFF;
270
271 eldbus_message_iter_basic_append(iter_array, 'u', s1);
272 eldbus_message_iter_basic_append(iter_array, 'u', s2);
273 eldbus_message_iter_container_close(iter, iter_array); 124 eldbus_message_iter_container_close(iter, iter_array);
274 125
275 return ret; 126 return ret;
276
277fail:
278 if (ret) eldbus_message_unref(ret);
279 return NULL;
280} 127}
281 128
282static Eldbus_Message * 129static Eldbus_Message *
@@ -284,12 +131,9 @@ _accessible_get_index_in_parent(const Eldbus_Service_Interface *iface EINA_UNUSE
284{ 131{
285 const char *obj_path = eldbus_service_object_path_get(iface); 132 const char *obj_path = eldbus_service_object_path_get(iface);
286 Elm_Atspi_Object *obj = _access_object_from_path(obj_path); 133 Elm_Atspi_Object *obj = _access_object_from_path(obj_path);
287 Eldbus_Message *ret; 134 Eldbus_Message *ret = eldbus_message_method_return_new(msg);
288 int idx; 135 int idx;
289 136
290 ret = eldbus_message_method_return_new(msg);
291 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
292
293 eo_do(obj, elm_atspi_obj_index_in_parent_get(&idx)); 137 eo_do(obj, elm_atspi_obj_index_in_parent_get(&idx));
294 eldbus_message_arguments_append(ret, "i", idx); 138 eldbus_message_arguments_append(ret, "i", idx);
295 139
@@ -310,8 +154,6 @@ _accessible_child_at_index(const Eldbus_Service_Interface *iface EINA_UNUSED, co
310 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type."); 154 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
311 155
312 ret = eldbus_message_method_return_new(msg); 156 ret = eldbus_message_method_return_new(msg);
313 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
314
315 iter = eldbus_message_iter_get(ret); 157 iter = eldbus_message_iter_get(ret);
316 eo_do(obj, elm_atspi_obj_child_at_index_get(idx, &child)); 158 eo_do(obj, elm_atspi_obj_child_at_index_get(idx, &child));
317 object_append_reference(iter, child); 159 object_append_reference(iter, child);
@@ -319,17 +161,11 @@ _accessible_child_at_index(const Eldbus_Service_Interface *iface EINA_UNUSED, co
319 return ret; 161 return ret;
320} 162}
321 163
322static Eldbus_Message *
323_accessible_get_relation_set(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
324{
325 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.NotSupported", "Relation states not implemented.");
326}
327
328static const Eldbus_Method accessible_methods[] = { 164static const Eldbus_Method accessible_methods[] = {
329 { "GetChildAtIndex", ELDBUS_ARGS({"i", "index"}), ELDBUS_ARGS({"(so)", "Accessible"}), _accessible_child_at_index, 0 }, 165 { "GetChildAtIndex", ELDBUS_ARGS({"i", "index"}), ELDBUS_ARGS({"(so)", "Accessible"}), _accessible_child_at_index, 0 },
330 { "GetChildren", NULL, ELDBUS_ARGS({"a(so)", "children"}), _accessible_get_children, 0 }, 166 { "GetChildren", NULL, ELDBUS_ARGS({"a(so)", "children"}), _accessible_get_children, 0 },
331 { "GetIndexInParent", NULL, ELDBUS_ARGS({"i", "index"}), _accessible_get_index_in_parent, 0 }, 167 { "GetIndexInParent", NULL, ELDBUS_ARGS({"i", "index"}), _accessible_get_index_in_parent, 0 },
332 { "GetRelationSet", NULL, ELDBUS_ARGS({"a(ua(so))", NULL}), _accessible_get_relation_set, 0 }, 168 { "GetRelationSet", NULL, ELDBUS_ARGS({"a(ua(so))", NULL}), _accessible_get_state, 0 },
333 { "GetRole", NULL, ELDBUS_ARGS({"u", "Role"}), _accessible_get_role, 0 }, 169 { "GetRole", NULL, ELDBUS_ARGS({"u", "Role"}), _accessible_get_role, 0 },
334 { "GetRoleName", NULL, ELDBUS_ARGS({"s", "Name"}), _accessible_get_role_name, 0 }, 170 { "GetRoleName", NULL, ELDBUS_ARGS({"s", "Name"}), _accessible_get_role_name, 0 },
335 { "GetLocalizedRoleName", NULL, ELDBUS_ARGS({"s", "LocalizedName"}), _accessible_get_localized_role_name, 0}, 171 { "GetLocalizedRoleName", NULL, ELDBUS_ARGS({"s", "LocalizedName"}), _accessible_get_localized_role_name, 0},
@@ -380,7 +216,9 @@ _accessible_property_get(const Eldbus_Service_Interface *interface, const char *
380 Eldbus_Message **error EINA_UNUSED) 216 Eldbus_Message **error EINA_UNUSED)
381{ 217{
382 const char *ret, *obj_path = eldbus_service_object_path_get(interface); 218 const char *ret, *obj_path = eldbus_service_object_path_get(interface);
219
383 Elm_Atspi_Object *ret_obj = NULL, *obj = _access_object_from_path(obj_path); 220 Elm_Atspi_Object *ret_obj = NULL, *obj = _access_object_from_path(obj_path);
221
384 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE); 222 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
385 223
386 if (!strcmp(property, "Name")) 224 if (!strcmp(property, "Name"))
@@ -422,10 +260,10 @@ _accessible_property_get(const Eldbus_Service_Interface *interface, const char *
422} 260}
423 261
424static const Eldbus_Property accessible_properties[] = { 262static const Eldbus_Property accessible_properties[] = {
425 { "Name", "s", _accessible_property_get, NULL, 0 }, 263 { "Name", "s", NULL, NULL, 0 },
426 { "Description", "s", _accessible_property_get, NULL, 0 }, 264 { "Description", "s", NULL, NULL, 0 },
427 { "Parent", "(so)", _accessible_property_get, NULL, 0 }, 265 { "Parent", "(so)", NULL, NULL, 0 },
428 { "ChildCount", "i", _accessible_property_get, NULL, 0 }, 266 { "ChildCount", "i", NULL, NULL, 0 },
429 { NULL, NULL, NULL, NULL, 0 } 267 { NULL, NULL, NULL, NULL, 0 }
430}; 268};
431 269
@@ -433,19 +271,10 @@ static const Eldbus_Service_Interface_Desc accessible_iface_desc = {
433 ATSPI_DBUS_INTERFACE_ACCESSIBLE, accessible_methods, NULL, accessible_properties, _accessible_property_get, NULL 271 ATSPI_DBUS_INTERFACE_ACCESSIBLE, accessible_methods, NULL, accessible_properties, _accessible_property_get, NULL
434}; 272};
435 273
436static const Eldbus_Service_Interface_Desc event_iface_desc = {
437 ATSPI_DBUS_INTERFACE_EVENT_OBJECT, NULL, _event_obj_signals, NULL, NULL, NULL
438};
439
440static const Eldbus_Service_Interface_Desc window_iface_desc = {
441 ATSPI_DBUS_INTERFACE_EVENT_WINDOW, NULL, _window_obj_signals, NULL, NULL, NULL
442};
443
444static void 274static void
445object_append_reference(Eldbus_Message_Iter *iter, Elm_Atspi_Object *obj) 275object_append_reference(Eldbus_Message_Iter *iter, Elm_Atspi_Object *obj){
446{ 276
447 Eldbus_Message_Iter *iter_struct = eldbus_message_iter_container_new(iter, 'r', NULL); 277 Eldbus_Message_Iter *iter_struct = eldbus_message_iter_container_new(iter, 'r', NULL);
448 EINA_SAFETY_ON_NULL_RETURN(iter);
449 char *path = _path_from_access_object(obj); 278 char *path = _path_from_access_object(obj);
450 eldbus_message_iter_basic_append(iter_struct, 's', eldbus_connection_unique_name_get(_a11y_bus)); 279 eldbus_message_iter_basic_append(iter_struct, 's', eldbus_connection_unique_name_get(_a11y_bus));
451 eldbus_message_iter_basic_append(iter_struct, 'o', path); 280 eldbus_message_iter_basic_append(iter_struct, 'o', path);
@@ -454,10 +283,9 @@ object_append_reference(Eldbus_Message_Iter *iter, Elm_Atspi_Object *obj)
454} 283}
455 284
456static void 285static void
457object_append_desktop_reference(Eldbus_Message_Iter *iter) 286object_append_desktop_reference(Eldbus_Message_Iter *iter){
458{ 287
459 Eldbus_Message_Iter *iter_struct = eldbus_message_iter_container_new(iter, 'r', NULL); 288 Eldbus_Message_Iter *iter_struct = eldbus_message_iter_container_new(iter, 'r', NULL);
460 EINA_SAFETY_ON_NULL_RETURN(iter);
461 289
462 eldbus_message_iter_basic_append(iter_struct, 's', ATSPI_DBUS_NAME_REGISTRY); 290 eldbus_message_iter_basic_append(iter_struct, 's', ATSPI_DBUS_NAME_REGISTRY);
463 eldbus_message_iter_basic_append(iter_struct, 'o', ATSPI_DBUS_PATH_ROOT); 291 eldbus_message_iter_basic_append(iter_struct, 'o', ATSPI_DBUS_PATH_ROOT);
@@ -467,19 +295,17 @@ object_append_desktop_reference(Eldbus_Message_Iter *iter)
467static Eina_Bool 295static Eina_Bool
468_append_item_fn(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata) 296_append_item_fn(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
469{ 297{
298
470 if (!eo_ref_get(data) || eo_destructed_is(data)) 299 if (!eo_ref_get(data) || eo_destructed_is(data))
471 return EINA_TRUE; 300 return EINA_TRUE;
472 301
473 Eldbus_Message_Iter *iter_struct, *iter_sub_array; 302 Eldbus_Message_Iter *iter_struct, *iter_sub_array;
474 Eldbus_Message_Iter *iter_array = fdata; 303 Eldbus_Message_Iter *iter_array = fdata;
475 Elm_Atspi_State states;
476 AtspiRole role;
477 304
305 AtspiRole role;
478 eo_do(data, elm_atspi_obj_role_get(&role)); 306 eo_do(data, elm_atspi_obj_role_get(&role));
479 307
480 iter_struct = eldbus_message_iter_container_new(iter_array, 'r', NULL); 308 iter_struct = eldbus_message_iter_container_new(iter_array, 'r', NULL);
481 EINA_SAFETY_ON_NULL_RETURN_VAL(iter_struct, EINA_TRUE);
482
483 /* Marshall object path */ 309 /* Marshall object path */
484 object_append_reference(iter_struct, data); 310 object_append_reference(iter_struct, data);
485 311
@@ -500,8 +326,6 @@ _append_item_fn(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
500 326
501 eo_do(data, elm_atspi_obj_children_get(&children_list)); 327 eo_do(data, elm_atspi_obj_children_get(&children_list));
502 iter_sub_array = eldbus_message_iter_container_new(iter_struct, 'a', "(so)"); 328 iter_sub_array = eldbus_message_iter_container_new(iter_struct, 'a', "(so)");
503 EINA_SAFETY_ON_NULL_GOTO(iter_sub_array, fail);
504
505 EINA_LIST_FOREACH(children_list, l, child) 329 EINA_LIST_FOREACH(children_list, l, child)
506 object_append_reference(iter_sub_array, child); 330 object_append_reference(iter_sub_array, child);
507 331
@@ -510,7 +334,6 @@ _append_item_fn(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
510 334
511 /* Marshall interfaces */ 335 /* Marshall interfaces */
512 iter_sub_array = eldbus_message_iter_container_new(iter_struct, 'a', "s"); 336 iter_sub_array = eldbus_message_iter_container_new(iter_struct, 'a', "s");
513 EINA_SAFETY_ON_NULL_GOTO(iter_sub_array, fail);
514 337
515 eldbus_message_iter_basic_append(iter_sub_array, 's', ATSPI_DBUS_INTERFACE_ACCESSIBLE); 338 eldbus_message_iter_basic_append(iter_sub_array, 's', ATSPI_DBUS_INTERFACE_ACCESSIBLE);
516 if (eo_isa(data, ELM_ATSPI_COMPONENT_INTERFACE)) 339 if (eo_isa(data, ELM_ATSPI_COMPONENT_INTERFACE))
@@ -537,44 +360,24 @@ _append_item_fn(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
537 360
538 /* Marshall state set */ 361 /* Marshall state set */
539 iter_sub_array = eldbus_message_iter_container_new(iter_struct, 'a', "u"); 362 iter_sub_array = eldbus_message_iter_container_new(iter_struct, 'a', "u");
540 EINA_SAFETY_ON_NULL_GOTO(iter_sub_array, fail); 363 /* TODO: states are not implemented yet*/
541
542 eo_do(data, elm_atspi_obj_state_get(&states));
543 unsigned int s1 = states & 0xFFFFFFFF;
544 unsigned int s2 = (states >> 32) & 0xFFFFFFFF;
545 eldbus_message_iter_basic_append(iter_sub_array, 'u', s1);
546 eldbus_message_iter_basic_append(iter_sub_array, 'u', s2);
547
548 eldbus_message_iter_container_close(iter_struct, iter_sub_array); 364 eldbus_message_iter_container_close(iter_struct, iter_sub_array);
549 eldbus_message_iter_container_close(iter_array, iter_struct);
550 365
551 return EINA_TRUE; 366 eldbus_message_iter_container_close(iter_array, iter_struct);
552 367
553fail:
554 if (iter_struct) eldbus_message_iter_del(iter_struct);
555 return EINA_TRUE; 368 return EINA_TRUE;
556} 369}
557 370
558static Eldbus_Message * 371static Eldbus_Message *
559_cache_get_items(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg) 372_cache_get_items(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
560{ 373{
561 Eldbus_Message_Iter *iter, *iter_array;
562 Eldbus_Message *ret = eldbus_message_method_return_new(msg); 374 Eldbus_Message *ret = eldbus_message_method_return_new(msg);
563 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL); 375 Eldbus_Message_Iter *iter, *iter_array;
564
565 _cache_update();
566
567 iter = eldbus_message_iter_get(ret); 376 iter = eldbus_message_iter_get(ret);
568 iter_array = eldbus_message_iter_container_new(iter, 'a', CACHE_ITEM_SIGNATURE); 377 iter_array = eldbus_message_iter_container_new(iter, 'a', CACHE_ITEM_SIGNATURE);
569 EINA_SAFETY_ON_NULL_GOTO(iter_array, fail);
570
571 eina_hash_foreach(_cache, _append_item_fn, iter_array); 378 eina_hash_foreach(_cache, _append_item_fn, iter_array);
572 eldbus_message_iter_container_close(iter, iter_array); 379 eldbus_message_iter_container_close(iter, iter_array);
573
574 return ret; 380 return ret;
575fail:
576 if (ret) eldbus_message_unref(ret);
577 return NULL;
578} 381}
579 382
580static const Eldbus_Method cache_methods[] = { 383static const Eldbus_Method cache_methods[] = {
@@ -583,8 +386,8 @@ static const Eldbus_Method cache_methods[] = {
583}; 386};
584 387
585static const Eldbus_Signal cache_signals[] = { 388static const Eldbus_Signal cache_signals[] = {
586 [ATSPI_OBJECT_CHILD_ADDED] = { "AddAccessible", ELDBUS_ARGS({"((so)(so)a(so)assusau)", "added"}), 0}, 389 [ADD_ACCESSIBLE] = { "AddAccessible", ELDBUS_ARGS({"((so)(so)a(so)assusau)", "added"}), 0},
587 [ATSPI_OBJECT_CHILD_REMOVED] = { "RemoveAccessible", ELDBUS_ARGS({ "(so)", "removed" }), 0}, 390 [REMOVE_ACCESSIBLE] = { "RemoveAccessible", ELDBUS_ARGS({ "(so)", "removed" }), 0},
588 {NULL, NULL, 0} 391 {NULL, NULL, 0}
589}; 392};
590 393
@@ -609,8 +412,6 @@ _component_contains(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eld
609 eo_do(obj, elm_atspi_component_interface_contains(x, y, coord_type, &contains)); 412 eo_do(obj, elm_atspi_component_interface_contains(x, y, coord_type, &contains));
610 413
611 ret = eldbus_message_method_return_new(msg); 414 ret = eldbus_message_method_return_new(msg);
612 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
613
614 eldbus_message_arguments_append(ret, "b", contains); 415 eldbus_message_arguments_append(ret, "b", contains);
615 416
616 return ret; 417 return ret;
@@ -631,8 +432,6 @@ _component_get_accessible_at_point(const Eldbus_Service_Interface *iface EINA_UN
631 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type."); 432 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
632 433
633 ret = eldbus_message_method_return_new(msg); 434 ret = eldbus_message_method_return_new(msg);
634 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
635
636 iter = eldbus_message_iter_get(ret); 435 iter = eldbus_message_iter_get(ret);
637 eo_do(obj, elm_atspi_component_interface_accessible_at_point_get(x, y, coord_type, &accessible)); 436 eo_do(obj, elm_atspi_component_interface_accessible_at_point_get(x, y, coord_type, &accessible));
638 object_append_reference(iter, accessible); 437 object_append_reference(iter, accessible);
@@ -648,30 +447,23 @@ _component_get_extents(const Eldbus_Service_Interface *iface EINA_UNUSED, const
648 int x, y, w, h; 447 int x, y, w, h;
649 AtspiCoordType coord_type; 448 AtspiCoordType coord_type;
650 Eldbus_Message *ret; 449 Eldbus_Message *ret;
651 Eldbus_Message_Iter *iter, *iter_struct; 450 Eldbus_Message_Iter *iter, *iter_struct;
451
652 if (!eldbus_message_arguments_get(msg, "u", &coord_type)) 452 if (!eldbus_message_arguments_get(msg, "u", &coord_type))
653 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type."); 453 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
654 454
655 ret = eldbus_message_method_return_new(msg); 455 ret = eldbus_message_method_return_new(msg);
656 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
657
658 iter = eldbus_message_iter_get(ret); 456 iter = eldbus_message_iter_get(ret);
659 457
660 eo_do(obj, elm_atspi_component_interface_extents_get(&x, &y, &w, &h, coord_type)); 458 eo_do(obj, elm_atspi_component_interface_extents_get(&x, &y, &w, &h, coord_type));
661 iter_struct = eldbus_message_iter_container_new(iter, 'r', NULL); 459 iter_struct = eldbus_message_iter_container_new(iter, 'r', NULL);
662 EINA_SAFETY_ON_NULL_GOTO(iter_struct, fail);
663
664 eldbus_message_iter_basic_append(iter_struct, 'i', x); 460 eldbus_message_iter_basic_append(iter_struct, 'i', x);
665 eldbus_message_iter_basic_append(iter_struct, 'i', y); 461 eldbus_message_iter_basic_append(iter_struct, 'i', y);
666 eldbus_message_iter_basic_append(iter_struct, 'i', w); 462 eldbus_message_iter_basic_append(iter_struct, 'i', w);
667 eldbus_message_iter_basic_append(iter_struct, 'i', h); 463 eldbus_message_iter_basic_append(iter_struct, 'i', h);
668
669 eldbus_message_iter_container_close(iter, iter_struct); 464 eldbus_message_iter_container_close(iter, iter_struct);
670 465
671 return ret; 466 return ret;
672fail:
673 if (iter_struct) eldbus_message_iter_del(iter_struct);
674 return NULL;
675} 467}
676 468
677static Eldbus_Message * 469static Eldbus_Message *
@@ -689,8 +481,6 @@ _component_get_position(const Eldbus_Service_Interface *iface EINA_UNUSED, const
689 eo_do(obj, elm_atspi_component_interface_position_get(&x, &y, coord_type)); 481 eo_do(obj, elm_atspi_component_interface_position_get(&x, &y, coord_type));
690 482
691 ret = eldbus_message_method_return_new(msg); 483 ret = eldbus_message_method_return_new(msg);
692 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
693
694 eldbus_message_arguments_append(ret, "i", x); 484 eldbus_message_arguments_append(ret, "i", x);
695 eldbus_message_arguments_append(ret, "i", y); 485 eldbus_message_arguments_append(ret, "i", y);
696 486
@@ -708,8 +498,6 @@ _component_get_size(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eld
708 eo_do(obj, elm_atspi_component_interface_size_get(&x, &y)); 498 eo_do(obj, elm_atspi_component_interface_size_get(&x, &y));
709 499
710 ret = eldbus_message_method_return_new(msg); 500 ret = eldbus_message_method_return_new(msg);
711 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
712
713 eldbus_message_arguments_append(ret, "i", x); 501 eldbus_message_arguments_append(ret, "i", x);
714 eldbus_message_arguments_append(ret, "i", y); 502 eldbus_message_arguments_append(ret, "i", y);
715 503
@@ -727,8 +515,6 @@ _component_get_layer(const Eldbus_Service_Interface *iface EINA_UNUSED, const El
727 eo_do(obj, elm_atspi_component_interface_layer_get(&layer)); 515 eo_do(obj, elm_atspi_component_interface_layer_get(&layer));
728 516
729 ret = eldbus_message_method_return_new(msg); 517 ret = eldbus_message_method_return_new(msg);
730 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
731
732 eldbus_message_arguments_append(ret, "u", layer); 518 eldbus_message_arguments_append(ret, "u", layer);
733 519
734 return ret; 520 return ret;
@@ -745,8 +531,6 @@ _component_grab_focus(const Eldbus_Service_Interface *iface EINA_UNUSED, const E
745 eo_do(obj, elm_atspi_component_interface_focus_grab(&focus)); 531 eo_do(obj, elm_atspi_component_interface_focus_grab(&focus));
746 532
747 ret = eldbus_message_method_return_new(msg); 533 ret = eldbus_message_method_return_new(msg);
748 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
749
750 eldbus_message_arguments_append(ret, "b", focus); 534 eldbus_message_arguments_append(ret, "b", focus);
751 535
752 return ret; 536 return ret;
@@ -763,8 +547,6 @@ _component_get_alpha(const Eldbus_Service_Interface *iface EINA_UNUSED, const El
763 eo_do(obj, elm_atspi_component_interface_alpha_get(&alpha)); 547 eo_do(obj, elm_atspi_component_interface_alpha_get(&alpha));
764 548
765 ret = eldbus_message_method_return_new(msg); 549 ret = eldbus_message_method_return_new(msg);
766 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
767
768 eldbus_message_arguments_append(ret, "d", alpha); 550 eldbus_message_arguments_append(ret, "d", alpha);
769 551
770 return ret; 552 return ret;
@@ -786,8 +568,6 @@ _component_set_extends(const Eldbus_Service_Interface *iface EINA_UNUSED, const
786 eo_do(obj, elm_atspi_component_interface_extents_set(x, y, w, h, coord_type, &result)); 568 eo_do(obj, elm_atspi_component_interface_extents_set(x, y, w, h, coord_type, &result));
787 569
788 ret = eldbus_message_method_return_new(msg); 570 ret = eldbus_message_method_return_new(msg);
789 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
790
791 eldbus_message_arguments_append(ret, "b", result); 571 eldbus_message_arguments_append(ret, "b", result);
792 572
793 return ret; 573 return ret;
@@ -809,8 +589,6 @@ _component_set_position(const Eldbus_Service_Interface *iface EINA_UNUSED, const
809 eo_do(obj, elm_atspi_component_interface_position_set(x, y, coord_type, &result)); 589 eo_do(obj, elm_atspi_component_interface_position_set(x, y, coord_type, &result));
810 590
811 ret = eldbus_message_method_return_new(msg); 591 ret = eldbus_message_method_return_new(msg);
812 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
813
814 eldbus_message_arguments_append(ret, "b", result); 592 eldbus_message_arguments_append(ret, "b", result);
815 593
816 return ret; 594 return ret;
@@ -831,8 +609,6 @@ _component_set_size(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eld
831 eo_do(obj, elm_atspi_component_interface_size_set(w, h, &result)); 609 eo_do(obj, elm_atspi_component_interface_size_set(w, h, &result));
832 610
833 ret = eldbus_message_method_return_new(msg); 611 ret = eldbus_message_method_return_new(msg);
834 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
835
836 eldbus_message_arguments_append(ret, "b", result); 612 eldbus_message_arguments_append(ret, "b", result);
837 613
838 return ret; 614 return ret;
@@ -859,17 +635,19 @@ static const Eldbus_Service_Interface_Desc component_iface_desc = {
859}; 635};
860 636
861static Eina_Bool 637static Eina_Bool
862_cache_object_del_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 638_atspi_object_del_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
863{ 639{
864 Eldbus_Message *msg; 640 Eldbus_Message *msg;
865 Eldbus_Message_Iter *iter; 641 Eldbus_Message_Iter *iter;
866 char* path; 642 char* path;
867 643
868 msg = eldbus_service_signal_new(_cache_interface, ATSPI_OBJECT_CHILD_REMOVED); 644 msg = eldbus_service_signal_new(_cache_interface, REMOVE_ACCESSIBLE);
869 iter = eldbus_message_iter_get(msg); 645 iter = eldbus_message_iter_get(msg);
870 object_append_reference(iter, obj); 646 object_append_reference(iter, obj);
871 path = _path_from_access_object(obj); 647 path = _path_from_access_object(obj);
872 648
649 //ERR("_atspi_object_del_cbi: %d", eo_ref_get(obj));
650
873 eldbus_service_signal_send(_cache_interface, msg); 651 eldbus_service_signal_send(_cache_interface, msg);
874 eina_hash_del(_cache, path, obj); 652 eina_hash_del(_cache, path, obj);
875 653
@@ -880,50 +658,37 @@ _cache_object_del_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_
880} 658}
881 659
882static void 660static void
883_cache_object_register_interfaces(const char *path, Elm_Atspi_Object *node) 661_atspi_object_register_interfaces(const char* path, Elm_Atspi_Object *node)
884{ 662{
885 Eldbus_Service_Interface *accessible = NULL; 663 Eldbus_Service_Interface *accessible = NULL;
886 Eldbus_Service_Interface *events = NULL;
887 Eldbus_Service_Interface *window = NULL;
888
889 if (eina_hash_find(_cache, path))
890 return;
891 else
892 eina_hash_add(_cache, path, node);
893
894 if (!eo_isa(node, ELM_ATSPI_CLASS)) return;
895 664
896 accessible = eldbus_service_interface_register(_a11y_bus, path, &accessible_iface_desc); 665 if (eo_isa(node, ELM_ATSPI_CLASS))
897 events = eldbus_service_interface_register(_a11y_bus, path, &event_iface_desc); 666 {
898 eo_do(node, eo_base_data_set("atspi_event_interface", events, NULL)); 667 accessible = eldbus_service_interface_register(_a11y_bus, path, &accessible_iface_desc);
899 eo_do(node, eo_event_callback_add(EO_EV_DEL, _cache_object_del_cb, accessible)); 668 eo_do(node, eo_event_callback_add(EO_EV_DEL, _atspi_object_del_cb, accessible));
669 }
900 670
901 if (eo_isa(node, ELM_ATSPI_COMPONENT_INTERFACE)) 671 if (eo_isa(node, ELM_ATSPI_COMPONENT_INTERFACE))
902 eldbus_service_interface_register(_a11y_bus, path, &component_iface_desc); 672 eldbus_service_interface_register(_a11y_bus, path, &component_iface_desc);
903
904 if (eo_isa(node, ELM_ATSPI_WINDOW_INTERFACE))
905 {
906 window = eldbus_service_interface_register(_a11y_bus, path, &window_iface_desc);
907 eo_do(node, eo_base_data_set("window_event_interface", window, NULL));
908 }
909} 673}
910 674
911static void 675static void
912_cache_object_register(Elm_Atspi_Object *node, Eina_Bool rec) 676_atspi_objects_register_rec(Elm_Atspi_Object *node)
913{ 677{
914 EINA_SAFETY_ON_NULL_RETURN(node); 678 EINA_SAFETY_ON_NULL_RETURN(node);
915 Eina_List *children_list = NULL, *l; 679 Eina_List *children_list = NULL, *l;
916 Elm_Atspi_Object *child; 680 Elm_Atspi_Object *child;
917 char* path = _path_from_access_object(node); 681 char* path = _path_from_access_object(node);
918 682
919 _cache_object_register_interfaces(path, node); 683 // register in cache
920 free(path); 684 eina_hash_add(_cache, path, node);
921 685
922 if (!rec) return; 686 _atspi_object_register_interfaces(path, node);
687 free(path);
923 688
924 eo_do(node, elm_atspi_obj_children_get(&children_list)); 689 eo_do(node, elm_atspi_obj_children_get(&children_list));
925 EINA_LIST_FOREACH(children_list, l, child) 690 EINA_LIST_FOREACH(children_list, l, child)
926 _cache_object_register(child, rec); 691 _atspi_objects_register_rec(child);
927 692
928 eina_list_free(children_list); 693 eina_list_free(children_list);
929} 694}
@@ -942,7 +707,7 @@ _on_app_register(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pendi
942} 707}
943 708
944static Eina_Bool 709static Eina_Bool
945_app_register(void) 710_app_register(Eldbus_Connection *a11y_bus)
946{ 711{
947 Eldbus_Message *message = eldbus_message_method_call_new(ATSPI_DBUS_NAME_REGISTRY, 712 Eldbus_Message *message = eldbus_message_method_call_new(ATSPI_DBUS_NAME_REGISTRY,
948 ATSPI_DBUS_PATH_ROOT, 713 ATSPI_DBUS_PATH_ROOT,
@@ -951,381 +716,27 @@ _app_register(void)
951 Eldbus_Message_Iter *iter = eldbus_message_iter_get(message); 716 Eldbus_Message_Iter *iter = eldbus_message_iter_get(message);
952 717
953 object_append_reference(iter, _root); 718 object_append_reference(iter, _root);
954 eldbus_connection_send(_a11y_bus, message, _on_app_register, NULL, -1);
955
956 return EINA_TRUE;
957}
958 719
959static void 720 eldbus_connection_send(a11y_bus, message, _on_app_register, NULL, -1);
960_cache_update(void)
961{
962 _cache_object_register(_root, EINA_TRUE);
963}
964
965static void
966_bus_objects_register(void)
967{
968 _cache_interface = eldbus_service_interface_register(_a11y_bus, CACHE_INTERFACE_PATH, &cache_iface_desc);
969}
970
971static void
972_set_broadcast_flag(const char *event)
973{
974 char **tokens;
975
976 tokens = eina_str_split(event, ":", 3);
977
978 if (!tokens) return;
979
980 if (!strcmp(tokens[0], "Object"))
981 {
982 if (!tokens[1] || *tokens[1] == '\0') return; // do not handle "Object:*"
983 else if (!strcmp(tokens[1], "StateChanged"))
984 {
985 if (!tokens[2] || *tokens[2] == '\0')
986 _object_state_broadcast_mask = -1; // broadcast all
987 else if (!strcmp(tokens[2], "Focused"))
988 BIT_FLAG_SET(_object_state_broadcast_mask, ATSPI_STATE_FOCUSED);
989 else if (!strcmp(tokens[2], "Showing"))
990 BIT_FLAG_SET(_object_state_broadcast_mask, ATSPI_STATE_SHOWING);
991 }
992 else if (!strcmp(tokens[1], "PropertyChange"))
993 {
994 if (!tokens[2] || *tokens[2] == '\0')
995 _object_property_broadcast_mask = -1; //broadcast all
996 else if (!strcmp(tokens[2], "AccessibleValue"))
997 BIT_FLAG_SET(_object_property_broadcast_mask, ATSPI_OBJECT_PROPERTY_VALUE);
998 else if (!strcmp(tokens[2], "AccessibleName"))
999 BIT_FLAG_SET(_object_property_broadcast_mask, ATSPI_OBJECT_PROPERTY_NAME);
1000 else if (!strcmp(tokens[2], "AccessibleDescription"))
1001 BIT_FLAG_SET(_object_property_broadcast_mask, ATSPI_OBJECT_PROPERTY_DESCRIPTION);
1002 else if (!strcmp(tokens[2], "AccessibleParent"))
1003 BIT_FLAG_SET(_object_property_broadcast_mask, ATSPI_OBJECT_PROPERTY_PARENT);
1004 else if (!strcmp(tokens[2], "AccessibleRole"))
1005 BIT_FLAG_SET(_object_property_broadcast_mask, ATSPI_OBJECT_PROPERTY_ROLE);
1006 }
1007 else if (!strcmp(tokens[1], "ChildrenChanged"))
1008 {
1009 if (!tokens[2] || *tokens[2] == '\0')
1010 _object_children_broadcast_mask = -1; // broadcast all
1011 else if (!strcmp(tokens[2], "add"))
1012 BIT_FLAG_SET(_object_children_broadcast_mask, ATSPI_OBJECT_CHILD_ADDED);
1013 else if (!strcmp(tokens[2], "remove"))
1014 BIT_FLAG_SET(_object_children_broadcast_mask, ATSPI_OBJECT_CHILD_ADDED);
1015 }
1016 }
1017 else if (!strcmp(tokens[0], "Window"))
1018 {
1019 if (!tokens[1] || *tokens[1] == '\0')
1020 _window_signal_broadcast_mask = -1; // broadcast all
1021 else if (!strcmp(tokens[1], "Create"))
1022 BIT_FLAG_SET(_window_signal_broadcast_mask, ATSPI_WINDOW_EVENT_CREATE);
1023 else if (!strcmp(tokens[1], "Activate"))
1024 BIT_FLAG_SET(_window_signal_broadcast_mask, ATSPI_WINDOW_EVENT_ACTIVATE);
1025 else if (!strcmp(tokens[1], "Deactivate"))
1026 BIT_FLAG_SET(_window_signal_broadcast_mask, ATSPI_WINDOW_EVENT_DEACTIVATE);
1027 }
1028
1029 free(tokens[0]);
1030 free(tokens);
1031}
1032
1033static void
1034_registered_listeners_get(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
1035{
1036 DBG("Updating ATSPI2 clients registered events list.");
1037 _object_children_broadcast_mask = 0;
1038 _object_property_broadcast_mask = 0;
1039 _object_state_broadcast_mask = 0;
1040 _window_signal_broadcast_mask = 0;
1041
1042 const char *event, *bus;
1043 Eldbus_Message_Iter *iter, *siter;
1044 if (!eldbus_message_arguments_get(msg, "a(ss)", &iter))
1045 {
1046 ERR("Invalid answer type from GetRegisteredEvents method call!");
1047 return;
1048 }
1049 while (eldbus_message_iter_get_and_next(iter, 'r', &siter))
1050 {
1051 eldbus_message_iter_arguments_get(siter, "ss", &bus, &event);
1052 _set_broadcast_flag(event);
1053 }
1054}
1055
1056static void
1057_registered_events_list_update(void)
1058{
1059 Eldbus_Message *msg;
1060 msg = eldbus_message_method_call_new(ATSPI_DBUS_NAME_REGISTRY, ATSPI_DBUS_PATH_REGISTRY, ATSPI_DBUS_INTERFACE_REGISTRY, "GetRegisteredEvents");
1061 eldbus_connection_send(_a11y_bus, msg, _registered_listeners_get, NULL, -1);
1062}
1063
1064static void
1065_handle_listener_change(void *data EINA_UNUSED, const Eldbus_Message *msg)
1066{
1067 const char *bus, *event;
1068 if (!eldbus_message_arguments_get(msg, "ss", &bus, &event))
1069 {
1070 ERR("Invalid org.a11y.Registry signal message args.");
1071 return;
1072 }
1073 _registered_events_list_update();
1074}
1075
1076static void
1077_send_signal_state_changed(Elm_Atspi_Object *obj, AtspiStateType type, Eina_Bool new_value)
1078{
1079 Eldbus_Message *msg;
1080 Eldbus_Message_Iter *iter, *viter;
1081 Eldbus_Service_Interface *events = NULL;
1082 char *desc;
1083
1084 if (!BIT_FLAG_GET(_object_state_broadcast_mask, type))
1085 {
1086 DBG("Masking event: %d", type);
1087 return;
1088 }
1089
1090 switch (type) {
1091 case ATSPI_STATE_FOCUSED:
1092 desc = "focused";
1093 break;
1094 case ATSPI_STATE_SHOWING:
1095 desc = "showing";
1096 break;
1097 case ATSPI_STATE_VISIBLE:
1098 desc = "visible";
1099 break;
1100 default:
1101 desc = NULL;
1102 }
1103
1104 eo_do(obj, eo_base_data_get("atspi_event_interface", (void **)&events));
1105 if (!events)
1106 {
1107 ERR("Atspi object does not have event interface!");
1108 return;
1109 }
1110 msg = eldbus_service_signal_new(events, ATSPI_OBJECT_EVENT_STATE_CHANGED);
1111 iter = eldbus_message_iter_get(msg);
1112
1113 eldbus_message_iter_arguments_append(iter, "sii", desc, new_value, 0);
1114
1115 viter = eldbus_message_iter_container_new(iter, 'v', "i");
1116 EINA_SAFETY_ON_NULL_RETURN(viter);
1117
1118 eldbus_message_iter_arguments_append(viter, "i", 0);
1119 eldbus_message_iter_container_close(iter, viter);
1120
1121 object_append_reference(iter, obj);
1122
1123 eldbus_service_signal_send(events, msg);
1124 DBG("signal sent StateChanged:%s:%d", desc, new_value);
1125}
1126
1127static void
1128_send_signal_property_changed(Elm_Atspi_Object *ao, enum _Atspi_Object_Property prop)
1129{
1130 const char *desc;
1131 Eldbus_Message *msg;
1132 Eldbus_Message_Iter *iter, *siter, *viter;
1133 Eldbus_Service_Interface *events = NULL;
1134
1135 if (!BIT_FLAG_GET(_object_property_broadcast_mask, prop))
1136 return;
1137
1138 switch(prop)
1139 {
1140 case ATSPI_OBJECT_PROPERTY_NAME:
1141 desc = "accessible-name";
1142 break;
1143 case ATSPI_OBJECT_PROPERTY_DESCRIPTION:
1144 desc = "accessible-description";
1145 break;
1146 case ATSPI_OBJECT_PROPERTY_ROLE:
1147 desc = "accessible-role";
1148 break;
1149 case ATSPI_OBJECT_PROPERTY_PARENT:
1150 desc = "accessible-parent";
1151 break;
1152 case ATSPI_OBJECT_PROPERTY_VALUE:
1153 desc = "accessible-value";
1154 break;
1155 default:
1156 desc = NULL;
1157 }
1158 eo_do(ao, eo_base_data_get("atspi_event_interface", (void**)&events));
1159 if (!events)
1160 {
1161 ERR("Atspi object does not have event interface!");
1162 return;
1163 }
1164 msg = eldbus_service_signal_new(events, ATSPI_OBJECT_EVENT_PROPERTY_CHANGED);
1165 EINA_SAFETY_ON_NULL_RETURN(msg);
1166
1167 iter = eldbus_message_iter_get(msg);
1168 siter = eldbus_message_iter_container_new(iter, 'r', NULL);
1169 EINA_SAFETY_ON_NULL_RETURN(siter);
1170
1171 eldbus_message_iter_arguments_append(siter, "suu", desc, 0, 0);
1172
1173 viter = eldbus_message_iter_container_new(siter, 'v', "s");
1174 EINA_SAFETY_ON_NULL_RETURN(viter);
1175
1176 eldbus_message_iter_arguments_append(viter, "s", _path_from_access_object(ao));
1177
1178 eldbus_message_iter_arguments_append(siter, "v", viter);
1179 eldbus_message_iter_container_close(siter, viter);
1180
1181 eldbus_message_iter_container_close(iter, siter);
1182 eldbus_service_signal_send(events, msg);
1183 DBG("signal sent PropertyChanged:%s", desc);
1184}
1185
1186static void
1187_send_signal_children_changed(Elm_Atspi_Object *parent, Elm_Atspi_Object *child, enum _Atspi_Object_Child_Event_Type type)
1188{
1189 Eldbus_Service_Interface *events = NULL;
1190 Eldbus_Message_Iter *iter, *viter;
1191 Eldbus_Message *msg;
1192 const char *desc = NULL;
1193 int idx;
1194
1195 if (!BIT_FLAG_GET(_object_children_broadcast_mask, type))
1196 return;
1197
1198 _cache_object_register(parent, EINA_FALSE);
1199 _cache_object_register(child, EINA_FALSE);
1200
1201 eo_do(parent, eo_base_data_get("atspi_event_interface", (void **)&events));
1202 if (!events)
1203 {
1204 ERR("Atspi object does not have event interface! %p %p %s", parent, _root, eo_class_name_get(eo_class_get(parent)));
1205 return;
1206 }
1207
1208 switch(type)
1209 {
1210 case ATSPI_OBJECT_CHILD_ADDED:
1211 desc = "add";
1212 eo_do(child, elm_atspi_obj_index_in_parent_get(&idx));
1213 break;
1214 case ATSPI_OBJECT_CHILD_REMOVED:
1215 desc = "remove";
1216 idx = -1;
1217 break;
1218 }
1219 msg = eldbus_service_signal_new(events, ATSPI_OBJECT_EVENT_CHILDREN_CHANGED);
1220 EINA_SAFETY_ON_NULL_RETURN(msg);
1221
1222 iter = eldbus_message_iter_get(msg);
1223 eldbus_message_iter_arguments_append(iter, "sii", desc, idx, 0);
1224
1225 viter = eldbus_message_iter_container_new(iter, 'v', "(so)");
1226 EINA_SAFETY_ON_NULL_RETURN(viter);
1227
1228 object_append_reference(viter, child);
1229 eldbus_message_iter_container_close(iter, viter);
1230
1231 object_append_reference(iter, _root);
1232
1233 eldbus_service_signal_send(events, msg);
1234 DBG("signal sent childrenChanged:%s:%d", desc, idx);
1235}
1236
1237static void
1238_send_signal_window(Elm_Atspi_Object *eo, enum _Atspi_Window_Signals type)
1239{
1240 const char *desc;
1241 Eldbus_Message *msg;
1242 Eldbus_Message_Iter *iter, *viter;
1243 Eldbus_Service_Interface *window = NULL;
1244
1245 if (!BIT_FLAG_GET(_window_signal_broadcast_mask, type))
1246 return;
1247
1248 eo_do(eo, eo_base_data_get("window_event_interface", (void**)&window));
1249 if (!window)
1250 {
1251 ERR("Atspi object does not have window interface!");
1252 return;
1253 }
1254
1255 switch(type)
1256 {
1257 case ATSPI_WINDOW_EVENT_DEACTIVATE:
1258 desc = "Deactivate";
1259 break;
1260 case ATSPI_WINDOW_EVENT_ACTIVATE:
1261 desc = "Activate";
1262 break;
1263 default:
1264 desc = "";
1265 }
1266
1267 msg = eldbus_service_signal_new(window, type);
1268 EINA_SAFETY_ON_NULL_RETURN(msg);
1269
1270 iter = eldbus_message_iter_get(msg);
1271 eldbus_message_iter_arguments_append(iter, "sii", desc, 0, 0);
1272
1273 viter = eldbus_message_iter_container_new(iter, 'v', "i");
1274 EINA_SAFETY_ON_NULL_RETURN(viter);
1275
1276 eldbus_message_iter_arguments_append(viter, "i", 0);
1277 eldbus_message_iter_container_close(iter, viter);
1278
1279 object_append_reference(iter, eo);
1280
1281 eldbus_service_signal_send(window, msg);
1282 DBG("signal sent Window:%s", desc);
1283}
1284
1285static Eina_Bool
1286_handle_atspi_event(void *data EINA_UNUSED, Elm_Atspi_Object *ao, const Eo_Event_Description *desc, void *event_info)
1287{
1288 if (desc == EV_ATSPI_OBJ_NAME_CHANGED)
1289 _send_signal_property_changed(ao, ATSPI_OBJECT_PROPERTY_NAME);
1290 else if (desc == EV_ATSPI_OBJ_STATE_CHANGED)
1291 {
1292 int *event_data = event_info;
1293 _send_signal_state_changed(ao, (AtspiStateType)event_data[0], (Eina_Bool)event_data[1]);
1294 }
1295 else if (desc == EV_ATSPI_OBJ_CHILD_ADD)
1296 _send_signal_children_changed(ao, event_info, ATSPI_OBJECT_CHILD_ADDED);
1297 else if (desc == EV_ATSPI_OBJ_CHILD_DEL)
1298 _send_signal_children_changed(ao, event_info, ATSPI_OBJECT_CHILD_REMOVED);
1299 else if (desc == EV_ATSPI_OBJ_WINDOW_ACTIVATED)
1300 _send_signal_window(ao, ATSPI_WINDOW_EVENT_ACTIVATE);
1301 else if (desc == EV_ATSPI_OBJ_WINDOW_DEACTIVATED)
1302 _send_signal_window(ao, ATSPI_WINDOW_EVENT_DEACTIVATE);
1303 721
1304 return EINA_TRUE; 722 return EINA_TRUE;
1305} 723}
1306 724
1307static void 725static void
1308_event_handlers_register(void) 726_bus_objects_register(Eldbus_Connection *a11y_bus)
1309{ 727{
1310 _registered_events_list_update(); 728 _cache_interface = eldbus_service_interface_register(a11y_bus, CACHE_INTERFACE_PATH, &cache_iface_desc);
1311 729 _atspi_objects_register_rec(_root);
1312 // register signal handlers in order to update list of registered listeners of ATSPI-Clients 730 DBG("%d elements registered in cache", eina_hash_population(_cache));
1313 _register_hdl = eldbus_signal_handler_add(_a11y_bus, ATSPI_DBUS_NAME_REGISTRY, ATSPI_DBUS_PATH_REGISTRY, ATSPI_DBUS_INTERFACE_REGISTRY, "EventListenerRegistered", _handle_listener_change, NULL);
1314 _unregister_hdl = eldbus_signal_handler_add(_a11y_bus, ATSPI_DBUS_NAME_REGISTRY, ATSPI_DBUS_PATH_REGISTRY, ATSPI_DBUS_INTERFACE_REGISTRY, "EventListenerDeregistered", _handle_listener_change, NULL);
1315
1316 // handle incoming events from Elm_Atspi_Objects
1317 _elm_atspi_object_global_callback_add(_handle_atspi_event, NULL);
1318} 731}
1319 732
1320static void 733static void
1321_a11y_bus_initialize(const char *socket_addr) 734_a11y_bus_initialize(const char *socket_addr)
1322{ 735{
1323 _a11y_bus = eldbus_address_connection_get(socket_addr); 736 Eldbus_Connection *a11y_bus = eldbus_address_connection_get(socket_addr);
1324 737 _a11y_bus = a11y_bus;
1325 _cache_update(); 738 _bus_objects_register(a11y_bus);
1326 _bus_objects_register(); 739 _app_register(a11y_bus);
1327 _app_register();
1328 _event_handlers_register();
1329} 740}
1330 741
1331static void 742static void
@@ -1360,18 +771,11 @@ _elm_atspi_bridge_init(void)
1360 771
1361 if (!_init_count && _elm_config->access_mode == ELM_ACCESS_MODE_ON) 772 if (!_init_count && _elm_config->access_mode == ELM_ACCESS_MODE_ON)
1362 { 773 {
1363 _elm_atspi_object_init();
1364 session_bus = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); 774 session_bus = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
1365 EINA_SAFETY_ON_NULL_RETURN(session_bus);
1366 msg = eldbus_message_method_call_new(A11Y_DBUS_NAME, A11Y_DBUS_PATH, A11Y_DBUS_INTERFACE, "GetAddress"); 775 msg = eldbus_message_method_call_new(A11Y_DBUS_NAME, A11Y_DBUS_PATH, A11Y_DBUS_INTERFACE, "GetAddress");
1367 if (!msg)
1368 {
1369 eldbus_connection_unref(session_bus);
1370 return;
1371 }
1372 eldbus_connection_send(session_bus, msg, _a11y_bus_address_get, session_bus, -1); 776 eldbus_connection_send(session_bus, msg, _a11y_bus_address_get, session_bus, -1);
1373 _cache = eina_hash_string_superfast_new(NULL); 777 _cache = eina_hash_string_superfast_new(NULL);
1374 _root = _elm_atspi_root_object_get(); 778 _root = elm_atspi_root_object_get();
1375 _init_count = 1; 779 _init_count = 1;
1376 } 780 }
1377} 781}
@@ -1381,15 +785,7 @@ _elm_atspi_bridge_shutdown(void)
1381{ 785{
1382 if (_init_count) 786 if (_init_count)
1383 { 787 {
1384 _elm_atspi_object_shutdown(); 788 eo_unref(_root);
1385
1386 if (_register_hdl)
1387 eldbus_signal_handler_del(_register_hdl);
1388 _register_hdl = NULL;
1389
1390 if (_unregister_hdl)
1391 eldbus_signal_handler_del(_unregister_hdl);
1392 _unregister_hdl = NULL;
1393 789
1394 if (_cache_interface) 790 if (_cache_interface)
1395 eldbus_service_object_unregister(_cache_interface); 791 eldbus_service_object_unregister(_cache_interface);
diff --git a/src/lib/elm_atspi_object.c b/src/lib/elm_atspi_object.c
index 790d3d2ed..612130a0c 100644
--- a/src/lib/elm_atspi_object.c
+++ b/src/lib/elm_atspi_object.c
@@ -5,21 +5,9 @@
5#include <Elementary.h> 5#include <Elementary.h>
6#include "elm_widget.h" 6#include "elm_widget.h"
7#include "elm_priv.h" 7#include "elm_priv.h"
8#include "assert.h"
9 8
10#include "atspi/atspi-constants.h" 9#include "atspi/atspi-constants.h"
11 10
12static Elm_Atspi_Object *_app;
13static Eina_List *_global_callbacks;
14
15typedef struct _Elm_Atspi_Global_Callback_Info Elm_Atspi_Global_Callback_Info;
16
17struct _Elm_Atspi_Global_Callback_Info
18{
19 Eo_Event_Cb cb;
20 void *user_data;
21};
22
23const char* Atspi_Name[] = { 11const char* Atspi_Name[] = {
24 "invalid", 12 "invalid",
25 "accelerator label", 13 "accelerator label",
@@ -127,313 +115,177 @@ const char* Atspi_Name[] = {
127 "last defined" 115 "last defined"
128}; 116};
129 117
130extern Eina_List *_elm_win_list; 118#define ARG_GET(valist, type) va_arg(*valist, type)
131
132EAPI Eo_Op ELM_ATSPI_OBJ_BASE_ID = EO_NOOP;
133
134EAPI const Eo_Event_Description _EV_ATSPI_OBJ_NAME_CHANGED =
135 EO_EVENT_DESCRIPTION("name,changed", "Called when accessible object text has changed.");
136 119
137EAPI const Eo_Event_Description _EV_ATSPI_OBJ_CHILD_ADD = 120static Elm_Atspi_Object * _elm_atspi_factory_construct(Evas_Object *obj, Elm_Atspi_Object *);
138 EO_EVENT_DESCRIPTION("child,added", "Called when accessible object children was created.");
139 121
140EAPI const Eo_Event_Description _EV_ATSPI_OBJ_CHILD_DEL = 122extern Eina_List *_elm_win_list;
141 EO_EVENT_DESCRIPTION("child,removed", "Called when accessible object children was destroyed.");
142
143EAPI const Eo_Event_Description _EV_ATSPI_OBJ_STATE_CHANGED =
144 EO_EVENT_DESCRIPTION("state,changed", "Called when accessible object state has changed.");
145
146EAPI const Eo_Event_Description _EV_ATSPI_OBJ_WINDOW_ACTIVATED =
147 EO_EVENT_DESCRIPTION("widnow,created", "Called when new window has been activated. (unfocuesed)");
148 123
149EAPI const Eo_Event_Description _EV_ATSPI_OBJ_WINDOW_DEACTIVATED = 124typedef struct _Atspi_Object_Data Atspi_Object_Data;
150 EO_EVENT_DESCRIPTION("widnow,created", "Called when new window has been deactivated (unfocused).");
151 125
152static void 126struct _Atspi_Object_Data
153_eo_emit_state_changed_event(void *data, Evas *e EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void *event_info EINA_UNUSED)
154{
155 Elm_Atspi_Object *ao = data;
156 int event_data[2] = {ATSPI_STATE_VISIBLE, 1};
157 eo_do(ao, eo_event_callback_call(EV_ATSPI_OBJ_STATE_CHANGED, &event_data[0], NULL));
158}
159
160static void
161_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
162{ 127{
163 Evas_Object *internal_obj = NULL; 128 const char *name;
164 eo_do_super(obj, ELM_ATSPI_CLASS, eo_constructor()); 129 const char *description;
165 130 AtspiRole role;
166 eo_do(obj, eo_parent_get(&internal_obj)); 131};
167
168 /* Evas_Object can only hold refs to atspi-object */
169 assert(eo_isa(internal_obj, EVAS_OBJ_SMART_CLASS));
170 132
171 evas_object_data_set(internal_obj, "_atspi_object", obj); 133EAPI Eo_Op ELM_ATSPI_OBJ_BASE_ID = EO_NOOP;
172 evas_object_event_callback_add(internal_obj, EVAS_CALLBACK_SHOW, _eo_emit_state_changed_event, obj);
173}
174 134
175static void 135static void
176_destructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 136_description_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
177{ 137{
178 eo_do_super(obj, ELM_ATSPI_CLASS, eo_destructor()); 138 const char **ret = ARG_GET(list, const char **);
139 Atspi_Object_Data *ad = _pd;
140
141 *ret = ad->description;
179} 142}
180 143
181static void 144static void
182_child_at_index_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 145_description_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
183{ 146{
184 EO_PARAMETER_GET(int, idx, list); 147 const char *desc = ARG_GET(list, const char *);
185 EO_PARAMETER_GET(Elm_Atspi_Object**, ao, list); 148 Atspi_Object_Data *ad = _pd;
186 Eina_List *children = NULL;
187 149
188 eo_do(obj, elm_atspi_obj_children_get(&children)); 150 if (ad->description)
189 if (!children) return; 151 eina_stringshare_del(ad->description);
190 152
191 if (ao) *ao = eina_list_nth(children, idx); 153 ad->description = eina_stringshare_add(desc);
192 eina_list_free(children);
193} 154}
194 155
195static void 156static void
196_object_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 157_parent_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
197{ 158{
198 EO_PARAMETER_GET(Evas_Object**, ret, list); 159 Elm_Atspi_Object **ret = ARG_GET(list, Elm_Atspi_Object**);
199 eo_do(obj, eo_parent_get(ret)); 160 eo_do(obj, eo_parent_get(ret));
200} 161}
201 162
202static void 163static void
203_index_in_parent_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 164_name_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
204{ 165{
205 EO_PARAMETER_GET(unsigned int*, idx, list); 166 const char **ret = ARG_GET(list, const char **);
206 Elm_Atspi_Object *chld, *parent = NULL; 167 Atspi_Object_Data *ad = _pd;
207 Eina_List *l, *children = NULL;
208 unsigned int tmp = 0;
209
210 eo_do(obj, elm_atspi_obj_parent_get(&parent));
211 if (!parent) return;
212 eo_do(parent, elm_atspi_obj_children_get(&children));
213 168
214 EINA_LIST_FOREACH(children, l, chld) 169 *ret = ad->name;
215 {
216 if (chld == obj)
217 {
218 if (idx) *idx = tmp;
219 break;
220 }
221 tmp++;
222 }
223 if (tmp == eina_list_count(children))
224 ERR("Access object not present in parent's children list!");
225
226 eina_list_free(children);
227} 170}
228 171
229static void 172static void
230_role_name_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 173_name_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
231{ 174{
232 EO_PARAMETER_GET(const char **, ret, list); 175 const char *name = ARG_GET(list, const char *);
233 AtspiRole role = ATSPI_ROLE_INVALID; 176 Atspi_Object_Data *ad = _pd;
234
235 eo_do(obj, elm_atspi_obj_role_get(&role));
236
237 if (role >= ATSPI_ROLE_LAST_DEFINED)
238 {
239 ERR("Invalid role enum for atspi-object: %d.", role);
240 return;
241 }
242 177
243 if (ret) *ret = Atspi_Name[role]; 178 if (ad->name)
244} 179 eina_stringshare_del(ad->name);
245 180
246static void 181 ad->name = eina_stringshare_add(name);
247_description_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
248{
249 EO_PARAMETER_GET(const char **, ret, list);
250 *ret = NULL;
251} 182}
252 183
253static void 184static void
254_localized_role_name_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 185_role_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
255{ 186{
256 EO_PARAMETER_GET(const char **, ret, list); 187 AtspiRole *ret = ARG_GET(list, AtspiRole *);
257 const char *name = NULL; 188 Atspi_Object_Data *ad = _pd;
258 189
259 eo_do(obj, elm_atspi_obj_role_name_get(&name)); 190 *ret = ad->role;
260 if (!name) return;
261#ifdef ENABLE_NLS
262 if (ret) *ret = gettext(name);
263#else
264 if (ret) *ret = name;
265#endif
266} 191}
267 192
268static void 193static void
269_state_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 194_role_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
270{ 195{
271 EO_PARAMETER_GET(Elm_Atspi_State *, ret, list); 196 AtspiRole role = ARG_GET(list, int);
272 Evas_Object *evobj = NULL; 197 Atspi_Object_Data *ad = _pd;
273 Elm_Atspi_State states = 0;
274 eo_do(obj, elm_atspi_obj_object_get(&evobj));
275 198
276 if (evas_object_visible_get(evobj)) 199 ad->role = role;
277 BIT_FLAG_SET(states, ATSPI_STATE_VISIBLE);
278
279 if (ret) *ret = states;
280} 200}
281 201
282static void 202static void
283_comp_access_at_point_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 203_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
284{ 204{
285 EO_PARAMETER_GET(int, x, list); 205 eo_do_super(obj, ELM_ATSPI_CLASS, eo_constructor());
286 EO_PARAMETER_GET(int, y, list); 206 Atspi_Object_Data *ad = _pd;
287 EO_PARAMETER_GET(AtspiCoordType, type, list); 207 ad->name = ad->description = NULL;
288 EO_PARAMETER_GET(Evas_Object **, ret, list);
289 int ee_x, ee_y;
290 Eina_List *l, *objs;
291 Evas_Object *evobj = NULL;
292
293 eo_do(obj, elm_atspi_obj_object_get(&evobj));
294
295 if (!evobj) return;
296 if (type == ATSPI_COORD_TYPE_SCREEN)
297 {
298 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(evobj));
299 if (!ee) return;
300 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
301 x -= ee_x;
302 y -= ee_y;
303 }
304 objs = evas_objects_at_xy_get(evas_object_evas_get(evobj), x, y, EINA_TRUE, EINA_TRUE);
305 EINA_LIST_FOREACH(objs, l, evobj)
306 {
307 // return first only, test if there is atspi interface for eo
308 Elm_Atspi_Object *acc = _elm_atspi_factory_construct(evobj);
309 if (acc)
310 {
311 *ret = evobj;
312 break;
313 }
314 }
315 eina_list_free(objs);
316} 208}
317 209
318static void 210static void
319_comp_extents_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 211_destructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
320{ 212{
321 EO_PARAMETER_GET(int *, x, list); 213 Atspi_Object_Data *ad = _pd;
322 EO_PARAMETER_GET(int*, y, list);
323 EO_PARAMETER_GET(int*, w, list);
324 EO_PARAMETER_GET(int*, h, list);
325 EO_PARAMETER_GET(AtspiCoordType, type, list);
326 int ee_x, ee_y;
327 Evas_Object *evobj = NULL;
328 214
329 eo_do(obj, elm_atspi_obj_object_get(&evobj)); 215 eina_stringshare_del(ad->name);
330 if (!evobj) return; 216 eina_stringshare_del(ad->description);
331 217
332 evas_object_geometry_get(evobj, x, y, w, h); 218 eo_do_super(obj, ELM_ATSPI_CLASS, eo_destructor());
333 if (type == ATSPI_COORD_TYPE_SCREEN)
334 {
335 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(evobj));
336 if (!ee) return;
337 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
338 if (x) *x += ee_x;
339 if (y) *y += ee_y;
340 }
341} 219}
342 220
343static void 221static void
344_comp_extents_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 222_role_name_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
345{ 223{
346 EO_PARAMETER_GET(int, x, list); 224 const char **ret = ARG_GET(list, const char **);
347 EO_PARAMETER_GET(int, y, list); 225 Atspi_Object_Data *ad = _pd;
348 EO_PARAMETER_GET(int, w, list);
349 EO_PARAMETER_GET(int, h, list);
350 EO_PARAMETER_GET(AtspiCoordType, type, list);
351 EO_PARAMETER_GET(Eina_Bool *, ret, list);
352 int wx, wy;
353 Evas_Object *evobj = NULL;
354
355 if (ret) *ret = EINA_FALSE;
356 if ((x < 0) || (y < 0) || (w < 0) || (h < 0)) return;
357
358 eo_do(obj, elm_atspi_obj_object_get(&evobj));
359 if (!evobj) return;
360
361 if (type == ATSPI_COORD_TYPE_SCREEN)
362 {
363 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(evobj));
364 if (!ee) return;
365 evas_object_geometry_get(evobj, &wx, &wy, NULL, NULL);
366 ecore_evas_move(ee, x - wx, y - wy);
367 }
368 else
369 evas_object_move(evobj, x, y);
370 226
371 evas_object_resize(evobj, w, h); 227 *ret = Atspi_Name[ad->role];
372 if (ret) *ret = EINA_TRUE;
373} 228}
374 229
375static void 230static void
376_comp_layer_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 231_localized_role_name_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
377{ 232{
378 EO_PARAMETER_GET(int *, ret, list); 233 const char **ret = ARG_GET(list, const char **);
379 Elm_Object_Layer layer; 234 Atspi_Object_Data *ad = _pd;
380 Evas_Object *evobj = NULL;
381 AtspiComponentLayer spi_layer;
382
383 eo_do(obj, elm_atspi_obj_object_get(&evobj));
384 if (!evobj) return;
385
386 layer = evas_object_layer_get(evobj);
387 switch (layer) {
388 case ELM_OBJECT_LAYER_BACKGROUND:
389 spi_layer = ATSPI_LAYER_BACKGROUND;
390 break;
391 case ELM_OBJECT_LAYER_FOCUS:
392 case ELM_OBJECT_LAYER_TOOLTIP:
393 case ELM_OBJECT_LAYER_CURSOR:
394 spi_layer = ATSPI_LAYER_OVERLAY;
395 break;
396 default:
397 spi_layer = ATSPI_LAYER_WIDGET;
398 }
399 if (ret) *ret = spi_layer;
400}
401 235
402static void 236#ifdef ENABLE_NLS
403_comp_z_order_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 237 *ret = gettext(Atspi_Name[ad->role]);
404{ 238#else
405 // FIXME 239 *ret = Atspi_Name[ad->role];
240#endif
406} 241}
407 242
408static void 243static void
409_cb_call(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 244_child_at_index_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
410{ 245{
411 Elm_Atspi_Global_Callback_Info *info; 246 int idx = ARG_GET(list, int);
412 Eina_List *l; 247 Elm_Atspi_Object **ao = ARG_GET(list, Elm_Atspi_Object**);
413 EO_PARAMETER_GET(const Eo_Event_Description *, desc, list); 248 Eina_List *children = NULL;
414 EO_PARAMETER_GET(void *, event_info, list); 249 eo_do(obj, elm_atspi_obj_children_get(&children));
415 EO_PARAMETER_GET(Eina_Bool *, ret, list);
416 250
417 EINA_LIST_FOREACH(_global_callbacks, l, info) 251 if (children)
418 { 252 *ao = eina_list_nth(children, idx);
419 if (info->cb) info->cb(info->user_data, obj, desc, event_info); 253 else
420 } 254 *ao = NULL;
421 255
422 eo_do_super(obj, ELM_ATSPI_CLASS, eo_event_callback_call(desc, event_info, ret)); 256 eina_list_free(children);
423} 257}
424 258
425static void 259static void
426_comp_alpha_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 260_index_in_parent_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
427{ 261{
428 EO_PARAMETER_GET(double *, ret, list); 262 unsigned int *idx = ARG_GET(list, unsigned int*);
429 Evas_Object *evobj = NULL; 263 Elm_Atspi_Object *chld, *parent = NULL;
430 int alpha; 264 Eina_List *l, *children = NULL;
265 unsigned int tmp = 0;
266 eo_do(obj, elm_atspi_obj_parent_get(&parent));
431 267
432 eo_do(obj, elm_atspi_obj_object_get(&evobj)); 268 if (parent)
433 if (!evobj) return; 269 {
270 eo_do(parent, elm_atspi_obj_children_get(&children));
271 EINA_LIST_FOREACH(children, l, chld)
272 {
273 if (chld == obj)
274 {
275 *idx = tmp;
276 break;
277 }
278 tmp++;
279 }
280 if (tmp == eina_list_count(children))
281 ERR("Access object not present in parent's children list!");
282 EINA_LIST_FREE(children, chld)
283 eo_unref(chld);
434 284
435 evas_object_color_get(evobj, NULL, NULL, NULL, &alpha); 285 eo_unref(parent);
436 if (ret) *ret = (double)alpha / 255.0; 286 }
287 else
288 DBG("Access Object has no parent.");
437} 289}
438 290
439static void 291static void
@@ -442,20 +294,17 @@ _class_constructor(Eo_Class *klass)
442 const Eo_Op_Func_Description func_desc[] = { 294 const Eo_Op_Func_Description func_desc[] = {
443 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), 295 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
444 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), 296 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
445 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_CALL), _cb_call), 297 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_NAME_GET), _name_get),
446 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_OBJECT_GET), _object_get), 298 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_NAME_SET), _name_set),
299 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_GET), _description_get),
300 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_SET), _description_set),
301 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_PARENT_GET), _parent_get),
447 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_CHILD_AT_INDEX_GET), _child_at_index_get), 302 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_CHILD_AT_INDEX_GET), _child_at_index_get),
448 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_INDEX_IN_PARENT_GET), _index_in_parent_get), 303 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_INDEX_IN_PARENT_GET), _index_in_parent_get),
304 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_GET), _role_get),
305 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_SET), _role_set),
449 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_NAME_GET), _role_name_get), 306 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_NAME_GET), _role_name_get),
450 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_GET), _description_get),
451 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_LOCALIZED_ROLE_NAME_GET), _localized_role_name_get), 307 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_LOCALIZED_ROLE_NAME_GET), _localized_role_name_get),
452 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_STATE_GET), _state_get),
453 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_ACCESSIBLE_AT_POINT_GET), _comp_access_at_point_get),
454 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_EXTENTS_GET), _comp_extents_get),
455 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_EXTENTS_SET), _comp_extents_set),
456 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_LAYER_GET), _comp_layer_get),
457 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_Z_ORDER_GET), _comp_z_order_get),
458 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_ALPHA_GET), _comp_alpha_get),
459 EO_OP_FUNC_SENTINEL 308 EO_OP_FUNC_SENTINEL
460 }; 309 };
461 eo_class_funcs_set(klass, func_desc); 310 eo_class_funcs_set(klass, func_desc);
@@ -463,14 +312,17 @@ _class_constructor(Eo_Class *klass)
463 312
464static const Eo_Op_Description op_desc[] = { 313static const Eo_Op_Description op_desc[] = {
465 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_NAME_GET, ""), 314 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_NAME_GET, ""),
315 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_NAME_SET, ""),
466 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_GET, ""), 316 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_GET, ""),
317 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_SET, ""),
318 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_PARENT_GET, ""),
467 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_CHILD_AT_INDEX_GET, ""), 319 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_CHILD_AT_INDEX_GET, ""),
468 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_CHILDREN_GET, ""), 320 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_CHILDREN_GET, ""),
469 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_PARENT_GET, ""),
470 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_OBJECT_GET, ""),
471 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_INDEX_IN_PARENT_GET, ""), 321 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_INDEX_IN_PARENT_GET, ""),
472 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_RELATION_SET_GET, ""), 322 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_RELATION_SET_GET, ""),
323 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_RELATION_SET_SET, ""),
473 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_ROLE_GET, ""), 324 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_ROLE_GET, ""),
325 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_ROLE_SET, ""),
474 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_ROLE_NAME_GET, ""), 326 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_ROLE_NAME_GET, ""),
475 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_LOCALIZED_ROLE_NAME_GET, ""), 327 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_LOCALIZED_ROLE_NAME_GET, ""),
476 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_STATE_GET, ""), 328 EO_OP_DESCRIPTION(ELM_ATSPI_OBJ_SUB_ID_STATE_GET, ""),
@@ -478,26 +330,18 @@ static const Eo_Op_Description op_desc[] = {
478 EO_OP_DESCRIPTION_SENTINEL 330 EO_OP_DESCRIPTION_SENTINEL
479}; 331};
480 332
481static const Eo_Event_Description *event_desc[] = {
482 EV_ATSPI_OBJ_NAME_CHANGED,
483 EV_ATSPI_OBJ_STATE_CHANGED,
484 EV_ATSPI_OBJ_CHILD_ADD,
485 EV_ATSPI_OBJ_CHILD_DEL,
486 NULL
487};
488
489static const Eo_Class_Description class_desc = { 333static const Eo_Class_Description class_desc = {
490 EO_VERSION, 334 EO_VERSION,
491 "Elm_Atspi_Object", 335 "Access_Object",
492 EO_CLASS_TYPE_REGULAR, 336 EO_CLASS_TYPE_REGULAR,
493 EO_CLASS_DESCRIPTION_OPS(&ELM_ATSPI_OBJ_BASE_ID, op_desc, ELM_ATSPI_OBJ_SUB_ID_LAST), 337 EO_CLASS_DESCRIPTION_OPS(&ELM_ATSPI_OBJ_BASE_ID, op_desc, ELM_ATSPI_OBJ_SUB_ID_LAST),
494 event_desc, 338 NULL,
495 0, 339 sizeof(Atspi_Object_Data),
496 _class_constructor, 340 _class_constructor,
497 NULL 341 NULL
498}; 342};
499 343
500EO_DEFINE_CLASS(elm_atspi_obj_class_get, &class_desc, EO_BASE_CLASS, ELM_ATSPI_COMPONENT_INTERFACE, NULL); 344EO_DEFINE_CLASS(elm_atspi_obj_class_get, &class_desc, EO_BASE_CLASS, NULL);
501 345
502// Component interface 346// Component interface
503EAPI Eo_Op ELM_ATSPI_COMPONENT_INTERFACE_BASE_ID = EO_NOOP; 347EAPI Eo_Op ELM_ATSPI_COMPONENT_INTERFACE_BASE_ID = EO_NOOP;
@@ -505,9 +349,9 @@ EAPI Eo_Op ELM_ATSPI_COMPONENT_INTERFACE_BASE_ID = EO_NOOP;
505static void 349static void
506_comp_interface_position_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 350_comp_interface_position_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
507{ 351{
508 EO_PARAMETER_GET(int *, x, list); 352 int *x = ARG_GET(list, int*);
509 EO_PARAMETER_GET(int *, y, list); 353 int *y = ARG_GET(list, int*);
510 EO_PARAMETER_GET(AtspiCoordType, type, list); 354 AtspiCoordType type = ARG_GET(list, AtspiCoordType);
511 355
512 eo_do(obj, elm_atspi_component_interface_extents_get(x, y, NULL, NULL, type)); 356 eo_do(obj, elm_atspi_component_interface_extents_get(x, y, NULL, NULL, type));
513} 357}
@@ -515,10 +359,10 @@ _comp_interface_position_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list
515static void 359static void
516_comp_interface_position_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 360_comp_interface_position_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
517{ 361{
518 EO_PARAMETER_GET(int, x, list); 362 int x = ARG_GET(list, int);
519 EO_PARAMETER_GET(int, y, list); 363 int y = ARG_GET(list, int);
520 EO_PARAMETER_GET(AtspiCoordType, type, list); 364 AtspiCoordType type = ARG_GET(list, AtspiCoordType);
521 EO_PARAMETER_GET(Eina_Bool*, ret, list); 365 Eina_Bool *ret = ARG_GET(list, Eina_Bool*);
522 int c_w, c_h; 366 int c_w, c_h;
523 367
524 eo_do(obj, elm_atspi_component_interface_extents_get(NULL, NULL, &c_w, &c_h, type)); 368 eo_do(obj, elm_atspi_component_interface_extents_get(NULL, NULL, &c_w, &c_h, type));
@@ -528,9 +372,9 @@ _comp_interface_position_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list
528static void 372static void
529_comp_interface_size_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 373_comp_interface_size_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
530{ 374{
531 EO_PARAMETER_GET(int, w, list); 375 int w = ARG_GET(list, int);
532 EO_PARAMETER_GET(int, h, list); 376 int h = ARG_GET(list, int);
533 EO_PARAMETER_GET(Eina_Bool*, ret, list); 377 Eina_Bool *ret = ARG_GET(list, Eina_Bool*);
534 int c_x, c_y; 378 int c_x, c_y;
535 379
536 eo_do(obj, elm_atspi_component_interface_extents_get(&c_x, &c_y, NULL, NULL, ATSPI_COORD_TYPE_WINDOW)); 380 eo_do(obj, elm_atspi_component_interface_extents_get(&c_x, &c_y, NULL, NULL, ATSPI_COORD_TYPE_WINDOW));
@@ -540,8 +384,8 @@ _comp_interface_size_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *li
540static void 384static void
541_comp_interface_size_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 385_comp_interface_size_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
542{ 386{
543 EO_PARAMETER_GET(int*, w, list); 387 int *w = ARG_GET(list, int*);
544 EO_PARAMETER_GET(int*, h, list); 388 int *h = ARG_GET(list, int*);
545 389
546 eo_do(obj, elm_atspi_component_interface_extents_get(NULL, NULL, w, h, ATSPI_COORD_TYPE_WINDOW)); 390 eo_do(obj, elm_atspi_component_interface_extents_get(NULL, NULL, w, h, ATSPI_COORD_TYPE_WINDOW));
547} 391}
@@ -549,25 +393,32 @@ _comp_interface_size_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *li
549static void 393static void
550_comp_interface_contains(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list) 394_comp_interface_contains(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
551{ 395{
552 EO_PARAMETER_GET(int, x, list); 396 int x = ARG_GET(list, int);
553 EO_PARAMETER_GET(int, y, list); 397 int y = ARG_GET(list, int);
554 EO_PARAMETER_GET(AtspiCoordType, type, list); 398 AtspiCoordType type = ARG_GET(list, AtspiCoordType);
555 EO_PARAMETER_GET(Eina_Bool*, ret, list); 399 Eina_Bool *ret = ARG_GET(list, Eina_Bool*);
556 int w_x, w_y, w_w, w_h; 400 int w_x, w_y, w_w, w_h;
557 401
558 if (ret) *ret = EINA_FALSE; 402 *ret = EINA_FALSE;
559 403
560 if (!eo_do(obj, elm_atspi_component_interface_extents_get(&w_x, &w_y, &w_w, &w_h, type))) 404 if (!eo_do(obj, elm_atspi_component_interface_extents_get(&w_x, &w_y, &w_w, &w_h, type)))
561 return; 405 return;
562 406
563 if ((x >= w_x) && (x <= w_x + w_w) && (y >= w_y) && (y <= w_y + w_h)) 407 if ((x >= w_x) && (x <= w_x + w_w) && (y >= w_y) && (y <= w_y + w_h))
564 if (ret) *ret = EINA_TRUE; 408 *ret = EINA_TRUE;
409}
410
411static void
412_component_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
413{
414 eo_do_super(obj, ELM_ATSPI_COMPONENT_INTERFACE, eo_constructor());
565} 415}
566 416
567static void 417static void
568_component_interface_constructor(Eo_Class *klass) 418_component_interface_constructor(Eo_Class *klass)
569{ 419{
570 const Eo_Op_Func_Description func_desc[] = { 420 const Eo_Op_Func_Description func_desc[] = {
421 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _component_constructor),
571 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_POSITION_GET), _comp_interface_position_get), 422 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_POSITION_GET), _comp_interface_position_get),
572 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_POSITION_SET), _comp_interface_position_set), 423 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_POSITION_SET), _comp_interface_position_set),
573 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_CONTAINS), _comp_interface_contains), 424 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_CONTAINS), _comp_interface_contains),
@@ -608,174 +459,232 @@ static const Eo_Class_Description component_interface_desc = {
608 459
609EO_DEFINE_CLASS(elm_atspi_component_interface_get, &component_interface_desc, NULL, NULL); 460EO_DEFINE_CLASS(elm_atspi_component_interface_get, &component_interface_desc, NULL, NULL);
610 461
611// Window Interface 462/// Elm_Atspi_Widget base class
463#define ELM_ATSPI_WIDGET_CLASS elm_atspi_widget_obj_class_get()
612 464
613static const Eo_Event_Description *window_event_desc[] = { 465const Eo_Class *elm_atspi_widget_obj_class_get(void) EINA_CONST;
614 EV_ATSPI_OBJ_WINDOW_ACTIVATED,
615 EV_ATSPI_OBJ_WINDOW_DEACTIVATED,
616 NULL
617};
618 466
619static const Eo_Class_Description window_interface_desc = { 467typedef struct _Access_Widget_Object_Data Access_Widget_Object_Data;
620 EO_VERSION, 468
621 "Elm_Atspi_Window_Interface", 469struct _Access_Widget_Object_Data
622 EO_CLASS_TYPE_INTERFACE, 470{
623 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), 471 Evas_Object *obj;
624 window_event_desc,
625 0,
626 NULL,
627 NULL
628}; 472};
629 473
630EO_DEFINE_CLASS(elm_atspi_window_interface_get, &window_interface_desc, NULL, NULL); 474static void
475_del_ao_obj(void *data, Evas *e EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void *event_info EINA_UNUSED)
476{
477 Elm_Atspi_Object *obj = data;
478 Access_Widget_Object_Data *ad = eo_data_scope_get(obj, ELM_ATSPI_WIDGET_CLASS);
479 ad->obj = NULL;
480 // below will cause Accessibility object destruction while evas object is destroyed and access object has none extra refs
481 eo_unref(obj);
482}
631 483
632/// Elm_Atspi_Widget base class
633static void 484static void
634_emit_atspi_state_changed_focused_event(void *data, Evas_Object *eo EINA_UNUSED, void *event_info EINA_UNUSED) 485_widget_constructor(Eo *obj, void *_pd, va_list *list)
635{ 486{
636 Elm_Atspi_Object *ao = data; 487 Evas_Object *widget = ARG_GET(list, Evas_Object*);
637 int evdata[2] = {ATSPI_STATE_FOCUSED, 1}; 488 Access_Widget_Object_Data *ad = _pd;
638 eo_do(ao, eo_event_callback_call(EV_ATSPI_OBJ_STATE_CHANGED, &evdata[0], NULL)); 489 const char *name;
490
491 eo_do_super(obj, ELM_ATSPI_WIDGET_CLASS, eo_constructor());
492 name = evas_object_type_get(widget);
493
494 evas_object_event_callback_add(widget, EVAS_CALLBACK_DEL, _del_ao_obj, obj);
495
496 ad->obj = widget;
497 eo_do(obj, elm_atspi_obj_name_set(name));
498 eo_do(obj, elm_atspi_obj_role_set(ATSPI_ROLE_UNKNOWN));
639} 499}
640 500
641static void 501static void
642_emit_atspi_state_changed_unfocused_event(void *data, Evas_Object *eo EINA_UNUSED, void *event_info EINA_UNUSED) 502_widget_destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
643{ 503{
644 Elm_Atspi_Object *ao = data; 504 Access_Widget_Object_Data *ad = _pd;
645 int evdata[2] = {ATSPI_STATE_FOCUSED, 0}; 505 if (ad->obj)
646 eo_do(ao, eo_event_callback_call(EV_ATSPI_OBJ_STATE_CHANGED, &evdata[0], NULL)); 506 evas_object_event_callback_del(ad->obj, EVAS_CALLBACK_DEL, _del_ao_obj);
507
508 eo_do_super(obj, ELM_ATSPI_WIDGET_CLASS, eo_destructor());
647} 509}
648 510
649static void 511static void
650_widget_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 512_widget_children_get(Eo *obj, void *_pd, va_list *list)
651{ 513{
652 Evas_Object *internal_obj = NULL; 514 Eina_List **ret = ARG_GET(list, Eina_List**);
653 eo_do_super(obj, ELM_ATSPI_WIDGET_CLASS, eo_constructor()); 515 Access_Widget_Object_Data *ad = _pd;
516 Eina_List *l, *al = NULL;
517 Evas_Object *sub;
518 Elm_Atspi_Object *ao;
519 Elm_Widget_Smart_Data *sd;
654 520
655 eo_do(obj, eo_parent_get(&internal_obj)); 521 EINA_SAFETY_ON_NULL_GOTO(ad->obj, fail);
656 522
657 /* Evas_Object can only hold refs to atspi-object */ 523 sd = eo_data_scope_get(ad->obj, ELM_OBJ_WIDGET_CLASS);
658 assert(eo_isa(internal_obj, ELM_OBJ_WIDGET_CLASS)); 524 EINA_SAFETY_ON_NULL_GOTO(sd, fail);
525
526 EINA_LIST_FOREACH(sd->subobjs, l, sub) {
527 if (!sub) continue;
528 ao = _elm_atspi_factory_construct(sub, obj);
529 if (ao)
530 al = eina_list_append(al, ao);
531 }
659 532
660 evas_object_smart_callback_add(internal_obj, "focused", _emit_atspi_state_changed_focused_event, obj); 533 *ret = al;
661 evas_object_smart_callback_add(internal_obj, "unfocused", _emit_atspi_state_changed_unfocused_event, obj); 534 return;
535
536fail:
537 *ret = NULL;
538 return;
662} 539}
663 540
541
664static void 542static void
665_widget_name_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 543_widget_state_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
666{ 544{
667 EO_PARAMETER_GET(const char **, ret, list); 545 // FIXME
668 Evas_Object *widget = NULL;
669 const char *name = NULL;
670
671 eo_do(obj, elm_atspi_obj_object_get(&widget));
672 name = elm_object_text_get(widget);
673 if (ret) *ret = name;
674} 546}
675 547
548
676static void 549static void
677_widget_role_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 550_widget_comp_access_at_point_get(Eo *obj, void *_pd, va_list *list)
678{ 551{
679 EO_PARAMETER_GET(AtspiRole*, ret, list); 552 int x = ARG_GET(list, int);
680 const char *type; 553 int y = ARG_GET(list, int);
681 AtspiRole role; 554 AtspiCoordType type = ARG_GET(list, AtspiCoordType);
682 Evas_Object *widget = NULL; 555 Elm_Atspi_Object **ret = ARG_GET(list, Elm_Atspi_Object**);
683 eo_do(obj, elm_atspi_obj_object_get(&widget)); 556 int ee_x, ee_y;
684 if (!widget) return; 557 Access_Widget_Object_Data *ad = _pd;
685 type = evas_object_type_get(widget); 558 Eina_List *l, *objs;
686 559 Evas_Object *wid;
687 // FIXME make it hash or cast some first bytes to int.
688 if (!strcmp(type, "elm_win"))
689 role = ATSPI_ROLE_WINDOW;
690 else if (!strcmp(type, "elm_button"))
691 role = ATSPI_ROLE_PUSH_BUTTON;
692 else
693 role = ATSPI_ROLE_UNKNOWN;
694 560
695 if (ret) *ret = role; 561 if (ad->obj)
562 {
563 if (type == ATSPI_COORD_TYPE_SCREEN)
564 {
565 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(ad->obj));
566 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
567 x -= ee_x;
568 y -= ee_y;
569 }
570 objs = evas_objects_at_xy_get(evas_object_evas_get(ad->obj), x, y, EINA_TRUE, EINA_TRUE);
571 EINA_LIST_FOREACH(objs, l, wid)
572 {
573 // return first only
574 if (elm_object_widget_check(wid))
575 {
576 *ret = _elm_atspi_factory_construct(wid, obj);
577 break;
578 }
579 }
580 eina_list_free(objs);
581 }
696} 582}
697 583
698static void 584static void
699_widget_parent_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 585_widget_comp_extents_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
700{ 586{
701 EO_PARAMETER_GET(Elm_Atspi_Object **, ret, list); 587 Access_Widget_Object_Data *ad = _pd;
702 Evas_Object *widget = NULL; 588 int *x, *y, *w, *h;
703 Elm_Atspi_Object *parent; 589 int ee_x, ee_y;
704 590 x = ARG_GET(list, int*);
705 eo_do(obj, elm_atspi_obj_object_get(&widget)); 591 y = ARG_GET(list, int*);
706 widget = elm_object_parent_widget_get(widget); 592 w = ARG_GET(list, int*);
707 593 h = ARG_GET(list, int*);
708 if (widget) 594 AtspiCoordType type = ARG_GET(list, AtspiCoordType);
709 parent = _elm_atspi_factory_construct(widget);
710 else // if parent is not found, attach it to atspi root object.
711 parent = _elm_atspi_root_object_get();
712 595
713 if (ret) *ret = parent; 596 if (ad->obj)
597 {
598 evas_object_geometry_get(ad->obj, x, y, w, h);
599 if (type == ATSPI_COORD_TYPE_SCREEN)
600 {
601 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(ad->obj));
602 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
603 if (x) *x += ee_x;
604 if (y) *y += ee_y;
605 }
606 }
714} 607}
715 608
716static void 609static void
717_widget_children_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 610_widget_comp_extents_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
718{ 611{
719 EO_PARAMETER_GET(Eina_List **, ret, list); 612 Access_Widget_Object_Data *ad = _pd;
720 Evas_Object *widget = NULL; 613 int x, y, w, h;
721 Eina_List *l, *accs = NULL; 614 int wx, wy;
722 Elm_Widget_Smart_Data *sd; 615 x = ARG_GET(list, int);
723 Elm_Atspi_Object *aobj; 616 y = ARG_GET(list, int);
617 w = ARG_GET(list, int);
618 h = ARG_GET(list, int);
619 AtspiCoordType type = ARG_GET(list, AtspiCoordType);
620 Eina_Bool *ret = ARG_GET(list, Eina_Bool*);
724 621
725 eo_do(obj, elm_atspi_obj_object_get(&widget)); 622 *ret = EINA_FALSE;
726 623
727 sd = eo_data_scope_get(widget, ELM_OBJ_WIDGET_CLASS); 624 if ((x < 0) || (y < 0) || (w < 0) || (h < 0)) return;
728 if (!sd) return;
729 625
730 EINA_LIST_FOREACH(sd->subobjs, l, widget) 626 if (ad->obj)
731 { 627 {
732 if (!elm_object_widget_check(widget)) continue; 628 if (type == ATSPI_COORD_TYPE_SCREEN)
733 aobj = _elm_atspi_factory_construct(widget); 629 {
734 if (aobj) 630 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(ad->obj));
735 accs = eina_list_append(accs, aobj); 631 evas_object_geometry_get(ad->obj, &wx, &wy, NULL, NULL);
632 ecore_evas_move(ee, x - wx, y - wy);
633 }
634 else
635 evas_object_move(ad->obj, x, y);
636
637 evas_object_resize(ad->obj, w, h);
638 *ret = EINA_TRUE;
736 } 639 }
737 if (ret) 640}
738 *ret = accs; 641
739 else 642
740 eina_list_free(accs); 643static void
644_widget_comp_layer_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
645{
646 int *l = ARG_GET(list, int *);
647 Access_Widget_Object_Data *ad = _pd;
648
649 if (ad->obj)
650 *l = evas_object_layer_get(ad->obj);
651}
652
653static void
654_widget_comp_z_order_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
655{
656 // FIXME
741} 657}
742 658
743static void 659static void
744_widget_state_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 660_widget_comp_focus_grab(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
745{ 661{
746 EO_PARAMETER_GET(Elm_Atspi_State *, ret, list); 662 Eina_Bool *ret = ARG_GET(list, Eina_Bool*);
747 Evas_Object *widget; 663 Access_Widget_Object_Data *ad = _pd;
748 Elm_Atspi_State states;
749 eo_do(obj, elm_atspi_obj_object_get(&widget));
750 664
751 eo_do_super(obj, ELM_ATSPI_WIDGET_CLASS, elm_atspi_obj_state_get(&states)); 665 *ret = EINA_FALSE;
752 666
753 if (elm_object_focus_get(widget)) 667 if (ad->obj && elm_object_focus_allow_get(ad->obj))
754 BIT_FLAG_SET(states, ATSPI_STATE_FOCUSED); 668 {
755 if (elm_object_focus_allow_get(widget)) 669 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(ad->obj));
756 BIT_FLAG_SET(states, ATSPI_STATE_FOCUSABLE);
757 if (!elm_object_disabled_get(widget))
758 BIT_FLAG_SET(states, ATSPI_STATE_ENABLED);
759 670
760 if (ret) *ret = states; 671 ecore_evas_activate(ee);
672 elm_object_focus_set(ad->obj, EINA_TRUE);
673 *ret = EINA_TRUE;
674 }
761} 675}
762 676
763static void 677static void
764_widget_comp_focus_grab(Eo *obj, void *_pd EINA_UNUSED, va_list *list) 678_widget_comp_alpha_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
765{ 679{
766 EO_PARAMETER_GET(Eina_Bool*, ret, list); 680 double *ret = ARG_GET(list, double*);
767 Evas_Object *evobj = NULL; 681 int alpha;
768 if (ret) *ret = EINA_FALSE; 682 Access_Widget_Object_Data *ad = _pd;
769 683
770 eo_do(obj, elm_atspi_obj_object_get(&evobj)); 684 if (ad->obj)
771 EINA_SAFETY_ON_NULL_RETURN(evobj);
772 if (elm_object_focus_allow_get(evobj))
773 { 685 {
774 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(evobj)); 686 evas_object_color_get(ad->obj, NULL, NULL, NULL, &alpha);
775 if (!ee) return; 687 *ret = (double)alpha/255.0;
776 ecore_evas_activate(ee);
777 elm_object_focus_set(evobj, EINA_TRUE);
778 if (ret) *ret = EINA_TRUE;
779 } 688 }
780} 689}
781 690
@@ -784,12 +693,16 @@ _widget_class_constructor(Eo_Class *klass)
784{ 693{
785 const Eo_Op_Func_Description func_desc[] = { 694 const Eo_Op_Func_Description func_desc[] = {
786 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _widget_constructor), 695 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _widget_constructor),
787 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_NAME_GET), _widget_name_get), 696 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _widget_destructor),
788 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_GET), _widget_role_get),
789 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_PARENT_GET), _widget_parent_get),
790 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_CHILDREN_GET), _widget_children_get), 697 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_CHILDREN_GET), _widget_children_get),
791 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_STATE_GET), _widget_state_get), 698 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_STATE_GET), _widget_state_get),
699 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_ACCESSIBLE_AT_POINT_GET), _widget_comp_access_at_point_get),
700 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_EXTENTS_GET), _widget_comp_extents_get),
701 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_EXTENTS_SET), _widget_comp_extents_set),
702 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_LAYER_GET), _widget_comp_layer_get),
703 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_Z_ORDER_GET), _widget_comp_z_order_get),
792 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_FOCUS_GRAB), _widget_comp_focus_grab), 704 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_FOCUS_GRAB), _widget_comp_focus_grab),
705 EO_OP_FUNC(ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_ALPHA_GET), _widget_comp_alpha_get),
793 EO_OP_FUNC_SENTINEL 706 EO_OP_FUNC_SENTINEL
794 }; 707 };
795 eo_class_funcs_set(klass, func_desc); 708 eo_class_funcs_set(klass, func_desc);
@@ -797,65 +710,77 @@ _widget_class_constructor(Eo_Class *klass)
797 710
798static const Eo_Class_Description widget_class_desc = { 711static const Eo_Class_Description widget_class_desc = {
799 EO_VERSION, 712 EO_VERSION,
800 "Elm_Widget_Access_Object", 713 "Elm_Widget Access_Object",
801 EO_CLASS_TYPE_REGULAR, 714 EO_CLASS_TYPE_REGULAR,
802 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), 715 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
803 NULL, 716 NULL,
804 0, 717 sizeof(Access_Widget_Object_Data),
805 _widget_class_constructor, 718 _widget_class_constructor,
806 NULL 719 NULL
807}; 720};
808 721
809EO_DEFINE_CLASS(elm_atspi_widget_obj_class_get, &widget_class_desc, ELM_ATSPI_CLASS, NULL); 722EO_DEFINE_CLASS(elm_atspi_widget_obj_class_get, &widget_class_desc, ELM_ATSPI_CLASS, ELM_ATSPI_COMPONENT_INTERFACE, NULL);
810 723
724static Elm_Atspi_Object *
725_elm_atspi_factory_construct(Evas_Object *obj, Elm_Atspi_Object *parent)
726{
727 Elm_Atspi_Object *ret;
728 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
729 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
730
731 if (!elm_object_widget_check(obj))
732 return NULL;
733
734 if (!strcmp(evas_object_type_get(obj), "elm_access"))
735 return NULL;
736
737 ret = evas_object_data_get(obj, "_atspi_object");
738 if (!ret)
739 {
740 ret = eo_add(ELM_ATSPI_WIDGET_CLASS, parent, obj);
741 evas_object_data_set(obj, "_atspi_object", ret);
742 eo_unref(ret); // only parent should hold reference to atspi object
743 }
744 else
745 {
746 Elm_Atspi_Object *tmp;
747 eo_do(ret, eo_parent_get(&tmp));
748 if (!tmp)
749 eo_do(ret, eo_parent_set(parent));
750 }
751
752 return ret;
753}
811 754
812/// Elm_Atspi_App base class 755/// Elm_Atspi_App base class
756const Eo_Class *elm_atspi_app_obj_class_get(void) EINA_CONST;
813#define ELM_ATSPI_APP_CLASS elm_atspi_app_obj_class_get() 757#define ELM_ATSPI_APP_CLASS elm_atspi_app_obj_class_get()
814 758
815static void 759static void
816_app_children_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list) 760_app_children_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
817{ 761{
818 EO_PARAMETER_GET(Eina_List **, ret, list); 762 Eina_List **ret = ARG_GET(list, Eina_List**);
819 Eina_List *l, *accs = NULL; 763 Eina_List *l, *objs = NULL;
820 Elm_Atspi_Object *aobj;
821 Evas_Object *win; 764 Evas_Object *win;
765 Elm_Atspi_Object *o = NULL;
822 766
823 EINA_LIST_FOREACH(_elm_win_list, l, win) 767 EINA_LIST_FOREACH(_elm_win_list, l, win)
824 { 768 {
825 if (!win) continue; 769 if (!win) continue;
826 aobj = _elm_atspi_factory_construct(win); 770 o = _elm_atspi_factory_construct(win, obj);
827 if (aobj) 771 if (o)
828 accs = eina_list_append(accs, aobj); 772 objs = eina_list_append(objs, o);
829 } 773 }
830 774 *ret = objs;
831 if (ret) *ret = accs;
832} 775}
833 776
834static void 777static void
835_app_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 778_app_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
836{ 779{
837 eo_do_super(obj, ELM_ATSPI_CLASS, eo_constructor()); 780 eo_do_super(obj, ELM_ATSPI_APP_CLASS, eo_constructor());
838}
839 781
840static void 782 eo_do(obj, elm_atspi_obj_name_set(elm_app_name_get()));
841_app_name_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 783 eo_do(obj, elm_atspi_obj_role_set(ATSPI_ROLE_APPLICATION));
842{
843 EO_PARAMETER_GET(const char **, name, list);
844 if (name) *name = elm_app_name_get();
845}
846
847static void
848_app_role_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
849{
850 EO_PARAMETER_GET(AtspiRole *, ret, list);
851 if (ret) *ret = ATSPI_ROLE_APPLICATION;
852}
853
854static void
855_app_parent_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
856{
857 EO_PARAMETER_GET(Elm_Atspi_Object **, ret, list);
858 if (ret) *ret = NULL;
859} 784}
860 785
861static void 786static void
@@ -863,9 +788,6 @@ _app_class_constructor(Eo_Class *klass)
863{ 788{
864 const Eo_Op_Func_Description func_desc[] = { 789 const Eo_Op_Func_Description func_desc[] = {
865 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _app_constructor), 790 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _app_constructor),
866 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_NAME_GET), _app_name_get),
867 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_GET), _app_role_get),
868 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_PARENT_GET), _app_parent_get),
869 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_CHILDREN_GET), _app_children_get), 791 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_CHILDREN_GET), _app_children_get),
870 EO_OP_FUNC_SENTINEL 792 EO_OP_FUNC_SENTINEL
871 }; 793 };
@@ -878,7 +800,7 @@ static const Eo_Op_Description app_op_desc[] = {
878 800
879static const Eo_Class_Description app_class_desc = { 801static const Eo_Class_Description app_class_desc = {
880 EO_VERSION, 802 EO_VERSION,
881 "Elm_App_Access_Object", 803 "App Access_Object",
882 EO_CLASS_TYPE_REGULAR, 804 EO_CLASS_TYPE_REGULAR,
883 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), 805 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
884 NULL, 806 NULL,
@@ -889,165 +811,14 @@ static const Eo_Class_Description app_class_desc = {
889 811
890EO_DEFINE_CLASS(elm_atspi_app_obj_class_get, &app_class_desc, ELM_ATSPI_CLASS, NULL); 812EO_DEFINE_CLASS(elm_atspi_app_obj_class_get, &app_class_desc, ELM_ATSPI_CLASS, NULL);
891 813
892// elm_win wrapper 814Elm_Atspi_Object * elm_atspi_root_object_get(void)
893
894const Eo_Class *elm_atspi_win_obj_class_get(void) EINA_CONST;
895#define ELM_ATSPI_WIN_CLASS elm_atspi_win_obj_class_get()
896
897static void
898_win_focused(void *data, Evas_Object *eo EINA_UNUSED, void *event_info EINA_UNUSED)
899{
900 Elm_Atspi_Object *ao = data;
901 eo_do(ao, eo_event_callback_call(EV_ATSPI_OBJ_WINDOW_ACTIVATED, NULL, NULL));
902}
903
904static void
905_win_unfocused(void *data, Evas_Object *eo EINA_UNUSED, void *event_info EINA_UNUSED)
906{ 815{
907 Elm_Atspi_Object *ao = data; 816 static Elm_Atspi_Object *app;
908 eo_do(ao, eo_event_callback_call(EV_ATSPI_OBJ_WINDOW_DEACTIVATED, NULL, NULL));
909}
910 817
911static void 818 if (!app)
912_win_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 819 app = eo_add(ELM_ATSPI_APP_CLASS, NULL);
913{
914 eo_do_super(obj, ELM_ATSPI_WIN_CLASS, eo_constructor());
915 Evas_Object *evobj = NULL;
916
917 eo_do(obj, elm_atspi_obj_object_get(&evobj));
918
919 evas_object_smart_callback_add(evobj, "focused", _win_focused, obj);
920 evas_object_smart_callback_add(evobj, "unfocused", _win_unfocused, obj);
921}
922
923static void
924_win_destructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
925{
926 Elm_Atspi_Object *root = _elm_atspi_root_object_get();
927 eo_do(root, eo_event_callback_call(EV_ATSPI_OBJ_CHILD_DEL, obj, NULL));
928
929 eo_do_super(obj, ELM_ATSPI_WIN_CLASS, eo_destructor());
930}
931
932static void
933_win_name_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
934{
935 EO_PARAMETER_GET(const char **, ret, list);
936 Evas_Object *evobj = NULL;
937
938 eo_do(obj, elm_atspi_obj_object_get(&evobj));
939 EINA_SAFETY_ON_NULL_RETURN(evobj);
940
941 if (ret) *ret = elm_win_title_get(evobj);
942}
943
944static void
945_win_parent_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
946{
947 EO_PARAMETER_GET(Elm_Atspi_Object **, ret, list);
948 if (ret) *ret = _elm_atspi_root_object_get();
949}
950
951static void
952_win_class_constructor(Eo_Class *klass)
953{
954 const Eo_Op_Func_Description func_desc[] = {
955 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _win_constructor),
956 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _win_destructor),
957 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_NAME_GET), _win_name_get),
958 EO_OP_FUNC(ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_PARENT_GET), _win_parent_get),
959 EO_OP_FUNC_SENTINEL
960 };
961 eo_class_funcs_set(klass, func_desc);
962}
963
964static const Eo_Class_Description win_class_desc = {
965 EO_VERSION,
966 "Elm_Win_Access_Object",
967 EO_CLASS_TYPE_REGULAR,
968 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
969 NULL,
970 0,
971 _win_class_constructor,
972 NULL
973};
974
975EO_DEFINE_CLASS(elm_atspi_win_obj_class_get, &win_class_desc, ELM_ATSPI_WIDGET_CLASS, ELM_ATSPI_WINDOW_INTERFACE, NULL);
976
977Elm_Atspi_Object*
978_elm_atspi_root_object_get(void)
979{
980 if (!_app)
981 _app = eo_add(ELM_ATSPI_APP_CLASS, NULL);
982 else 820 else
983 eo_ref(_app); 821 eo_ref(app);
984
985 return _app;
986}
987
988Elm_Atspi_Object *
989_elm_atspi_factory_construct(Evas_Object *obj)
990{
991 Elm_Atspi_Object *ret;
992 const char *type;
993
994 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
995
996 ret = evas_object_data_get(obj, "_atspi_object");
997 if (ret) return ret;
998 822
999 type = evas_object_type_get(obj); 823 return app;
1000
1001 //FIXME add possibility to install new handlers
1002 if (!strcmp(type, "elm_access"))
1003 {
1004 DBG("Unable to create ATSPI object for elm_access widget.");
1005 return NULL;
1006 }
1007 else if (!strcmp(type, "elm_win"))
1008 ret = eo_add(ELM_ATSPI_WIN_CLASS, obj);
1009 else if (!strncmp(type, "elm_", 4)) // defaults to implementation for elm_widget class.
1010 ret = eo_add(ELM_ATSPI_WIDGET_CLASS, obj);
1011
1012 eo_unref(ret); // only evas_object should hold reference to atspi object
1013
1014 return ret;
1015}
1016
1017void _elm_atspi_object_init(void)
1018{
1019}
1020
1021void _elm_atspi_object_shutdown(void)
1022{
1023 Elm_Atspi_Global_Callback_Info *info;
1024 if (_app)
1025 eo_del(_app);
1026
1027 EINA_LIST_FREE(_global_callbacks, info)
1028 free(info);
1029 _global_callbacks = NULL;
1030}
1031
1032void _elm_atspi_object_global_callback_add(Eo_Event_Cb cb, void *user_data)
1033{
1034 Elm_Atspi_Global_Callback_Info *info = calloc(1, sizeof(Elm_Atspi_Global_Callback_Info));
1035 if (!info) return;
1036 info->user_data = user_data;
1037 info->cb = cb;
1038 _global_callbacks = eina_list_append(_global_callbacks, info);
1039}
1040
1041void _elm_atspi_object_global_callback_del(Eo_Event_Cb cb)
1042{
1043 Elm_Atspi_Global_Callback_Info *info;
1044 Eina_List *l;
1045 EINA_LIST_FOREACH(_global_callbacks, l, info)
1046 {
1047 if ((info->cb == cb))
1048 {
1049 _global_callbacks = eina_list_remove(_global_callbacks, info);
1050 free(info);
1051 }
1052 }
1053} 824}
diff --git a/src/lib/elm_atspi_object_common.h b/src/lib/elm_atspi_object_common.h
index 767f74bb7..fdc533b48 100644
--- a/src/lib/elm_atspi_object_common.h
+++ b/src/lib/elm_atspi_object_common.h
@@ -1,24 +1 @@
1typedef Eo Elm_Atspi_Object; typedef Eo Elm_Atspi_Object;
2
3typedef uint64_t Elm_Atspi_State;
4
5typedef enum _Elm_Atspi_Event Elm_Atspi_Event;
6
7#define BIT_FLAG_SET(mask, bit) (mask |= (1 << bit))
8#define BIT_FLAG_UNSET(mask, bit) (mask &= ~(1 << bit))
9#define BIT_FLAG_GET(mask, bit) (mask & (1 << bit))
10
11/*
12 * @brief Gets root (application) type atspi-object.
13 */
14Elm_Atspi_Object * _elm_atspi_root_object_get(void);
15
16/*
17 * @brief Constructs atspi-object for evas_object
18 */
19Elm_Atspi_Object * _elm_atspi_factory_construct(Evas_Object *obj);
20
21void _elm_atspi_object_init(void);
22
23void _elm_atspi_object_shutdown(void);
24
diff --git a/src/lib/elm_atspi_object_eo.h b/src/lib/elm_atspi_object_eo.h
index d1ff2b7a2..67a07c697 100644
--- a/src/lib/elm_atspi_object_eo.h
+++ b/src/lib/elm_atspi_object_eo.h
@@ -1,47 +1,32 @@
1void _elm_atspi_object_global_callback_add(Eo_Event_Cb cv, void *user_data);
2void _elm_atspi_object_global_callback_del(Eo_Event_Cb cv);
3
4#define ELM_ATSPI_CLASS elm_atspi_obj_class_get() 1#define ELM_ATSPI_CLASS elm_atspi_obj_class_get()
5const Eo_Class *elm_atspi_obj_class_get(void) EINA_CONST;
6 2
7#define ELM_ATSPI_WIDGET_CLASS elm_atspi_widget_obj_class_get() 3const Eo_Class *elm_atspi_obj_class_get(void) EINA_CONST;
8const Eo_Class *elm_atspi_widget_obj_class_get(void) EINA_CONST;
9 4
10extern EAPI Eo_Op ELM_ATSPI_OBJ_BASE_ID; 5extern EAPI Eo_Op ELM_ATSPI_OBJ_BASE_ID;
11 6
12enum 7enum
13{ 8{
14 ELM_ATSPI_OBJ_SUB_ID_NAME_GET, /* virtual */ 9 ELM_ATSPI_OBJ_SUB_ID_NAME_GET,
15 ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_GET, /* virtual */ 10 ELM_ATSPI_OBJ_SUB_ID_NAME_SET,
11 ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_GET,
12 ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_SET,
13 ELM_ATSPI_OBJ_SUB_ID_PARENT_GET,
16 ELM_ATSPI_OBJ_SUB_ID_CHILD_AT_INDEX_GET, 14 ELM_ATSPI_OBJ_SUB_ID_CHILD_AT_INDEX_GET,
17 ELM_ATSPI_OBJ_SUB_ID_CHILDREN_GET, /* virtual */ 15 ELM_ATSPI_OBJ_SUB_ID_CHILDREN_GET,
18 ELM_ATSPI_OBJ_SUB_ID_PARENT_GET, /* virtual */
19 ELM_ATSPI_OBJ_SUB_ID_OBJECT_GET,
20 ELM_ATSPI_OBJ_SUB_ID_INDEX_IN_PARENT_GET, 16 ELM_ATSPI_OBJ_SUB_ID_INDEX_IN_PARENT_GET,
21 ELM_ATSPI_OBJ_SUB_ID_RELATION_SET_GET, /* virtual */ 17 ELM_ATSPI_OBJ_SUB_ID_RELATION_SET_GET,
22 ELM_ATSPI_OBJ_SUB_ID_ROLE_GET, /* virtual */ 18 ELM_ATSPI_OBJ_SUB_ID_RELATION_SET_SET,
19 ELM_ATSPI_OBJ_SUB_ID_ROLE_GET,
20 ELM_ATSPI_OBJ_SUB_ID_ROLE_SET,
23 ELM_ATSPI_OBJ_SUB_ID_ROLE_NAME_GET, 21 ELM_ATSPI_OBJ_SUB_ID_ROLE_NAME_GET,
24 ELM_ATSPI_OBJ_SUB_ID_LOCALIZED_ROLE_NAME_GET, 22 ELM_ATSPI_OBJ_SUB_ID_LOCALIZED_ROLE_NAME_GET,
25 ELM_ATSPI_OBJ_SUB_ID_STATE_GET, /* virtual */ 23 ELM_ATSPI_OBJ_SUB_ID_STATE_GET,
26 ELM_ATSPI_OBJ_SUB_ID_ATTRIBUTES_GET, /* virtual */ 24 ELM_ATSPI_OBJ_SUB_ID_ATTRIBUTES_GET,
27 ELM_ATSPI_OBJ_SUB_ID_LAST 25 ELM_ATSPI_OBJ_SUB_ID_LAST
28}; 26};
29 27
30#define ELM_ATSPI_OBJ_ID(sub_id) (ELM_ATSPI_OBJ_BASE_ID + sub_id) 28#define ELM_ATSPI_OBJ_ID(sub_id) (ELM_ATSPI_OBJ_BASE_ID + sub_id)
31 29
32/* Elm_Atspi_Object events */
33extern const Eo_Event_Description _EV_ATSPI_OBJ_NAME_CHANGED;
34#define EV_ATSPI_OBJ_NAME_CHANGED (&(_EV_ATSPI_OBJ_NAME_CHANGED))
35
36extern const Eo_Event_Description _EV_ATSPI_OBJ_CHILD_ADD;
37#define EV_ATSPI_OBJ_CHILD_ADD (&(_EV_ATSPI_OBJ_CHILD_ADD))
38
39extern const Eo_Event_Description _EV_ATSPI_OBJ_CHILD_DEL;
40#define EV_ATSPI_OBJ_CHILD_DEL (&(_EV_ATSPI_OBJ_CHILD_DEL))
41
42extern const Eo_Event_Description _EV_ATSPI_OBJ_STATE_CHANGED;
43#define EV_ATSPI_OBJ_STATE_CHANGED (&(_EV_ATSPI_OBJ_STATE_CHANGED))
44
45/* Component Interface */ 30/* Component Interface */
46#define ELM_ATSPI_COMPONENT_INTERFACE elm_atspi_component_interface_get() 31#define ELM_ATSPI_COMPONENT_INTERFACE elm_atspi_component_interface_get()
47 32
@@ -69,17 +54,6 @@ enum
69#define ELM_ATSPI_COMPONENT_INTERFACE_ID(sub_id) (ELM_ATSPI_COMPONENT_INTERFACE_BASE_ID + sub_id) 54#define ELM_ATSPI_COMPONENT_INTERFACE_ID(sub_id) (ELM_ATSPI_COMPONENT_INTERFACE_BASE_ID + sub_id)
70/* Component Interface - END */ 55/* Component Interface - END */
71 56
72/* Window Interface */
73#define ELM_ATSPI_WINDOW_INTERFACE elm_atspi_window_interface_get()
74const Eo_Class *elm_atspi_window_interface_get(void) EINA_CONST;
75
76extern const Eo_Event_Description _EV_ATSPI_OBJ_WINDOW_ACTIVATED;
77#define EV_ATSPI_OBJ_WINDOW_ACTIVATED (&(_EV_ATSPI_OBJ_WINDOW_ACTIVATED))
78
79extern const Eo_Event_Description _EV_ATSPI_OBJ_WINDOW_DEACTIVATED;
80#define EV_ATSPI_OBJ_WINDOW_DEACTIVATED (&(_EV_ATSPI_OBJ_WINDOW_DEACTIVATED))
81/* Window Interface - END */
82
83/* Action Interface */ 57/* Action Interface */
84#define ELM_ATSPI_ACTION_INTERFACE elm_accessible_action_interface_get() 58#define ELM_ATSPI_ACTION_INTERFACE elm_accessible_action_interface_get()
85 59
@@ -134,7 +108,6 @@ enum
134}; 108};
135/* Text Interface - END */ 109/* Text Interface - END */
136 110
137
138/* EditableText Interface */ 111/* EditableText Interface */
139#define ELM_ATSPI_EDITABLE_TEXT_INTERFACE elm_accessible_editable_text_interface_get() 112#define ELM_ATSPI_EDITABLE_TEXT_INTERFACE elm_accessible_editable_text_interface_get()
140 113
@@ -154,9 +127,10 @@ enum
154}; 127};
155/* EditableText Interface - END */ 128/* EditableText Interface - END */
156 129
157/* Value Interface */
158#define ELM_ATSPI_VALUE_INTERFACE elm_accessible_value_interface_get() 130#define ELM_ATSPI_VALUE_INTERFACE elm_accessible_value_interface_get()
159 131
132
133/* Value Interface */
160const Eo_Class *elm_accessible_value_interface_get(void) EINA_CONST; 134const Eo_Class *elm_accessible_value_interface_get(void) EINA_CONST;
161 135
162extern EAPI Eo_Op ELM_ATSPI_VALUE_INTERFACE_BASE_ID; 136extern EAPI Eo_Op ELM_ATSPI_VALUE_INTERFACE_BASE_ID;
@@ -210,10 +184,18 @@ enum
210 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_NAME_GET), \ 184 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_NAME_GET), \
211 EO_TYPECHECK(const char **, ret) 185 EO_TYPECHECK(const char **, ret)
212 186
187#define elm_atspi_obj_name_set(name)\
188 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_NAME_SET),\
189 EO_TYPECHECK(const char *, name)
190
213#define elm_atspi_obj_role_get(role)\ 191#define elm_atspi_obj_role_get(role)\
214 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_GET), \ 192 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_GET), \
215 EO_TYPECHECK(AtspiRole*, role) 193 EO_TYPECHECK(AtspiRole*, role)
216 194
195#define elm_atspi_obj_role_set(role)\
196 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_SET),\
197 EO_TYPECHECK(AtspiRole, role)
198
217#define elm_atspi_obj_role_name_get(ret)\ 199#define elm_atspi_obj_role_name_get(ret)\
218 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_NAME_GET),\ 200 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ROLE_NAME_GET),\
219 EO_TYPECHECK(const char **, ret) 201 EO_TYPECHECK(const char **, ret)
@@ -226,6 +208,14 @@ enum
226 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_GET),\ 208 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_GET),\
227 EO_TYPECHECK(const char **, ret) 209 EO_TYPECHECK(const char **, ret)
228 210
211#define elm_atspi_obj_description_set(desc)\
212 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_DESCRIPTION_SET),\
213 EO_TYPECHECK(const char *, desc)
214
215#define elm_atspi_obj_parent_get(ret)\
216 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_PARENT_GET),\
217 EO_TYPECHECK(Elm_Atspi_Object**, ret)
218
229#define elm_atspi_obj_child_at_index_get(idx, ret)\ 219#define elm_atspi_obj_child_at_index_get(idx, ret)\
230 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_CHILD_AT_INDEX_GET), \ 220 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_CHILD_AT_INDEX_GET), \
231 EO_TYPECHECK(int, idx),\ 221 EO_TYPECHECK(int, idx),\
@@ -235,14 +225,6 @@ enum
235 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_CHILDREN_GET),\ 225 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_CHILDREN_GET),\
236 EO_TYPECHECK(Eina_List**, ret) 226 EO_TYPECHECK(Eina_List**, ret)
237 227
238#define elm_atspi_obj_parent_get(ret)\
239 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_PARENT_GET),\
240 EO_TYPECHECK(Elm_Atspi_Object**, ret)
241
242#define elm_atspi_obj_object_get(ret)\
243 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_OBJECT_GET),\
244 EO_TYPECHECK(Evas_Object**, ret)
245
246#define elm_atspi_obj_index_in_parent_get(ret)\ 228#define elm_atspi_obj_index_in_parent_get(ret)\
247 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_INDEX_IN_PARENT_GET),\ 229 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_INDEX_IN_PARENT_GET),\
248 EO_TYPECHECK(int*, ret) 230 EO_TYPECHECK(int*, ret)
@@ -251,13 +233,11 @@ enum
251 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_RELATION_SET_GET),\ 233 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_RELATION_SET_GET),\
252 EO_TYPECHECK() 234 EO_TYPECHECK()
253 235
254#define elm_atspi_obj_state_get(ret)\ 236#define elm_atspi_obj_relation_set_set() ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_RELATION_SET_SET), EO_TYPECHECK()
255 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_STATE_GET),\
256 EO_TYPECHECK(Elm_Atspi_State*, ret)
257 237
258#define elm_atspi_obj_attributes_get()\ 238#define elm_atspi_obj_state_get() ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_STATE_GET), EO_TYPECHECK()
259 ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ATTRIBUTES_GET),\ 239
260 EO_TYPECHECK() 240#define elm_atspi_obj_attributes_get() ELM_ATSPI_OBJ_ID(ELM_ATSPI_OBJ_SUB_ID_ATTRIBUTES_GET), EO_TYPECHECK()
261 241
262#define elm_atspi_component_interface_contains(x, y, type, ret)\ 242#define elm_atspi_component_interface_contains(x, y, type, ret)\
263 ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_CONTAINS),\ 243 ELM_ATSPI_COMPONENT_INTERFACE_ID(ELM_ATSPI_COMPONENT_INTERFACE_SUB_ID_CONTAINS),\
diff --git a/src/lib/elm_atspi_object_legacy.h b/src/lib/elm_atspi_object_legacy.h
index 5ec21a383..ea5e93bed 100644
--- a/src/lib/elm_atspi_object_legacy.h
+++ b/src/lib/elm_atspi_object_legacy.h
@@ -1,2 +1 @@
1// to be removed to private: EAPI Elm_Atspi_Object * elm_atspi_root_object_get(void);
2
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index 5671efb13..4cb6010b6 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -6318,19 +6318,6 @@ elm_widget_tree_dot_dump(const Evas_Object *top,
6318#endif 6318#endif
6319} 6319}
6320 6320
6321static Eina_Bool
6322_atspi_obj_create(void *data)
6323{
6324 Elm_Atspi_Object *parent = NULL;
6325 Elm_Atspi_Object *obj = _elm_atspi_factory_construct(data);
6326 if (obj)
6327 {
6328 eo_do(obj, elm_atspi_obj_parent_get(&parent));
6329 eo_do(parent, eo_event_callback_call(EV_ATSPI_OBJ_CHILD_ADD, obj, NULL));
6330 }
6331 return EINA_FALSE;
6332}
6333
6334static void 6321static void
6335_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) 6322_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
6336{ 6323{
@@ -6344,9 +6331,6 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
6344 eo_parent_get(&parent)); 6331 eo_parent_get(&parent));
6345 eo_do(obj, elm_wdg_parent_set(parent)); 6332 eo_do(obj, elm_wdg_parent_set(parent));
6346 sd->on_create = EINA_FALSE; 6333 sd->on_create = EINA_FALSE;
6347
6348 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
6349 ecore_idle_enterer_add(_atspi_obj_create, obj);
6350} 6334}
6351 6335
6352static void 6336static void