diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/ecore/src/lib/ecore_evas/ecore_evas_ews.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_evas/ecore_evas_ews.c | 1454 |
1 files changed, 1454 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_evas/ecore_evas_ews.c b/libraries/ecore/src/lib/ecore_evas/ecore_evas_ews.c new file mode 100644 index 0000000..e19fb05 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_evas/ecore_evas_ews.c | |||
@@ -0,0 +1,1454 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <Ecore.h> | ||
6 | #include "ecore_private.h" | ||
7 | #include <Ecore_Input.h> | ||
8 | |||
9 | #include "ecore_evas_private.h" | ||
10 | #include "Ecore_Evas.h" | ||
11 | |||
12 | EAPI int ECORE_EVAS_EWS_EVENT_MANAGER_CHANGE = 0; | ||
13 | EAPI int ECORE_EVAS_EWS_EVENT_ADD = 0; | ||
14 | EAPI int ECORE_EVAS_EWS_EVENT_DEL = 0; | ||
15 | EAPI int ECORE_EVAS_EWS_EVENT_RESIZE = 0; | ||
16 | EAPI int ECORE_EVAS_EWS_EVENT_MOVE = 0; | ||
17 | EAPI int ECORE_EVAS_EWS_EVENT_SHOW = 0; | ||
18 | EAPI int ECORE_EVAS_EWS_EVENT_HIDE = 0; | ||
19 | EAPI int ECORE_EVAS_EWS_EVENT_FOCUS = 0; | ||
20 | EAPI int ECORE_EVAS_EWS_EVENT_UNFOCUS = 0; | ||
21 | EAPI int ECORE_EVAS_EWS_EVENT_RAISE = 0; | ||
22 | EAPI int ECORE_EVAS_EWS_EVENT_LOWER = 0; | ||
23 | EAPI int ECORE_EVAS_EWS_EVENT_ACTIVATE = 0; | ||
24 | |||
25 | EAPI int ECORE_EVAS_EWS_EVENT_ICONIFIED_CHANGE = 0; | ||
26 | EAPI int ECORE_EVAS_EWS_EVENT_MAXIMIZED_CHANGE = 0; | ||
27 | EAPI int ECORE_EVAS_EWS_EVENT_LAYER_CHANGE = 0; | ||
28 | EAPI int ECORE_EVAS_EWS_EVENT_FULLSCREEN_CHANGE = 0; | ||
29 | EAPI int ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE = 0; | ||
30 | |||
31 | #ifdef BUILD_ECORE_EVAS_EWS | ||
32 | static int _ecore_evas_init_count = 0; | ||
33 | |||
34 | static Ecore_Evas *_ews_ee = NULL; | ||
35 | static Evas_Object *_ews_bg = NULL; | ||
36 | static Eina_List *_ews_children = NULL; | ||
37 | static const void *_ews_manager = NULL; | ||
38 | static char *_ews_engine = NULL; | ||
39 | static char *_ews_options = NULL; | ||
40 | static int _ews_x = 0; | ||
41 | static int _ews_y = 0; | ||
42 | static int _ews_w = 1024; | ||
43 | static int _ews_h = 768; | ||
44 | static Eina_Bool _ews_defaults_engine = EINA_TRUE; | ||
45 | static Eina_Bool _ews_defaults_geo = EINA_TRUE; | ||
46 | |||
47 | static const char EWS_ENGINE_NAME[] = "ews"; | ||
48 | |||
49 | static void | ||
50 | _ecore_evas_ews_pre_free(Ecore_Evas *ee __UNUSED__) | ||
51 | { | ||
52 | DBG("EWS backing store free'd"); | ||
53 | _ews_children = eina_list_free(_ews_children); | ||
54 | _ews_ee = NULL; | ||
55 | _ews_bg = NULL; | ||
56 | } | ||
57 | |||
58 | static void | ||
59 | _ecore_evas_ews_del_request(Ecore_Evas *ee __UNUSED__) | ||
60 | { | ||
61 | INF("EWS backing store deletion is forbidden!"); | ||
62 | } | ||
63 | |||
64 | static Ecore_Evas * | ||
65 | _ecore_evas_ews_ee_new(void) | ||
66 | { | ||
67 | Ecore_Evas *ee = ecore_evas_new(_ews_engine, _ews_x, _ews_y, _ews_w, _ews_h, | ||
68 | _ews_options); | ||
69 | if (!ee) | ||
70 | ERR("Failed: ecore_evas_new(%s, %d, %d, %d, %d, %s)", | ||
71 | _ews_engine, _ews_x, _ews_y, _ews_w, _ews_h, _ews_options); | ||
72 | else | ||
73 | { | ||
74 | ecore_evas_size_min_set(ee, _ews_w, _ews_h); | ||
75 | ecore_evas_size_max_set(ee, _ews_w, _ews_h); | ||
76 | ecore_evas_callback_pre_free_set(ee, _ecore_evas_ews_pre_free); | ||
77 | ecore_evas_callback_delete_request_set(ee, _ecore_evas_ews_del_request); | ||
78 | ecore_evas_name_class_set(ee, "ecore_evas_ews", "ews"); | ||
79 | ecore_evas_title_set | ||
80 | (ee, "EWS: Ecore + Evas Single Process Windowing System"); | ||
81 | ecore_evas_show(ee); | ||
82 | } | ||
83 | |||
84 | return ee; | ||
85 | } | ||
86 | |||
87 | static void | ||
88 | _ecore_evas_ews_env_setup(void) | ||
89 | { | ||
90 | const char *env = getenv("ECORE_EVAS_EWS"); | ||
91 | char *p, *n, *tmp; | ||
92 | |||
93 | if (_ews_defaults_engine) | ||
94 | { | ||
95 | free(_ews_engine); | ||
96 | _ews_engine = NULL; | ||
97 | free(_ews_options); | ||
98 | _ews_options = NULL; | ||
99 | } | ||
100 | if (_ews_defaults_geo) | ||
101 | { | ||
102 | _ews_x = 0; | ||
103 | _ews_y = 0; | ||
104 | _ews_w = 1024; | ||
105 | _ews_h = 768; | ||
106 | } | ||
107 | |||
108 | if ((!env) || (!*env)) return; | ||
109 | |||
110 | p = tmp = strdup(env); | ||
111 | if (!tmp) return; | ||
112 | |||
113 | n = strchr(p, ':'); | ||
114 | if (n) *n = '\0'; | ||
115 | if (_ews_defaults_engine) _ews_engine = strdup(p); | ||
116 | if (!n) goto end; | ||
117 | |||
118 | p = n + 1; | ||
119 | n = strchr(p, ':'); | ||
120 | if (!n) goto end; | ||
121 | *n = '\0'; | ||
122 | if (_ews_defaults_geo) _ews_x = atoi(p); | ||
123 | |||
124 | p = n + 1; | ||
125 | n = strchr(p, ':'); | ||
126 | if (!n) goto end; | ||
127 | *n = '\0'; | ||
128 | if (_ews_defaults_geo) _ews_y = atoi(p); | ||
129 | |||
130 | p = n + 1; | ||
131 | n = strchr(p, ':'); | ||
132 | if (!n) goto end; | ||
133 | *n = '\0'; | ||
134 | if (_ews_defaults_geo) _ews_w = atoi(p); | ||
135 | |||
136 | p = n + 1; | ||
137 | n = strchr(p, ':'); | ||
138 | if (n) *n = '\0'; | ||
139 | if (_ews_defaults_geo) _ews_h = atoi(p); | ||
140 | if (!n) goto end; | ||
141 | |||
142 | p = n + 1; | ||
143 | if (_ews_defaults_engine) _ews_options = strdup(p); | ||
144 | |||
145 | end: | ||
146 | free(tmp); | ||
147 | } | ||
148 | |||
149 | static void | ||
150 | _ecore_evas_ews_event_free(void *data __UNUSED__, void *ev) | ||
151 | { | ||
152 | Ecore_Evas *ee = ev; | ||
153 | _ecore_evas_unref(ee); | ||
154 | } | ||
155 | |||
156 | static void | ||
157 | _ecore_evas_ews_event(Ecore_Evas *ee, int event) | ||
158 | { | ||
159 | _ecore_evas_ref(ee); | ||
160 | ecore_event_add(event, ee, _ecore_evas_ews_event_free, NULL); | ||
161 | } | ||
162 | |||
163 | static void | ||
164 | _ecore_evas_ews_event_free_del(void *data __UNUSED__, void *ev __UNUSED__) | ||
165 | { | ||
166 | _ecore_evas_ews_shutdown(); | ||
167 | } | ||
168 | |||
169 | static void | ||
170 | _ecore_evas_ews_free(Ecore_Evas *ee) | ||
171 | { | ||
172 | evas_object_del(ee->engine.ews.image); | ||
173 | _ews_ee->sub_ecore_evas = eina_list_remove(_ews_ee->sub_ecore_evas, ee); | ||
174 | |||
175 | ecore_event_add(ECORE_EVAS_EWS_EVENT_DEL, ee, _ecore_evas_ews_event_free_del, NULL); | ||
176 | } | ||
177 | |||
178 | static void | ||
179 | _ecore_evas_ews_move(Ecore_Evas *ee, int x, int y) | ||
180 | { | ||
181 | ee->req.x = x; | ||
182 | ee->req.y = y; | ||
183 | |||
184 | if ((x == ee->x) && (y == ee->y)) return; | ||
185 | ee->x = x; | ||
186 | ee->y = y; | ||
187 | evas_object_move(ee->engine.ews.image, x, y); | ||
188 | if (ee->func.fn_move) ee->func.fn_move(ee); | ||
189 | |||
190 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_MOVE); | ||
191 | } | ||
192 | |||
193 | static void | ||
194 | _ecore_evas_ews_managed_move(Ecore_Evas *ee, int x, int y) | ||
195 | { | ||
196 | ee->req.x = x; | ||
197 | ee->req.y = y; | ||
198 | |||
199 | if ((x == ee->x) && (y == ee->y)) return; | ||
200 | ee->x = x; | ||
201 | ee->y = y; | ||
202 | if (ee->func.fn_move) ee->func.fn_move(ee); | ||
203 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_MOVE); | ||
204 | } | ||
205 | |||
206 | static void | ||
207 | _ecore_evas_ews_resize_internal(Ecore_Evas *ee, int w, int h) | ||
208 | { | ||
209 | Evas_Engine_Info_Buffer *einfo; | ||
210 | void *pixels; | ||
211 | int stride; | ||
212 | |||
213 | evas_output_size_set(ee->evas, w, h); | ||
214 | evas_output_viewport_set(ee->evas, 0, 0, w, h); | ||
215 | evas_damage_rectangle_add(ee->evas, 0, 0, w, h); | ||
216 | |||
217 | evas_object_image_size_set(ee->engine.ews.image, w, h); | ||
218 | evas_object_image_fill_set(ee->engine.ews.image, 0, 0, w, h); | ||
219 | evas_object_resize(ee->engine.ews.image, w, h); | ||
220 | |||
221 | pixels = evas_object_image_data_get(ee->engine.ews.image, 1); | ||
222 | evas_object_image_data_set(ee->engine.ews.image, pixels); // refcount | ||
223 | stride = evas_object_image_stride_get(ee->engine.ews.image); | ||
224 | |||
225 | einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); | ||
226 | EINA_SAFETY_ON_NULL_RETURN(einfo); | ||
227 | |||
228 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; | ||
229 | einfo->info.dest_buffer = pixels; | ||
230 | einfo->info.dest_buffer_row_bytes = stride; | ||
231 | einfo->info.use_color_key = 0; | ||
232 | einfo->info.alpha_threshold = 0; | ||
233 | einfo->info.func.new_update_region = NULL; | ||
234 | einfo->info.func.free_update_region = NULL; | ||
235 | evas_object_image_data_set(ee->engine.ews.image, pixels); | ||
236 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
237 | { | ||
238 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
239 | } | ||
240 | } | ||
241 | |||
242 | static void | ||
243 | _ecore_evas_ews_resize(Ecore_Evas *ee, int w, int h) | ||
244 | { | ||
245 | if (w < 1) w = 1; | ||
246 | if (h < 1) h = 1; | ||
247 | |||
248 | ee->req.w = w; | ||
249 | ee->req.h = h; | ||
250 | |||
251 | if ((w == ee->w) && (h == ee->h)) return; | ||
252 | ee->w = w; | ||
253 | ee->h = h; | ||
254 | _ecore_evas_ews_resize_internal(ee, w, h); | ||
255 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
256 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_RESIZE); | ||
257 | } | ||
258 | |||
259 | static void | ||
260 | _ecore_evas_ews_move_resize(Ecore_Evas *ee, int x, int y, int w, int h) | ||
261 | { | ||
262 | _ecore_evas_ews_move(ee, x, y); | ||
263 | _ecore_evas_ews_resize(ee, w, h); | ||
264 | } | ||
265 | |||
266 | static void | ||
267 | _ecore_evas_ews_rotation_set(Ecore_Evas *ee, int rot, int resize) | ||
268 | { | ||
269 | if (ee->rotation == rot) return; | ||
270 | ee->rotation = rot; | ||
271 | |||
272 | ERR("TODO: rot=%d, resize=%d", rot, resize); | ||
273 | |||
274 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
275 | } | ||
276 | |||
277 | static void | ||
278 | _ecore_evas_ews_shaped_set(Ecore_Evas *ee, int val) | ||
279 | { | ||
280 | if (ee->shaped == val) return; | ||
281 | ee->shaped = val; | ||
282 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
283 | } | ||
284 | |||
285 | static void | ||
286 | _ecore_evas_ews_show(Ecore_Evas *ee) | ||
287 | { | ||
288 | ee->should_be_visible = EINA_TRUE; | ||
289 | evas_object_show(ee->engine.ews.image); | ||
290 | if (ee->prop.fullscreen) | ||
291 | evas_object_focus_set(ee->engine.ews.image, EINA_TRUE); | ||
292 | |||
293 | if (ee->func.fn_show) ee->func.fn_show(ee); | ||
294 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_SHOW); | ||
295 | } | ||
296 | |||
297 | static void | ||
298 | _ecore_evas_ews_hide(Ecore_Evas *ee) | ||
299 | { | ||
300 | ee->should_be_visible = EINA_FALSE; | ||
301 | evas_object_hide(ee->engine.ews.image); | ||
302 | |||
303 | if (ee->func.fn_hide) ee->func.fn_hide(ee); | ||
304 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_HIDE); | ||
305 | } | ||
306 | |||
307 | static void | ||
308 | _ecore_evas_ews_raise(Ecore_Evas *ee) | ||
309 | { | ||
310 | evas_object_raise(ee->engine.ews.image); | ||
311 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_RAISE); | ||
312 | } | ||
313 | |||
314 | static void | ||
315 | _ecore_evas_ews_lower(Ecore_Evas *ee) | ||
316 | { | ||
317 | evas_object_lower(ee->engine.ews.image); | ||
318 | evas_object_lower(_ews_bg); | ||
319 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_LOWER); | ||
320 | } | ||
321 | |||
322 | static void | ||
323 | _ecore_evas_ews_activate(Ecore_Evas *ee) | ||
324 | { | ||
325 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_ACTIVATE); | ||
326 | } | ||
327 | |||
328 | static void | ||
329 | _ecore_evas_ews_title_set(Ecore_Evas *ee, const char *t) | ||
330 | { | ||
331 | if (ee->prop.title) free(ee->prop.title); | ||
332 | ee->prop.title = NULL; | ||
333 | if (t) ee->prop.title = strdup(t); | ||
334 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
335 | } | ||
336 | |||
337 | static void | ||
338 | _ecore_evas_ews_name_class_set(Ecore_Evas *ee, const char *n, const char *c) | ||
339 | { | ||
340 | if (ee->prop.name) free(ee->prop.name); | ||
341 | if (ee->prop.clas) free(ee->prop.clas); | ||
342 | ee->prop.name = NULL; | ||
343 | ee->prop.clas = NULL; | ||
344 | if (n) ee->prop.name = strdup(n); | ||
345 | if (c) ee->prop.clas = strdup(c); | ||
346 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
347 | } | ||
348 | |||
349 | static void | ||
350 | _ecore_evas_ews_size_min_set(Ecore_Evas *ee, int w, int h) | ||
351 | { | ||
352 | if (w < 0) w = 0; | ||
353 | if (h < 0) h = 0; | ||
354 | if ((ee->prop.min.w == w) && (ee->prop.min.h == h)) return; | ||
355 | ee->prop.min.w = w; | ||
356 | ee->prop.min.h = h; | ||
357 | evas_object_size_hint_min_set(ee->engine.ews.image, w, h); | ||
358 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
359 | } | ||
360 | |||
361 | static void | ||
362 | _ecore_evas_ews_size_max_set(Ecore_Evas *ee, int w, int h) | ||
363 | { | ||
364 | if (w < 0) w = 0; | ||
365 | if (h < 0) h = 0; | ||
366 | if ((ee->prop.max.w == w) && (ee->prop.max.h == h)) return; | ||
367 | ee->prop.max.w = w; | ||
368 | ee->prop.max.h = h; | ||
369 | evas_object_size_hint_max_set(ee->engine.ews.image, w, h); | ||
370 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
371 | } | ||
372 | |||
373 | static void | ||
374 | _ecore_evas_ews_size_base_set(Ecore_Evas *ee, int w, int h) | ||
375 | { | ||
376 | if (w < 0) w = 0; | ||
377 | if (h < 0) h = 0; | ||
378 | if ((ee->prop.base.w == w) && (ee->prop.base.h == h)) return; | ||
379 | ee->prop.base.w = w; | ||
380 | ee->prop.base.h = h; | ||
381 | evas_object_size_hint_request_set(ee->engine.ews.image, w, h); | ||
382 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
383 | } | ||
384 | |||
385 | static void | ||
386 | _ecore_evas_ews_size_step_set(Ecore_Evas *ee, int w, int h) | ||
387 | { | ||
388 | if (w < 1) w = 1; | ||
389 | if (h < 1) h = 1; | ||
390 | if ((ee->prop.step.w == w) && (ee->prop.step.h == h)) return; | ||
391 | ee->prop.step.w = w; | ||
392 | ee->prop.step.h = h; | ||
393 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
394 | } | ||
395 | |||
396 | static void | ||
397 | _ecore_evas_ews_object_cursor_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
398 | { | ||
399 | Ecore_Evas *ee = data; | ||
400 | ee->prop.cursor.object = NULL; | ||
401 | } | ||
402 | |||
403 | static void | ||
404 | _ecore_evas_ews_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) | ||
405 | { | ||
406 | int x, y; | ||
407 | |||
408 | if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object); | ||
409 | |||
410 | if (!obj) | ||
411 | { | ||
412 | ee->prop.cursor.object = NULL; | ||
413 | ee->prop.cursor.layer = 0; | ||
414 | ee->prop.cursor.hot.x = 0; | ||
415 | ee->prop.cursor.hot.y = 0; | ||
416 | return; | ||
417 | } | ||
418 | |||
419 | ee->prop.cursor.object = obj; | ||
420 | ee->prop.cursor.layer = layer; | ||
421 | ee->prop.cursor.hot.x = hot_x; | ||
422 | ee->prop.cursor.hot.y = hot_y; | ||
423 | evas_pointer_output_xy_get(ee->evas, &x, &y); | ||
424 | evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); | ||
425 | evas_object_move(ee->prop.cursor.object, | ||
426 | x - ee->prop.cursor.hot.x, | ||
427 | y - ee->prop.cursor.hot.y); | ||
428 | evas_object_pass_events_set(ee->prop.cursor.object, 1); | ||
429 | if (evas_pointer_inside_get(ee->evas)) | ||
430 | evas_object_show(ee->prop.cursor.object); | ||
431 | |||
432 | evas_object_event_callback_add | ||
433 | (obj, EVAS_CALLBACK_DEL, _ecore_evas_ews_object_cursor_del, ee); | ||
434 | |||
435 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
436 | } | ||
437 | |||
438 | static void | ||
439 | _ecore_evas_ews_layer_set(Ecore_Evas *ee, int layer) | ||
440 | { | ||
441 | if (layer < EVAS_LAYER_MIN + 1) | ||
442 | layer = EVAS_LAYER_MIN + 1; | ||
443 | else if (layer > EVAS_LAYER_MAX) | ||
444 | layer = EVAS_LAYER_MAX; | ||
445 | |||
446 | if (ee->prop.layer == layer) return; | ||
447 | ee->prop.layer = layer; | ||
448 | evas_object_layer_set(ee->engine.ews.image, layer); | ||
449 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_LAYER_CHANGE); | ||
450 | } | ||
451 | |||
452 | static void | ||
453 | _ecore_evas_ews_focus_set(Ecore_Evas *ee, int val) | ||
454 | { | ||
455 | evas_object_focus_set(ee->engine.ews.image, val); | ||
456 | ee->prop.focused = val; | ||
457 | if (val) | ||
458 | { | ||
459 | evas_focus_in(ee->evas); | ||
460 | if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee); | ||
461 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_FOCUS); | ||
462 | } | ||
463 | else | ||
464 | { | ||
465 | evas_focus_out(ee->evas); | ||
466 | if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee); | ||
467 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_UNFOCUS); | ||
468 | } | ||
469 | } | ||
470 | |||
471 | static void | ||
472 | _ecore_evas_ews_iconified_set(Ecore_Evas *ee, int val) | ||
473 | { | ||
474 | if (ee->prop.iconified == val) return; | ||
475 | ee->prop.iconified = val; | ||
476 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_ICONIFIED_CHANGE); | ||
477 | } | ||
478 | |||
479 | static void | ||
480 | _ecore_evas_ews_borderless_set(Ecore_Evas *ee, int val) | ||
481 | { | ||
482 | if (ee->prop.borderless == val) return; | ||
483 | ee->prop.borderless = val; | ||
484 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
485 | } | ||
486 | |||
487 | static void | ||
488 | _ecore_evas_ews_override_set(Ecore_Evas *ee, int val) | ||
489 | { | ||
490 | if (ee->prop.override == val) return; | ||
491 | if (ee->visible) evas_object_show(ee->engine.ews.image); | ||
492 | if (ee->prop.focused) evas_object_focus_set(ee->engine.ews.image, EINA_TRUE); | ||
493 | ee->prop.override = val; | ||
494 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
495 | } | ||
496 | |||
497 | static void | ||
498 | _ecore_evas_ews_maximized_set(Ecore_Evas *ee, int val) | ||
499 | { | ||
500 | if (ee->prop.maximized == val) return; | ||
501 | ee->prop.maximized = val; | ||
502 | if (val) evas_object_show(ee->engine.ews.image); | ||
503 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_MAXIMIZED_CHANGE); | ||
504 | } | ||
505 | |||
506 | static void | ||
507 | _ecore_evas_ews_fullscreen_set(Ecore_Evas *ee, int val) | ||
508 | { | ||
509 | if (ee->prop.fullscreen == val) return; | ||
510 | ee->prop.fullscreen = val; | ||
511 | |||
512 | if (!val) | ||
513 | { | ||
514 | evas_object_move(ee->engine.ews.image, ee->x, ee->y); | ||
515 | evas_object_resize(ee->engine.ews.image, ee->w, ee->h); | ||
516 | } | ||
517 | else | ||
518 | { | ||
519 | Evas_Coord w, h; | ||
520 | ecore_evas_geometry_get(_ews_ee, NULL, NULL, &w, &h); | ||
521 | evas_object_move(ee->engine.ews.image, 0, 0); | ||
522 | evas_object_resize(ee->engine.ews.image, w, h); | ||
523 | evas_object_focus_set(ee->engine.ews.image, EINA_TRUE); | ||
524 | } | ||
525 | |||
526 | if (ee->should_be_visible) | ||
527 | evas_object_show(ee->engine.ews.image); | ||
528 | else | ||
529 | evas_object_hide(ee->engine.ews.image); | ||
530 | |||
531 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_FULLSCREEN_CHANGE); | ||
532 | } | ||
533 | |||
534 | static void | ||
535 | _ecore_evas_ews_avoid_damage_set(Ecore_Evas *ee, int val) | ||
536 | { | ||
537 | if (ee->prop.avoid_damage == val) return; | ||
538 | ee->prop.avoid_damage = val; | ||
539 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
540 | } | ||
541 | |||
542 | static void | ||
543 | _ecore_evas_ews_withdrawn_set(Ecore_Evas *ee, int val) | ||
544 | { | ||
545 | if (ee->prop.withdrawn == val) return; | ||
546 | ee->prop.withdrawn = val; | ||
547 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
548 | } | ||
549 | |||
550 | static void | ||
551 | _ecore_evas_ews_sticky_set(Ecore_Evas *ee, int val) | ||
552 | { | ||
553 | if (ee->prop.sticky == val) return; | ||
554 | ee->prop.sticky = val; | ||
555 | if ((val) && (ee->func.fn_sticky)) ee->func.fn_sticky(ee); | ||
556 | else if ((!val) && (ee->func.fn_unsticky)) ee->func.fn_unsticky(ee); | ||
557 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
558 | } | ||
559 | |||
560 | static void | ||
561 | _ecore_evas_ews_ignore_events_set(Ecore_Evas *ee, int val) | ||
562 | { | ||
563 | if (ee->ignore_events == val) return; | ||
564 | ee->ignore_events = val; | ||
565 | evas_object_pass_events_set(ee->engine.ews.image, val); | ||
566 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
567 | } | ||
568 | |||
569 | static void | ||
570 | _ecore_evas_ews_alpha_set(Ecore_Evas *ee, int val) | ||
571 | { | ||
572 | if (ee->alpha == val) return; | ||
573 | ee->alpha = val; | ||
574 | evas_object_image_alpha_set(ee->engine.ews.image, val); | ||
575 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
576 | } | ||
577 | |||
578 | static void | ||
579 | _ecore_evas_ews_transparent_set(Ecore_Evas *ee, int val) | ||
580 | { | ||
581 | if (ee->transparent == val) return; | ||
582 | ee->transparent = val; | ||
583 | evas_object_image_alpha_set(ee->engine.ews.image, val); | ||
584 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); | ||
585 | } | ||
586 | |||
587 | static int | ||
588 | _ecore_evas_ews_render(Ecore_Evas *ee) | ||
589 | { | ||
590 | Eina_List *updates = NULL, *l, *ll; | ||
591 | Ecore_Evas *ee2; | ||
592 | Eina_Rectangle *r; | ||
593 | int w, h, rend = 0; | ||
594 | void *pixels; | ||
595 | |||
596 | EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) | ||
597 | { | ||
598 | if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); | ||
599 | rend |= _ecore_evas_ews_render(ee2); | ||
600 | if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); | ||
601 | } | ||
602 | |||
603 | evas_object_image_size_get(ee->engine.ews.image, &w, &h); | ||
604 | if ((w != ee->w) || (h != ee->h)) | ||
605 | ecore_evas_resize(ee, w, h); | ||
606 | |||
607 | pixels = evas_object_image_data_get(ee->engine.ews.image, 1); | ||
608 | if (pixels) | ||
609 | { | ||
610 | updates = evas_render_updates(ee->evas); | ||
611 | } | ||
612 | evas_object_image_data_set(ee->engine.ews.image, pixels); | ||
613 | |||
614 | EINA_LIST_FOREACH(updates, l, r) | ||
615 | evas_object_image_data_update_add(ee->engine.ews.image, | ||
616 | r->x, r->y, r->w, r->h); | ||
617 | |||
618 | if (updates) | ||
619 | { | ||
620 | evas_render_updates_free(updates); | ||
621 | _ecore_evas_idle_timeout_update(ee); | ||
622 | } | ||
623 | |||
624 | return updates ? 1 : rend; | ||
625 | } | ||
626 | |||
627 | static void | ||
628 | _ecore_evas_ews_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h) | ||
629 | { | ||
630 | ecore_evas_geometry_get(_ews_ee, x, y, w, h); | ||
631 | } | ||
632 | |||
633 | static const Ecore_Evas_Engine_Func _ecore_ews_engine_func = | ||
634 | { | ||
635 | _ecore_evas_ews_free, | ||
636 | NULL, | ||
637 | NULL, | ||
638 | NULL, | ||
639 | NULL, | ||
640 | NULL, | ||
641 | NULL, | ||
642 | NULL, | ||
643 | NULL, | ||
644 | NULL, | ||
645 | NULL, | ||
646 | NULL, | ||
647 | NULL, | ||
648 | NULL, | ||
649 | NULL, | ||
650 | _ecore_evas_ews_move, | ||
651 | _ecore_evas_ews_managed_move, | ||
652 | _ecore_evas_ews_resize, | ||
653 | _ecore_evas_ews_move_resize, | ||
654 | _ecore_evas_ews_rotation_set, | ||
655 | _ecore_evas_ews_shaped_set, | ||
656 | _ecore_evas_ews_show, | ||
657 | _ecore_evas_ews_hide, | ||
658 | _ecore_evas_ews_raise, | ||
659 | _ecore_evas_ews_lower, | ||
660 | _ecore_evas_ews_activate, | ||
661 | _ecore_evas_ews_title_set, | ||
662 | _ecore_evas_ews_name_class_set, | ||
663 | _ecore_evas_ews_size_min_set, | ||
664 | _ecore_evas_ews_size_max_set, | ||
665 | _ecore_evas_ews_size_base_set, | ||
666 | _ecore_evas_ews_size_step_set, | ||
667 | _ecore_evas_ews_object_cursor_set, | ||
668 | _ecore_evas_ews_layer_set, | ||
669 | _ecore_evas_ews_focus_set, | ||
670 | _ecore_evas_ews_iconified_set, | ||
671 | _ecore_evas_ews_borderless_set, | ||
672 | _ecore_evas_ews_override_set, | ||
673 | _ecore_evas_ews_maximized_set, | ||
674 | _ecore_evas_ews_fullscreen_set, | ||
675 | _ecore_evas_ews_avoid_damage_set, | ||
676 | _ecore_evas_ews_withdrawn_set, | ||
677 | _ecore_evas_ews_sticky_set, | ||
678 | _ecore_evas_ews_ignore_events_set, | ||
679 | _ecore_evas_ews_alpha_set, | ||
680 | _ecore_evas_ews_transparent_set, | ||
681 | _ecore_evas_ews_render, | ||
682 | _ecore_evas_ews_screen_geometry_get | ||
683 | }; | ||
684 | |||
685 | void | ||
686 | _ecore_evas_ews_events_init(void) | ||
687 | { | ||
688 | if (ECORE_EVAS_EWS_EVENT_MANAGER_CHANGE != 0) return; | ||
689 | ECORE_EVAS_EWS_EVENT_MANAGER_CHANGE = ecore_event_type_new(); | ||
690 | ECORE_EVAS_EWS_EVENT_ADD = ecore_event_type_new(); | ||
691 | ECORE_EVAS_EWS_EVENT_DEL = ecore_event_type_new(); | ||
692 | ECORE_EVAS_EWS_EVENT_RESIZE = ecore_event_type_new(); | ||
693 | ECORE_EVAS_EWS_EVENT_MOVE = ecore_event_type_new(); | ||
694 | ECORE_EVAS_EWS_EVENT_SHOW = ecore_event_type_new(); | ||
695 | ECORE_EVAS_EWS_EVENT_HIDE = ecore_event_type_new(); | ||
696 | ECORE_EVAS_EWS_EVENT_FOCUS = ecore_event_type_new(); | ||
697 | ECORE_EVAS_EWS_EVENT_UNFOCUS = ecore_event_type_new(); | ||
698 | ECORE_EVAS_EWS_EVENT_RAISE = ecore_event_type_new(); | ||
699 | ECORE_EVAS_EWS_EVENT_LOWER = ecore_event_type_new(); | ||
700 | ECORE_EVAS_EWS_EVENT_ACTIVATE = ecore_event_type_new(); | ||
701 | ECORE_EVAS_EWS_EVENT_ICONIFIED_CHANGE = ecore_event_type_new(); | ||
702 | ECORE_EVAS_EWS_EVENT_MAXIMIZED_CHANGE = ecore_event_type_new(); | ||
703 | ECORE_EVAS_EWS_EVENT_LAYER_CHANGE = ecore_event_type_new(); | ||
704 | ECORE_EVAS_EWS_EVENT_FULLSCREEN_CHANGE = ecore_event_type_new(); | ||
705 | ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE = ecore_event_type_new(); | ||
706 | } | ||
707 | |||
708 | static int | ||
709 | _ecore_evas_ews_init(void) | ||
710 | { | ||
711 | _ecore_evas_init_count++; | ||
712 | if (_ecore_evas_init_count > 1) return _ecore_evas_init_count; | ||
713 | |||
714 | _ecore_evas_ews_env_setup(); | ||
715 | |||
716 | return _ecore_evas_init_count; | ||
717 | } | ||
718 | |||
719 | int | ||
720 | _ecore_evas_ews_shutdown(void) | ||
721 | { | ||
722 | _ecore_evas_init_count--; | ||
723 | if (_ecore_evas_init_count == 0) | ||
724 | { | ||
725 | if (_ews_ee) | ||
726 | { | ||
727 | ecore_evas_free(_ews_ee); | ||
728 | _ews_ee = NULL; | ||
729 | } | ||
730 | if (_ews_children) | ||
731 | { | ||
732 | eina_list_free(_ews_children); | ||
733 | _ews_children = NULL; | ||
734 | } | ||
735 | |||
736 | free(_ews_engine); | ||
737 | _ews_engine = NULL; | ||
738 | free(_ews_options); | ||
739 | _ews_options = NULL; | ||
740 | _ews_defaults_engine = EINA_TRUE; | ||
741 | _ews_defaults_geo = EINA_TRUE; | ||
742 | |||
743 | } | ||
744 | if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0; | ||
745 | return _ecore_evas_init_count; | ||
746 | } | ||
747 | |||
748 | static void | ||
749 | _ecore_evas_ews_coord_translate(Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y) | ||
750 | { | ||
751 | Evas_Coord xx, yy, ww, hh, fx, fy, fw, fh; | ||
752 | |||
753 | evas_object_geometry_get(ee->engine.ews.image, &xx, &yy, &ww, &hh); | ||
754 | evas_object_image_fill_get(ee->engine.ews.image, &fx, &fy, &fw, &fh); | ||
755 | |||
756 | if (fw < 1) fw = 1; | ||
757 | if (fh < 1) fh = 1; | ||
758 | |||
759 | if ((fx == 0) && (fy == 0) && (fw == ww) && (fh == hh)) | ||
760 | { | ||
761 | *x = (ee->w * (*x - xx)) / fw; | ||
762 | *y = (ee->h * (*y - yy)) / fh; | ||
763 | } | ||
764 | else | ||
765 | { | ||
766 | xx = (*x - xx) - fx; | ||
767 | while (xx < 0) xx += fw; | ||
768 | while (xx > fw) xx -= fw; | ||
769 | *x = (ee->w * xx) / fw; | ||
770 | |||
771 | yy = (*y - yy) - fy; | ||
772 | while (yy < 0) yy += fh; | ||
773 | while (yy > fh) yy -= fh; | ||
774 | *y = (ee->h * yy) / fh; | ||
775 | } | ||
776 | } | ||
777 | |||
778 | static void | ||
779 | _ecore_evas_ews_modifiers_apply(Ecore_Evas *ee, const Evas_Modifier *modifier) | ||
780 | { | ||
781 | Evas *e = ee->evas; | ||
782 | |||
783 | if (evas_key_modifier_is_set(modifier, "Shift")) | ||
784 | evas_key_modifier_on(e, "Shift"); | ||
785 | else evas_key_modifier_off(e, "Shift"); | ||
786 | |||
787 | if (evas_key_modifier_is_set(modifier, "Control")) | ||
788 | evas_key_modifier_on(e, "Control"); | ||
789 | else evas_key_modifier_off(e, "Control"); | ||
790 | |||
791 | if (evas_key_modifier_is_set(modifier, "Alt")) | ||
792 | evas_key_modifier_on(e, "Alt"); | ||
793 | else evas_key_modifier_off(e, "Alt"); | ||
794 | |||
795 | if (evas_key_modifier_is_set(modifier, "Super")) | ||
796 | evas_key_modifier_on(e, "Super"); | ||
797 | else evas_key_modifier_off(e, "Super"); | ||
798 | |||
799 | if (evas_key_modifier_is_set(modifier, "Hyper")) | ||
800 | evas_key_modifier_on(e, "Hyper"); | ||
801 | else evas_key_modifier_off(e, "Hyper"); | ||
802 | |||
803 | if (evas_key_modifier_is_set(modifier, "Scroll_Lock")) | ||
804 | evas_key_lock_on(e, "Scroll_Lock"); | ||
805 | else evas_key_lock_off(e, "Scroll_Lock"); | ||
806 | |||
807 | if (evas_key_modifier_is_set(modifier, "Num_Lock")) | ||
808 | evas_key_lock_on(e, "Num_Lock"); | ||
809 | else evas_key_lock_off(e, "Num_Lock"); | ||
810 | |||
811 | if (evas_key_modifier_is_set(modifier, "Caps_Lock")) | ||
812 | evas_key_lock_on(e, "Caps_Lock"); | ||
813 | else evas_key_lock_off(e, "Caps_Lock"); | ||
814 | |||
815 | if (evas_key_modifier_is_set(modifier, "Shift_Lock")) | ||
816 | evas_key_lock_on(e, "Shift_Lock"); | ||
817 | else evas_key_lock_off(e, "Shift_Lock"); | ||
818 | } | ||
819 | |||
820 | static void | ||
821 | _ecore_evas_ews_cb_mouse_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
822 | { | ||
823 | Ecore_Evas *ee = data; | ||
824 | Evas_Event_Mouse_In *ev = event_info; | ||
825 | Evas_Coord x = ev->canvas.x; | ||
826 | Evas_Coord y = ev->canvas.y; | ||
827 | _ecore_evas_ews_coord_translate(ee, &x, &y); | ||
828 | if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee); | ||
829 | _ecore_evas_ews_modifiers_apply(ee, ev->modifiers); | ||
830 | evas_event_feed_mouse_in(ee->evas, ev->timestamp, NULL); | ||
831 | _ecore_evas_mouse_move_process(ee, x, y, ev->timestamp); | ||
832 | } | ||
833 | |||
834 | static void | ||
835 | _ecore_evas_ews_cb_mouse_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
836 | { | ||
837 | Ecore_Evas *ee = data; | ||
838 | Evas_Event_Mouse_Out *ev = event_info; | ||
839 | Evas_Coord x = ev->canvas.x; | ||
840 | Evas_Coord y = ev->canvas.y; | ||
841 | // TODO: consider grab mode in EWS | ||
842 | _ecore_evas_ews_coord_translate(ee, &x, &y); | ||
843 | if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee); | ||
844 | _ecore_evas_ews_modifiers_apply(ee, ev->modifiers); | ||
845 | evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL); | ||
846 | if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object); | ||
847 | _ecore_evas_mouse_move_process(ee, x, y, ev->timestamp); | ||
848 | } | ||
849 | |||
850 | static void | ||
851 | _ecore_evas_ews_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
852 | { | ||
853 | Ecore_Evas *ee = data; | ||
854 | Evas_Event_Mouse_Down *ev = event_info; | ||
855 | _ecore_evas_ews_modifiers_apply(ee, ev->modifiers); | ||
856 | evas_event_feed_mouse_down(ee->evas, ev->button, ev->flags, ev->timestamp, NULL); | ||
857 | } | ||
858 | |||
859 | static void | ||
860 | _ecore_evas_ews_cb_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
861 | { | ||
862 | Ecore_Evas *ee = data; | ||
863 | Evas_Event_Mouse_Up *ev = event_info; | ||
864 | _ecore_evas_ews_modifiers_apply(ee, ev->modifiers); | ||
865 | evas_event_feed_mouse_up(ee->evas, ev->button, ev->flags, ev->timestamp, NULL); | ||
866 | } | ||
867 | |||
868 | static void | ||
869 | _ecore_evas_ews_cb_mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
870 | { | ||
871 | Ecore_Evas *ee = data; | ||
872 | Evas_Event_Mouse_Move *ev = event_info; | ||
873 | Evas_Coord x = ev->cur.canvas.x; | ||
874 | Evas_Coord y = ev->cur.canvas.y; | ||
875 | _ecore_evas_ews_coord_translate(ee, &x, &y); | ||
876 | _ecore_evas_ews_modifiers_apply(ee, ev->modifiers); | ||
877 | _ecore_evas_mouse_move_process(ee, x, y, ev->timestamp); | ||
878 | } | ||
879 | |||
880 | static void | ||
881 | _ecore_evas_ews_cb_mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
882 | { | ||
883 | Ecore_Evas *ee = data; | ||
884 | Evas_Event_Mouse_Wheel *ev = event_info; | ||
885 | _ecore_evas_ews_modifiers_apply(ee, ev->modifiers); | ||
886 | evas_event_feed_mouse_wheel(ee->evas, ev->direction, ev->z, ev->timestamp, NULL); | ||
887 | } | ||
888 | |||
889 | static void | ||
890 | _ecore_evas_ews_cb_multi_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
891 | { | ||
892 | Ecore_Evas *ee = data; | ||
893 | Evas_Event_Multi_Down *ev = event_info; | ||
894 | Evas_Coord x, y, xx, yy; | ||
895 | double xf, yf; | ||
896 | |||
897 | x = ev->canvas.x; | ||
898 | y = ev->canvas.y; | ||
899 | xx = x; | ||
900 | yy = y; | ||
901 | _ecore_evas_ews_coord_translate(ee, &x, &y); | ||
902 | xf = (ev->canvas.xsub - (double)xx) + (double)x; | ||
903 | yf = (ev->canvas.ysub - (double)yy) + (double)y; | ||
904 | _ecore_evas_ews_modifiers_apply(ee, ev->modifiers); | ||
905 | evas_event_feed_multi_down(ee->evas, ev->device, x, y, ev->radius, ev->radius_x, ev->radius_y, ev->pressure, ev->angle, xf, yf, ev->flags, ev->timestamp, NULL); | ||
906 | } | ||
907 | |||
908 | static void | ||
909 | _ecore_evas_ews_cb_multi_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
910 | { | ||
911 | Ecore_Evas *ee = data; | ||
912 | Evas_Event_Multi_Up *ev = event_info; | ||
913 | Evas_Coord x, y, xx, yy; | ||
914 | double xf, yf; | ||
915 | |||
916 | x = ev->canvas.x; | ||
917 | y = ev->canvas.y; | ||
918 | xx = x; | ||
919 | yy = y; | ||
920 | _ecore_evas_ews_coord_translate(ee, &x, &y); | ||
921 | xf = (ev->canvas.xsub - (double)xx) + (double)x; | ||
922 | yf = (ev->canvas.ysub - (double)yy) + (double)y; | ||
923 | _ecore_evas_ews_modifiers_apply(ee, ev->modifiers); | ||
924 | evas_event_feed_multi_up(ee->evas, ev->device, x, y, ev->radius, ev->radius_x, ev->radius_y, ev->pressure, ev->angle, xf, yf, ev->flags, ev->timestamp, NULL); | ||
925 | } | ||
926 | |||
927 | static void | ||
928 | _ecore_evas_ews_cb_multi_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
929 | { | ||
930 | Ecore_Evas *ee = data; | ||
931 | Evas_Event_Multi_Move *ev = event_info; | ||
932 | Evas_Coord x, y, xx, yy; | ||
933 | double xf, yf; | ||
934 | |||
935 | x = ev->cur.canvas.x; | ||
936 | y = ev->cur.canvas.y; | ||
937 | xx = x; | ||
938 | yy = y; | ||
939 | _ecore_evas_ews_coord_translate(ee, &x, &y); | ||
940 | xf = (ev->cur.canvas.xsub - (double)xx) + (double)x; | ||
941 | yf = (ev->cur.canvas.ysub - (double)yy) + (double)y; | ||
942 | _ecore_evas_ews_modifiers_apply(ee, ev->modifiers); | ||
943 | evas_event_feed_multi_move(ee->evas, ev->device, x, y, ev->radius, ev->radius_x, ev->radius_y, ev->pressure, ev->angle, xf, yf, ev->timestamp, NULL); | ||
944 | } | ||
945 | |||
946 | static void | ||
947 | _ecore_evas_ews_cb_free(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
948 | { | ||
949 | Ecore_Evas *ee = data; | ||
950 | if (ee->driver) _ecore_evas_free(ee); | ||
951 | } | ||
952 | |||
953 | static void | ||
954 | _ecore_evas_ews_cb_key_down(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
955 | { | ||
956 | Ecore_Evas *ee = data; | ||
957 | Evas_Event_Key_Down *ev = event_info; | ||
958 | |||
959 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Shift")) | ||
960 | evas_key_modifier_on(ee->evas, "Shift"); | ||
961 | else | ||
962 | evas_key_modifier_off(ee->evas, "Shift"); | ||
963 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Control")) | ||
964 | evas_key_modifier_on(ee->evas, "Control"); | ||
965 | else | ||
966 | evas_key_modifier_off(ee->evas, "Control"); | ||
967 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Alt")) | ||
968 | evas_key_modifier_on(ee->evas, "Alt"); | ||
969 | else | ||
970 | evas_key_modifier_off(ee->evas, "Alt"); | ||
971 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Meta")) | ||
972 | evas_key_modifier_on(ee->evas, "Meta"); | ||
973 | else | ||
974 | evas_key_modifier_off(ee->evas, "Meta"); | ||
975 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Hyper")) | ||
976 | evas_key_modifier_on(ee->evas, "Hyper"); | ||
977 | else | ||
978 | evas_key_modifier_off(ee->evas, "Hyper"); | ||
979 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Super")) | ||
980 | evas_key_modifier_on(ee->evas, "Super"); | ||
981 | else | ||
982 | evas_key_modifier_off(ee->evas, "Super"); | ||
983 | if (evas_key_lock_is_set(evas_key_lock_get(e), "Scroll_Lock")) | ||
984 | evas_key_lock_on(ee->evas, "Scroll_Lock"); | ||
985 | else | ||
986 | evas_key_lock_off(ee->evas, "Scroll_Lock"); | ||
987 | if (evas_key_lock_is_set(evas_key_lock_get(e), "Num_Lock")) | ||
988 | evas_key_lock_on(ee->evas, "Num_Lock"); | ||
989 | else | ||
990 | evas_key_lock_off(ee->evas, "Num_Lock"); | ||
991 | if (evas_key_lock_is_set(evas_key_lock_get(e), "Caps_Lock")) | ||
992 | evas_key_lock_on(ee->evas, "Caps_Lock"); | ||
993 | else | ||
994 | evas_key_lock_off(ee->evas, "Caps_Lock"); | ||
995 | evas_event_feed_key_down(ee->evas, ev->keyname, ev->key, ev->string, ev->compose, ev->timestamp, NULL); | ||
996 | } | ||
997 | |||
998 | static void | ||
999 | _ecore_evas_ews_cb_key_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
1000 | { | ||
1001 | Ecore_Evas *ee = data; | ||
1002 | Evas_Event_Key_Up *ev = event_info; | ||
1003 | |||
1004 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Shift")) | ||
1005 | evas_key_modifier_on(ee->evas, "Shift"); | ||
1006 | else | ||
1007 | evas_key_modifier_off(ee->evas, "Shift"); | ||
1008 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Control")) | ||
1009 | evas_key_modifier_on(ee->evas, "Control"); | ||
1010 | else | ||
1011 | evas_key_modifier_off(ee->evas, "Control"); | ||
1012 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Alt")) | ||
1013 | evas_key_modifier_on(ee->evas, "Alt"); | ||
1014 | else | ||
1015 | evas_key_modifier_off(ee->evas, "Alt"); | ||
1016 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Meta")) | ||
1017 | evas_key_modifier_on(ee->evas, "Meta"); | ||
1018 | else | ||
1019 | evas_key_modifier_off(ee->evas, "Meta"); | ||
1020 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Hyper")) | ||
1021 | evas_key_modifier_on(ee->evas, "Hyper"); | ||
1022 | else | ||
1023 | evas_key_modifier_off(ee->evas, "Hyper"); | ||
1024 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Super")) | ||
1025 | evas_key_modifier_on(ee->evas, "Super"); | ||
1026 | else | ||
1027 | evas_key_modifier_off(ee->evas, "Super"); | ||
1028 | if (evas_key_lock_is_set(evas_key_lock_get(e), "Scroll_Lock")) | ||
1029 | evas_key_lock_on(ee->evas, "Scroll_Lock"); | ||
1030 | else | ||
1031 | evas_key_lock_off(ee->evas, "Scroll_Lock"); | ||
1032 | if (evas_key_lock_is_set(evas_key_lock_get(e), "Num_Lock")) | ||
1033 | evas_key_lock_on(ee->evas, "Num_Lock"); | ||
1034 | else | ||
1035 | evas_key_lock_off(ee->evas, "Num_Lock"); | ||
1036 | if (evas_key_lock_is_set(evas_key_lock_get(e), "Caps_Lock")) | ||
1037 | evas_key_lock_on(ee->evas, "Caps_Lock"); | ||
1038 | else | ||
1039 | evas_key_lock_off(ee->evas, "Caps_Lock"); | ||
1040 | evas_event_feed_key_up(ee->evas, ev->keyname, ev->key, ev->string, ev->compose, ev->timestamp, NULL); | ||
1041 | } | ||
1042 | |||
1043 | static void | ||
1044 | _ecore_evas_ews_cb_focus_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1045 | { | ||
1046 | Ecore_Evas *ee = data; | ||
1047 | ecore_evas_focus_set(ee, EINA_TRUE); | ||
1048 | } | ||
1049 | |||
1050 | static void | ||
1051 | _ecore_evas_ews_cb_focus_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1052 | { | ||
1053 | Ecore_Evas *ee = data; | ||
1054 | if (ee->deleted) return; | ||
1055 | ecore_evas_focus_set(ee, EINA_FALSE); | ||
1056 | } | ||
1057 | |||
1058 | static void | ||
1059 | _ecore_evas_ews_cb_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1060 | { | ||
1061 | Ecore_Evas *ee = data; | ||
1062 | ecore_evas_show(ee); | ||
1063 | } | ||
1064 | |||
1065 | static void | ||
1066 | _ecore_evas_ews_cb_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1067 | { | ||
1068 | Ecore_Evas *ee = data; | ||
1069 | if (ee->deleted) return; | ||
1070 | ecore_evas_hide(ee); | ||
1071 | } | ||
1072 | #endif | ||
1073 | |||
1074 | EAPI Ecore_Evas * | ||
1075 | ecore_evas_ews_new(int x, int y, int w, int h) | ||
1076 | { | ||
1077 | // basically a copy of ecore_evas_buffer_new() keep in sync... | ||
1078 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1079 | Evas_Object *o; | ||
1080 | Evas_Engine_Info_Buffer *einfo; | ||
1081 | Ecore_Evas *ee; | ||
1082 | int rmethod; | ||
1083 | |||
1084 | if (_ecore_evas_ews_init() < 1) return NULL; | ||
1085 | |||
1086 | if (!_ews_ee) _ews_ee = _ecore_evas_ews_ee_new(); | ||
1087 | if (!_ews_ee) | ||
1088 | { | ||
1089 | ERR("Could not create EWS backing store"); | ||
1090 | _ecore_evas_ews_shutdown(); | ||
1091 | return NULL; | ||
1092 | } | ||
1093 | |||
1094 | rmethod = evas_render_method_lookup("buffer"); | ||
1095 | if (!rmethod) return NULL; | ||
1096 | ee = calloc(1, sizeof(Ecore_Evas)); | ||
1097 | if (!ee) return NULL; | ||
1098 | |||
1099 | if (w < 1) w = 1; | ||
1100 | if (h < 1) h = 1; | ||
1101 | |||
1102 | o = evas_object_image_add(_ews_ee->evas); | ||
1103 | evas_object_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); | ||
1104 | evas_object_image_colorspace_set(o, EVAS_COLORSPACE_ARGB8888); | ||
1105 | evas_object_image_size_set(o, w, h); | ||
1106 | evas_object_image_alpha_set(o, 1); | ||
1107 | |||
1108 | ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS); | ||
1109 | |||
1110 | ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_ews_engine_func; | ||
1111 | |||
1112 | ee->driver = EWS_ENGINE_NAME; | ||
1113 | |||
1114 | ee->x = 0; | ||
1115 | ee->y = 0; | ||
1116 | ee->w = w; | ||
1117 | ee->h = h; | ||
1118 | ee->req.x = ee->x; | ||
1119 | ee->req.y = ee->y; | ||
1120 | ee->req.w = ee->w; | ||
1121 | ee->req.h = ee->h; | ||
1122 | |||
1123 | /* init evas here */ | ||
1124 | ee->evas = evas_new(); | ||
1125 | evas_data_attach_set(ee->evas, ee); | ||
1126 | evas_output_method_set(ee->evas, rmethod); | ||
1127 | evas_output_size_set(ee->evas, w, h); | ||
1128 | evas_output_viewport_set(ee->evas, 0, 0, w, h); | ||
1129 | |||
1130 | evas_object_move(o, x, y); | ||
1131 | evas_object_resize(o, w, h); | ||
1132 | evas_object_image_fill_set(o, 0, 0, w, h); | ||
1133 | |||
1134 | ee->engine.ews.image = o; | ||
1135 | evas_object_data_set(ee->engine.ews.image, "Ecore_Evas", ee); | ||
1136 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1137 | EVAS_CALLBACK_MOUSE_IN, | ||
1138 | _ecore_evas_ews_cb_mouse_in, ee); | ||
1139 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1140 | EVAS_CALLBACK_MOUSE_OUT, | ||
1141 | _ecore_evas_ews_cb_mouse_out, ee); | ||
1142 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1143 | EVAS_CALLBACK_MOUSE_DOWN, | ||
1144 | _ecore_evas_ews_cb_mouse_down, ee); | ||
1145 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1146 | EVAS_CALLBACK_MOUSE_UP, | ||
1147 | _ecore_evas_ews_cb_mouse_up, ee); | ||
1148 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1149 | EVAS_CALLBACK_MOUSE_MOVE, | ||
1150 | _ecore_evas_ews_cb_mouse_move, ee); | ||
1151 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1152 | EVAS_CALLBACK_MOUSE_WHEEL, | ||
1153 | _ecore_evas_ews_cb_mouse_wheel, ee); | ||
1154 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1155 | EVAS_CALLBACK_MULTI_DOWN, | ||
1156 | _ecore_evas_ews_cb_multi_down, ee); | ||
1157 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1158 | EVAS_CALLBACK_MULTI_UP, | ||
1159 | _ecore_evas_ews_cb_multi_up, ee); | ||
1160 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1161 | EVAS_CALLBACK_MULTI_MOVE, | ||
1162 | _ecore_evas_ews_cb_multi_move, ee); | ||
1163 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1164 | EVAS_CALLBACK_FREE, | ||
1165 | _ecore_evas_ews_cb_free, ee); | ||
1166 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1167 | EVAS_CALLBACK_KEY_DOWN, | ||
1168 | _ecore_evas_ews_cb_key_down, ee); | ||
1169 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1170 | EVAS_CALLBACK_KEY_UP, | ||
1171 | _ecore_evas_ews_cb_key_up, ee); | ||
1172 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1173 | EVAS_CALLBACK_FOCUS_IN, | ||
1174 | _ecore_evas_ews_cb_focus_in, ee); | ||
1175 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1176 | EVAS_CALLBACK_FOCUS_OUT, | ||
1177 | _ecore_evas_ews_cb_focus_out, ee); | ||
1178 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1179 | EVAS_CALLBACK_SHOW, | ||
1180 | _ecore_evas_ews_cb_show, ee); | ||
1181 | evas_object_event_callback_add(ee->engine.ews.image, | ||
1182 | EVAS_CALLBACK_HIDE, | ||
1183 | _ecore_evas_ews_cb_hide, ee); | ||
1184 | einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); | ||
1185 | if (einfo) | ||
1186 | { | ||
1187 | void *pixels = evas_object_image_data_get(o, 1); | ||
1188 | evas_object_image_data_set(o, pixels); // refcount | ||
1189 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; | ||
1190 | einfo->info.dest_buffer = pixels; | ||
1191 | einfo->info.dest_buffer_row_bytes = evas_object_image_stride_get(o); | ||
1192 | einfo->info.use_color_key = 0; | ||
1193 | einfo->info.alpha_threshold = 0; | ||
1194 | einfo->info.func.new_update_region = NULL; | ||
1195 | einfo->info.func.free_update_region = NULL; | ||
1196 | evas_object_image_data_set(o, pixels); | ||
1197 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
1198 | { | ||
1199 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
1200 | ecore_evas_free(ee); | ||
1201 | return NULL; | ||
1202 | } | ||
1203 | } | ||
1204 | else | ||
1205 | { | ||
1206 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
1207 | ecore_evas_free(ee); | ||
1208 | return NULL; | ||
1209 | } | ||
1210 | evas_key_modifier_add(ee->evas, "Shift"); | ||
1211 | evas_key_modifier_add(ee->evas, "Control"); | ||
1212 | evas_key_modifier_add(ee->evas, "Alt"); | ||
1213 | evas_key_modifier_add(ee->evas, "Meta"); | ||
1214 | evas_key_modifier_add(ee->evas, "Hyper"); | ||
1215 | evas_key_modifier_add(ee->evas, "Super"); | ||
1216 | evas_key_lock_add(ee->evas, "Caps_Lock"); | ||
1217 | evas_key_lock_add(ee->evas, "Num_Lock"); | ||
1218 | evas_key_lock_add(ee->evas, "Scroll_Lock"); | ||
1219 | |||
1220 | _ews_ee->sub_ecore_evas = eina_list_append(_ews_ee->sub_ecore_evas, ee); | ||
1221 | _ews_children = eina_list_append(_ews_children, ee); | ||
1222 | |||
1223 | _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_ADD); | ||
1224 | |||
1225 | return ee; | ||
1226 | #else | ||
1227 | return NULL; | ||
1228 | (void)x; | ||
1229 | (void)y; | ||
1230 | (void)w; | ||
1231 | (void)h; | ||
1232 | #endif | ||
1233 | } | ||
1234 | |||
1235 | EAPI Evas_Object * | ||
1236 | ecore_evas_ews_backing_store_get(const Ecore_Evas *ee) | ||
1237 | { | ||
1238 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1239 | if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) | ||
1240 | { | ||
1241 | ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, | ||
1242 | "ecore_evas_ews_backing_store_get"); | ||
1243 | return NULL; | ||
1244 | } | ||
1245 | return ee->engine.ews.image; | ||
1246 | #else | ||
1247 | return NULL; | ||
1248 | (void)ee; | ||
1249 | #endif | ||
1250 | } | ||
1251 | |||
1252 | EAPI void | ||
1253 | ecore_evas_ews_delete_request(Ecore_Evas *ee) | ||
1254 | { | ||
1255 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1256 | if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) | ||
1257 | { | ||
1258 | ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, | ||
1259 | "ecore_evas_ews_delete_request"); | ||
1260 | return; | ||
1261 | } | ||
1262 | if (ee->func.fn_delete_request) ee->func.fn_delete_request(ee); | ||
1263 | else ecore_evas_free(ee); | ||
1264 | #else | ||
1265 | (void)ee; | ||
1266 | #endif | ||
1267 | } | ||
1268 | |||
1269 | |||
1270 | EAPI Eina_Bool | ||
1271 | ecore_evas_ews_engine_set(const char *engine, const char *options) | ||
1272 | { | ||
1273 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1274 | if (_ews_ee) return EINA_FALSE; | ||
1275 | |||
1276 | free(_ews_engine); | ||
1277 | free(_ews_options); | ||
1278 | |||
1279 | _ews_engine = engine ? strdup(engine) : NULL; | ||
1280 | _ews_options = options ? strdup(options) : NULL; | ||
1281 | |||
1282 | if ((engine) && (!_ews_engine)) return EINA_FALSE; | ||
1283 | if ((options) && (!_ews_options)) return EINA_FALSE; | ||
1284 | |||
1285 | _ews_defaults_engine = EINA_FALSE; | ||
1286 | return EINA_TRUE; | ||
1287 | #else | ||
1288 | return EINA_FALSE; | ||
1289 | (void)engine; | ||
1290 | (void)options; | ||
1291 | #endif | ||
1292 | } | ||
1293 | |||
1294 | EAPI Eina_Bool | ||
1295 | ecore_evas_ews_setup(int x, int y, int w, int h) | ||
1296 | { | ||
1297 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1298 | Eina_Bool ret = EINA_TRUE; | ||
1299 | |||
1300 | _ews_defaults_geo = EINA_FALSE; | ||
1301 | _ews_x = x; | ||
1302 | _ews_y = y; | ||
1303 | _ews_w = w; | ||
1304 | _ews_h = h; | ||
1305 | |||
1306 | if (!_ews_ee) return EINA_TRUE; | ||
1307 | |||
1308 | /* move-resize is not as implemented as move + resize */ | ||
1309 | ecore_evas_move(_ews_ee, x, y); | ||
1310 | ecore_evas_size_min_set(_ews_ee, w, h); | ||
1311 | ecore_evas_size_max_set(_ews_ee, w, h); | ||
1312 | ecore_evas_resize(_ews_ee, w, h); | ||
1313 | |||
1314 | ecore_evas_geometry_get(_ews_ee, &x, &y, &w, &h); | ||
1315 | |||
1316 | #define TST(n) if ((n != _ews_##n)) \ | ||
1317 | { \ | ||
1318 | WRN("Asked %d, got %d for "#n, _ews_##n, n); \ | ||
1319 | ret = EINA_FALSE; \ | ||
1320 | } | ||
1321 | TST(x); | ||
1322 | TST(y); | ||
1323 | TST(w); | ||
1324 | TST(h); | ||
1325 | #undef TST | ||
1326 | return ret; | ||
1327 | #else | ||
1328 | return EINA_FALSE; | ||
1329 | (void)x; | ||
1330 | (void)y; | ||
1331 | (void)w; | ||
1332 | (void)h; | ||
1333 | #endif | ||
1334 | } | ||
1335 | |||
1336 | EAPI Ecore_Evas * | ||
1337 | ecore_evas_ews_ecore_evas_get(void) | ||
1338 | { | ||
1339 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1340 | if (!_ews_ee) _ews_ee = _ecore_evas_ews_ee_new(); | ||
1341 | return _ews_ee; | ||
1342 | #else | ||
1343 | return NULL; | ||
1344 | #endif | ||
1345 | } | ||
1346 | |||
1347 | EAPI Evas * | ||
1348 | ecore_evas_ews_evas_get(void) | ||
1349 | { | ||
1350 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1351 | return ecore_evas_get(ecore_evas_ews_ecore_evas_get()); | ||
1352 | #else | ||
1353 | return NULL; | ||
1354 | #endif | ||
1355 | } | ||
1356 | |||
1357 | EAPI Evas_Object * | ||
1358 | ecore_evas_ews_background_get(void) | ||
1359 | { | ||
1360 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1361 | return _ews_bg; | ||
1362 | #else | ||
1363 | return NULL; | ||
1364 | #endif | ||
1365 | } | ||
1366 | |||
1367 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1368 | static void | ||
1369 | _ecore_evas_ews_background_free(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) | ||
1370 | { | ||
1371 | _ews_bg = NULL; | ||
1372 | ecore_evas_ews_background_set(NULL); | ||
1373 | } | ||
1374 | #endif | ||
1375 | |||
1376 | EAPI void | ||
1377 | ecore_evas_ews_background_set(Evas_Object *o) | ||
1378 | { | ||
1379 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1380 | if ((o) && (o == _ews_bg)) return; | ||
1381 | |||
1382 | if (_ews_bg) | ||
1383 | { | ||
1384 | evas_object_del(_ews_bg); | ||
1385 | _ews_bg = NULL; | ||
1386 | } | ||
1387 | |||
1388 | if ((!o) && (_ews_ee)) | ||
1389 | { | ||
1390 | o = evas_object_rectangle_add(ecore_evas_get(_ews_ee)); | ||
1391 | evas_object_color_set(o, 0, 0, 0, 255); | ||
1392 | } | ||
1393 | |||
1394 | if (_ews_ee) | ||
1395 | { | ||
1396 | Evas_Coord w, h; | ||
1397 | Evas *e = ecore_evas_get(_ews_ee); | ||
1398 | |||
1399 | if (e != evas_object_evas_get(o)) | ||
1400 | { | ||
1401 | ERR("background not in ecore_evas_ews_evas_get() canvas!"); | ||
1402 | return; | ||
1403 | } | ||
1404 | |||
1405 | evas_output_viewport_get(e, NULL, NULL, &w, &h); | ||
1406 | evas_object_move(o, 0, 0); | ||
1407 | evas_object_resize(o, w, h); | ||
1408 | evas_object_layer_set(o, EVAS_LAYER_MIN); | ||
1409 | evas_object_lower(o); | ||
1410 | evas_object_show(o); | ||
1411 | |||
1412 | evas_object_event_callback_add | ||
1413 | (o, EVAS_CALLBACK_FREE, _ecore_evas_ews_background_free, NULL); | ||
1414 | } | ||
1415 | |||
1416 | _ews_bg = o; | ||
1417 | #else | ||
1418 | return; | ||
1419 | (void)o; | ||
1420 | #endif | ||
1421 | } | ||
1422 | |||
1423 | |||
1424 | EAPI const Eina_List * | ||
1425 | ecore_evas_ews_children_get(void) | ||
1426 | { | ||
1427 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1428 | return _ews_children; | ||
1429 | #else | ||
1430 | return NULL; | ||
1431 | #endif | ||
1432 | } | ||
1433 | |||
1434 | EAPI void | ||
1435 | ecore_evas_ews_manager_set(const void *manager) | ||
1436 | { | ||
1437 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1438 | if (_ews_manager == manager) return; | ||
1439 | _ews_manager = manager; | ||
1440 | ecore_event_add(ECORE_EVAS_EWS_EVENT_MANAGER_CHANGE, NULL, NULL, NULL); | ||
1441 | #else | ||
1442 | (void)manager; | ||
1443 | #endif | ||
1444 | } | ||
1445 | |||
1446 | EAPI const void * | ||
1447 | ecore_evas_ews_manager_get(void) | ||
1448 | { | ||
1449 | #ifdef BUILD_ECORE_EVAS_EWS | ||
1450 | return _ews_manager; | ||
1451 | #else | ||
1452 | return NULL; | ||
1453 | #endif | ||
1454 | } | ||