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