Add a new API(ecore_evas_request_geometry_get)
[profile/ivi/ecore.git] / src / lib / ecore_evas / ecore_evas.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
4
5 #include <string.h>
6 #include <sys/types.h>
7 #include <errno.h>
8
9 #ifndef _MSC_VER
10 # include <unistd.h>
11 #endif
12
13 #ifdef HAVE_EVIL
14 # include <Evil.h>
15 #endif
16
17 #include "Ecore.h"
18 #include "ecore_private.h"
19 #include "Ecore_Input.h"
20
21 #include "ecore_evas_private.h"
22 #include "Ecore_Evas.h"
23
24 Eina_Bool _ecore_evas_app_comp_sync = 1;
25 int _ecore_evas_log_dom = -1;
26 static int _ecore_evas_init_count = 0;
27 static Ecore_Fd_Handler *_ecore_evas_async_events_fd = NULL;
28 static Eina_Bool _ecore_evas_async_events_fd_handler(void *data, Ecore_Fd_Handler *fd_handler);
29
30 static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL;
31 static Ecore_Evas *ecore_evases = NULL;
32 static int _ecore_evas_fps_debug = 0;
33
34 static Eina_Bool
35 _ecore_evas_idle_enter(void *data __UNUSED__)
36 {
37    Ecore_Evas *ee;
38    double t1 = 0.0;
39    double t2 = 0.0;
40    int rend = 0;
41
42    if (!ecore_evases) return ECORE_CALLBACK_RENEW;
43    if (_ecore_evas_fps_debug)
44      {
45         t1 = ecore_time_get();
46      }
47    EINA_INLIST_FOREACH(ecore_evases, ee)
48      {
49         if (!ee->manual_render)
50           {
51              if (ee->engine.func->fn_render)
52                rend |= ee->engine.func->fn_render(ee);
53           }
54      }
55    if (_ecore_evas_fps_debug)
56      {
57         t2 = ecore_time_get();
58         if (rend)
59           _ecore_evas_fps_debug_rendertime_add(t2 - t1);
60      }
61    return ECORE_CALLBACK_RENEW;
62 }
63
64 /**
65  * Query if a particular renginering engine target has support
66  * @param  engine The engine to check support for
67  * @return 1 if the particular engine is supported, 0 if it is not
68  *
69  * Query if engine @param engine is supported by ecore_evas. 1 is returned if
70  * it is, and 0 is returned if it is not supported.
71  */
72 EAPI int
73 ecore_evas_engine_type_supported_get(Ecore_Evas_Engine_Type engine)
74 {
75    switch (engine)
76      {
77       case ECORE_EVAS_ENGINE_SOFTWARE_BUFFER:
78 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
79         return EINA_TRUE;
80 #else
81         return EINA_FALSE;
82 #endif
83       case ECORE_EVAS_ENGINE_SOFTWARE_XLIB:
84 #ifdef BUILD_ECORE_EVAS_SOFTWARE_XLIB
85         return EINA_TRUE;
86 #else
87         return EINA_FALSE;
88 #endif
89       case ECORE_EVAS_ENGINE_XRENDER_X11:
90         return EINA_FALSE;
91       case ECORE_EVAS_ENGINE_OPENGL_X11:
92 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
93         return EINA_TRUE;
94 #else
95         return EINA_FALSE;
96 #endif
97       case ECORE_EVAS_ENGINE_SOFTWARE_XCB:
98 #ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB
99         return EINA_TRUE;
100 #else
101         return EINA_FALSE;
102 #endif
103       case ECORE_EVAS_ENGINE_XRENDER_XCB:
104         return EINA_FALSE;
105       case ECORE_EVAS_ENGINE_SOFTWARE_GDI:
106 #ifdef BUILD_ECORE_EVAS_SOFTWARE_GDI
107         return EINA_TRUE;
108 #else
109         return EINA_FALSE;
110 #endif
111       case ECORE_EVAS_ENGINE_SOFTWARE_DDRAW:
112 #ifdef BUILD_ECORE_EVAS_SOFTWARE_DDRAW
113         return EINA_TRUE;
114 #else
115         return EINA_FALSE;
116 #endif
117       case ECORE_EVAS_ENGINE_DIRECT3D:
118 #ifdef BUILD_ECORE_EVAS_DIRECT3D
119         return EINA_TRUE;
120 #else
121         return EINA_FALSE;
122 #endif
123       case ECORE_EVAS_ENGINE_OPENGL_GLEW:
124 #ifdef BUILD_ECORE_EVAS_OPENGL_GLEW
125         return EINA_TRUE;
126 #else
127         return EINA_FALSE;
128 #endif
129      case ECORE_EVAS_ENGINE_SOFTWARE_SDL:
130 #ifdef BUILD_ECORE_EVAS_SOFTWARE_SDL
131         return EINA_TRUE;
132 #else
133         return EINA_FALSE;
134 #endif
135      case ECORE_EVAS_ENGINE_OPENGL_SDL:
136 #ifdef BUILD_ECORE_EVAS_OPENGL_SDL
137         return EINA_TRUE;
138 #else
139         return EINA_FALSE;
140 #endif
141       case ECORE_EVAS_ENGINE_DIRECTFB:
142 #ifdef BUILD_ECORE_EVAS_DIRECTFB
143         return EINA_TRUE;
144 #else
145         return EINA_FALSE;
146 #endif
147       case ECORE_EVAS_ENGINE_SOFTWARE_FB:
148 #ifdef BUILD_ECORE_EVAS_FB
149         return EINA_TRUE;
150 #else
151         return EINA_FALSE;
152 #endif
153
154           case ECORE_EVAS_ENGINE_SOFTWARE_8_X11:
155 #ifdef BUILD_ECORE_EVAS_SOFTWARE_8_X11
156         return EINA_TRUE;
157 #else
158         return EINA_FALSE;
159 #endif
160
161       case ECORE_EVAS_ENGINE_SOFTWARE_16_X11:
162 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_X11
163         return EINA_TRUE;
164 #else
165         return EINA_FALSE;
166 #endif
167       case ECORE_EVAS_ENGINE_SOFTWARE_16_DDRAW:
168 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_DDRAW
169         return EINA_TRUE;
170 #else
171         return EINA_FALSE;
172 #endif
173       case ECORE_EVAS_ENGINE_SOFTWARE_16_WINCE:
174 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
175         return EINA_TRUE;
176 #else
177         return EINA_FALSE;
178 #endif
179       case ECORE_EVAS_ENGINE_COCOA:
180 #ifdef BUILD_ECORE_EVAS_COCOA
181         return EINA_TRUE;
182 #else
183         return EINA_FALSE;
184 #endif
185
186       case ECORE_EVAS_ENGINE_EWS:
187 #ifdef BUILD_ECORE_EVAS_EWS
188         return EINA_TRUE;
189 #else
190         return EINA_FALSE;
191 #endif
192
193       default:
194         return EINA_FALSE;
195      };
196 }
197
198 EAPI int
199 ecore_evas_init(void)
200 {
201    int fd;
202
203    if (++_ecore_evas_init_count != 1)
204      return _ecore_evas_init_count;
205
206    if (!evas_init())
207      return --_ecore_evas_init_count;
208
209    if (!ecore_init())
210      goto shutdown_evas;
211
212    _ecore_evas_log_dom = eina_log_domain_register
213      ("ecore_evas", ECORE_EVAS_DEFAULT_LOG_COLOR);
214    if(_ecore_evas_log_dom < 0)
215      {
216         EINA_LOG_ERR("Impossible to create a log domain for Ecore_Evas.");
217         goto shutdown_ecore;
218      }
219
220    fd = evas_async_events_fd_get();
221    if (fd > 0)
222      _ecore_evas_async_events_fd = ecore_main_fd_handler_add(fd,
223                                                              ECORE_FD_READ,
224                                                              _ecore_evas_async_events_fd_handler, NULL,
225                                                              NULL, NULL);
226
227    ecore_evas_idle_enterer =
228      ecore_idle_enterer_add(_ecore_evas_idle_enter, NULL);
229    if (getenv("ECORE_EVAS_FPS_DEBUG")) _ecore_evas_fps_debug = 1;
230    if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_init();
231
232 #ifdef BUILD_ECORE_EVAS_EWS
233    _ecore_evas_ews_events_init();
234 #endif
235
236    if (getenv("ECORE_EVAS_COMP_NOSYNC"))
237       _ecore_evas_app_comp_sync = 0;
238    return _ecore_evas_init_count;
239
240  shutdown_ecore:
241    ecore_shutdown();
242  shutdown_evas:
243    evas_shutdown();
244
245    return --_ecore_evas_init_count;
246 }
247
248 EAPI int
249 ecore_evas_shutdown(void)
250 {
251    if (--_ecore_evas_init_count != 0)
252      return _ecore_evas_init_count;
253
254    while (ecore_evases) _ecore_evas_free(ecore_evases);
255
256    if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown();
257    ecore_idle_enterer_del(ecore_evas_idle_enterer);
258    ecore_evas_idle_enterer = NULL;
259
260 #ifdef BUILD_ECORE_EVAS_X11
261    while (_ecore_evas_x_shutdown());
262 #endif
263 #ifdef BUILD_ECORE_EVAS_WIN32
264    while (_ecore_evas_win32_shutdown());
265 #endif
266 #ifdef BUILD_ECORE_EVAS_FB
267    while (_ecore_evas_fb_shutdown());
268 #endif
269 #ifdef BUILD_ECORE_EVAS_EWS
270    while (_ecore_evas_ews_shutdown());
271 #endif
272 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
273    while (_ecore_evas_buffer_shutdown());
274 #endif
275 #ifdef BUILD_ECORE_EVAS_DIRECTFB
276    while (_ecore_evas_directfb_shutdown());
277 #endif
278 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
279    while (_ecore_evas_wince_shutdown());
280 #endif
281    if (_ecore_evas_async_events_fd)
282      ecore_main_fd_handler_del(_ecore_evas_async_events_fd);
283
284    eina_log_domain_unregister(_ecore_evas_log_dom);
285    _ecore_evas_log_dom = -1;
286    ecore_shutdown();
287    evas_shutdown();
288
289    return _ecore_evas_init_count;
290 }
291
292 EAPI void
293 ecore_evas_app_comp_sync_set(Eina_Bool do_sync)
294 {
295    _ecore_evas_app_comp_sync = do_sync;
296 }
297
298 EAPI Eina_Bool
299 ecore_evas_app_comp_sync_get(void)
300 {
301    return _ecore_evas_app_comp_sync;
302 }
303
304 struct ecore_evas_engine {
305    const char *name;
306    Ecore_Evas *(*constructor)(int x, int y, int w, int h, const char *extra_options);
307 };
308
309 /* inline is just to avoid need to ifdef around it */
310 static inline const char *
311 _ecore_evas_parse_extra_options_str(const char *extra_options, const char *key, char **value)
312 {
313    int len = strlen(key);
314
315    while (extra_options)
316      {
317         const char *p;
318
319         if (strncmp(extra_options, key, len) != 0)
320           {
321              extra_options = strchr(extra_options, ';');
322              if (extra_options)
323                extra_options++;
324              continue;
325           }
326
327         extra_options += len;
328         p = strchr(extra_options, ';');
329         if (p)
330           {
331              len = p - extra_options;
332              *value = malloc(len + 1);
333              memcpy(*value, extra_options, len);
334              (*value)[len] = '\0';
335              extra_options = p + 1;
336           }
337         else
338           {
339              *value = strdup(extra_options);
340              extra_options = NULL;
341           }
342      }
343    return extra_options;
344 }
345
346 /* inline is just to avoid need to ifdef around it */
347 static inline const char *
348 _ecore_evas_parse_extra_options_uint(const char *extra_options, const char *key, unsigned int *value)
349 {
350    int len = strlen(key);
351
352    while (extra_options)
353      {
354         const char *p;
355
356         if (strncmp(extra_options, key, len) != 0)
357           {
358              extra_options = strchr(extra_options, ';');
359              if (extra_options)
360                extra_options++;
361              continue;
362           }
363
364         extra_options += len;
365         *value = strtol(extra_options, NULL, 0);
366
367         p = strchr(extra_options, ';');
368         if (p)
369           extra_options = p + 1;
370         else
371           extra_options = NULL;
372      }
373    return extra_options;
374 }
375
376 /* inline is just to avoid need to ifdef around it */
377 static inline const char *
378 _ecore_evas_parse_extra_options_x(const char *extra_options, char **disp_name, unsigned int *parent)
379 {
380    _ecore_evas_parse_extra_options_str(extra_options, "display=", disp_name);
381    _ecore_evas_parse_extra_options_uint(extra_options, "parent=", parent);
382    return extra_options;
383 }
384
385 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
386 static Ecore_Evas *
387 _ecore_evas_constructor_software_x11(int x, int y, int w, int h, const char *extra_options)
388 {
389    unsigned int parent = 0;
390    char *disp_name = NULL;
391    Ecore_Evas *ee;
392
393    _ecore_evas_parse_extra_options_x(extra_options, &disp_name, &parent);
394    ee = ecore_evas_software_x11_new(disp_name, parent, x, y, w, h);
395    free(disp_name);
396
397    return ee;
398 }
399 #endif
400
401 #ifdef BUILD_ECORE_EVAS_COCOA
402 static Ecore_Evas *
403 _ecore_evas_constructor_cocoa(int x, int y, int w, int h, const char *extra_options)
404 {
405    char *name = NULL;
406    Ecore_Evas *ee;
407
408    _ecore_evas_parse_extra_options_str(extra_options, "name=", &name);
409    ee = ecore_evas_cocoa_new(name, w, h);
410    free(name);
411
412    if (ee) ecore_evas_move(ee, x, y);
413    return ee;
414 }
415 #endif
416
417 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
418 static Ecore_Evas *
419 _ecore_evas_constructor_opengl_x11(int x, int y, int w, int h, const char *extra_options)
420 {
421    Ecore_X_Window parent = 0;
422    char *disp_name = NULL;
423    Ecore_Evas *ee;
424
425    _ecore_evas_parse_extra_options_x(extra_options, &disp_name, &parent);
426    ee = ecore_evas_gl_x11_new(disp_name, parent, x, y, w, h);
427    free(disp_name);
428
429    return ee;
430 }
431 #endif
432
433 #ifdef BUILD_ECORE_EVAS_SOFTWARE_8_X11
434 static Ecore_Evas *
435 _ecore_evas_constructor_software_8_x11(int x, int y, int w, int h, const char *extra_options)
436 {
437    Ecore_X_Window parent = 0;
438    char *disp_name = NULL;
439    Ecore_Evas *ee;
440
441    _ecore_evas_parse_extra_options_x(extra_options, &disp_name, &parent);
442    ee = ecore_evas_software_x11_8_new(disp_name, parent, x, y, w, h);
443    free(disp_name);
444
445    return ee;
446 }
447 #endif
448
449 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_X11
450 static Ecore_Evas *
451 _ecore_evas_constructor_software_16_x11(int x, int y, int w, int h, const char *extra_options)
452 {
453    Ecore_X_Window parent = 0;
454    char *disp_name = NULL;
455    Ecore_Evas *ee;
456
457    _ecore_evas_parse_extra_options_x(extra_options, &disp_name, &parent);
458    ee = ecore_evas_software_x11_16_new(disp_name, parent, x, y, w, h);
459    free(disp_name);
460
461    return ee;
462 }
463 #endif
464
465 #ifdef BUILD_ECORE_EVAS_SOFTWARE_SDL
466 static Ecore_Evas *
467 _ecore_evas_constructor_sdl(int x __UNUSED__, int y __UNUSED__, int w, int h, const char *extra_options)
468 {
469    Ecore_Evas *ee;
470    unsigned int fullscreen = 0, hwsurface = 0, noframe = 0, alpha = 0;
471    char *name = NULL;
472
473    _ecore_evas_parse_extra_options_str(extra_options, "name=", &name);
474    _ecore_evas_parse_extra_options_uint(extra_options, "fullscreen=", &fullscreen);
475    _ecore_evas_parse_extra_options_uint(extra_options, "hwsurface=", &hwsurface);
476    _ecore_evas_parse_extra_options_uint(extra_options, "noframe=", &noframe);
477    _ecore_evas_parse_extra_options_uint(extra_options, "alpha=", &alpha);
478
479    ee = ecore_evas_sdl_new(name, w, h, fullscreen, hwsurface, noframe, alpha);
480    free(name);
481
482    return ee;
483 }
484
485 static Ecore_Evas *
486 _ecore_evas_constructor_sdl16(int x __UNUSED__, int y __UNUSED__, int w, int h, const char *extra_options)
487 {
488    Ecore_Evas *ee;
489    unsigned int fullscreen = 0, hwsurface = 0, noframe = 0, alpha = 0;
490    char *name = NULL;
491
492    _ecore_evas_parse_extra_options_str(extra_options, "name=", &name);
493    _ecore_evas_parse_extra_options_uint(extra_options, "fullscreen=", &fullscreen);
494    _ecore_evas_parse_extra_options_uint(extra_options, "hwsurface=", &hwsurface);
495    _ecore_evas_parse_extra_options_uint(extra_options, "alpha=", &alpha);
496
497    ee = ecore_evas_sdl16_new(name, w, h, fullscreen, hwsurface, noframe, alpha);
498    free(name);
499
500    return ee;
501 }
502 #endif
503
504 #ifdef BUILD_ECORE_EVAS_OPENGL_SDL
505 static Ecore_Evas *
506 _ecore_evas_constructor_opengl_sdl(int x __UNUSED__, int y __UNUSED__, int w, int h, const char *extra_options)
507 {
508    Ecore_Evas *ee;
509    unsigned int fullscreen = 0, noframe = 0;
510    char *name = NULL;
511
512    _ecore_evas_parse_extra_options_str(extra_options, "name=", &name);
513    _ecore_evas_parse_extra_options_uint(extra_options, "fullscreen=", &fullscreen);
514    _ecore_evas_parse_extra_options_uint(extra_options, "noframe=", &noframe);
515
516    ee = ecore_evas_gl_sdl_new(name, w, h, fullscreen, noframe);
517    free(name);
518
519    return ee;
520 }
521 #endif
522
523 #ifdef BUILD_ECORE_EVAS_DIRECTFB
524 static Ecore_Evas *
525 _ecore_evas_constructor_directfb(int x, int y, int w, int h, const char *extra_options)
526 {
527    Ecore_Evas *ee;
528    char *disp_name = NULL;
529    unsigned int windowed = 1;
530
531    _ecore_evas_parse_extra_options_str(extra_options, "display=", &disp_name);
532    _ecore_evas_parse_extra_options_uint(extra_options, "windowed=", &windowed);
533
534    ee = ecore_evas_directfb_new(disp_name, windowed, x, y, w, h);
535    free(disp_name);
536
537    return ee;
538 }
539 #endif
540
541 #ifdef BUILD_ECORE_EVAS_FB
542 static Ecore_Evas *
543 _ecore_evas_constructor_fb(int x __UNUSED__, int y __UNUSED__, int w, int h, const char *extra_options)
544 {
545    Ecore_Evas *ee;
546    char *disp_name = NULL;
547    unsigned int rotation = 0;
548
549    _ecore_evas_parse_extra_options_str(extra_options, "display=", &disp_name);
550    _ecore_evas_parse_extra_options_uint(extra_options, "rotation=", &rotation);
551
552    ee = ecore_evas_fb_new(disp_name, rotation, w, h);
553    free(disp_name);
554
555    return ee;
556 }
557 #endif
558
559 #ifdef BUILD_ECORE_EVAS_SOFTWARE_GDI
560 static Ecore_Evas *
561 _ecore_evas_constructor_software_gdi(int x, int y, int w, int h, const char *extra_options)
562 {
563    return ecore_evas_software_gdi_new(NULL, x, y, w, h);
564 }
565 #endif
566
567 #ifdef BUILD_ECORE_EVAS_SOFTWARE_DDRAW
568 static Ecore_Evas *
569 _ecore_evas_constructor_software_ddraw(int x, int y, int w, int h, const char *extra_options)
570 {
571    return ecore_evas_software_ddraw_new(NULL, x, y, w, h);
572 }
573 #endif
574
575 #ifdef BUILD_ECORE_EVAS_DIRECT3D
576 static Ecore_Evas *
577 _ecore_evas_constructor_direct3d(int x, int y, int w, int h, const char *extra_options)
578 {
579    return ecore_evas_direct3d_new(NULL, x, y, w, h);
580 }
581 #endif
582
583 #ifdef BUILD_ECORE_EVAS_OPENGL_GLEW
584 static Ecore_Evas *
585 _ecore_evas_constructor_opengl_glew(int x, int y, int w, int h, const char *extra_options)
586 {
587    return ecore_evas_gl_glew_new(NULL, x, y, w, h);
588 }
589 #endif
590
591 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_DDRAW
592 static Ecore_Evas *
593 _ecore_evas_constructor_software_16_ddraw(int x, int y, int w, int h, const char *extra_options)
594 {
595    return ecore_evas_software_16_ddraw_new(NULL, x, y, w, h);
596 }
597 #endif
598
599 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
600 static Ecore_Evas *
601 _ecore_evas_constructor_software_16_wince(int x, int y, int w, int h, const char *extra_options __UNUSED__)
602 {
603    return ecore_evas_software_wince_new(NULL, x, y, w, h);
604 }
605
606 static Ecore_Evas *
607 _ecore_evas_constructor_software_16_wince_fb(int x, int y, int w, int h, const char *extra_options __UNUSED__)
608 {
609    return ecore_evas_software_wince_fb_new(NULL, x, y, w, h);
610 }
611
612 static Ecore_Evas *
613 _ecore_evas_constructor_software_16_wince_gapi(int x, int y, int w, int h, const char *extra_options __UNUSED__)
614 {
615    return ecore_evas_software_wince_gapi_new(NULL, x, y, w, h);
616 }
617
618 static Ecore_Evas *
619 _ecore_evas_constructor_software_16_wince_gdi(int x, int y, int w, int h, const char *extra_options __UNUSED__)
620 {
621    return ecore_evas_software_wince_gdi_new(NULL, x, y, w, h);
622 }
623 #endif
624
625 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
626 static Ecore_Evas *
627 _ecore_evas_constructor_buffer(int x __UNUSED__, int y __UNUSED__, int w, int h, const char *extra_options __UNUSED__)
628 {
629    return ecore_evas_buffer_new(w, h);
630 }
631 #endif
632
633 #ifdef BUILD_ECORE_EVAS_EWS
634 static Ecore_Evas *
635 _ecore_evas_constructor_ews(int x, int y, int w, int h, const char *extra_options __UNUSED__)
636 {
637    return ecore_evas_ews_new(x, y, w, h);
638 }
639 #endif
640
641 /* note: keep sorted by priority, highest first */
642 static const struct ecore_evas_engine _engines[] = {
643   /* unix */
644 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
645   {"software_x11", _ecore_evas_constructor_software_x11},
646 #endif
647 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
648   {"opengl_x11", _ecore_evas_constructor_opengl_x11},
649 #endif
650 #ifdef BUILD_ECORE_EVAS_SOFTWARE_8_X11
651   {"software_8_x11", _ecore_evas_constructor_software_8_x11},
652 #endif
653 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_X11
654   {"software_16_x11", _ecore_evas_constructor_software_16_x11},
655 #endif
656 #ifdef BUILD_ECORE_EVAS_DIRECTFB
657   {"directfb", _ecore_evas_constructor_directfb},
658 #endif
659 #ifdef BUILD_ECORE_EVAS_FB
660   {"fb", _ecore_evas_constructor_fb},
661 #endif
662
663   /* windows */
664 #ifdef BUILD_ECORE_EVAS_SOFTWARE_GDI
665   {"software_gdi", _ecore_evas_constructor_software_gdi},
666 #endif
667 #ifdef BUILD_ECORE_EVAS_SOFTWARE_DDRAW
668   {"software_ddraw", _ecore_evas_constructor_software_ddraw},
669 #endif
670 #ifdef BUILD_ECORE_EVAS_DIRECT3D
671   {"direct3d", _ecore_evas_constructor_direct3d},
672 #endif
673 #ifdef BUILD_ECORE_EVAS_OPENGL_GLEW
674   {"opengl_glew", _ecore_evas_constructor_opengl_glew},
675 #endif
676 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_DDRAW
677   {"software_16_ddraw", _ecore_evas_constructor_software_16_ddraw},
678 #endif
679 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
680   {"software_16_wince", _ecore_evas_constructor_software_16_wince},
681   {"software_16_wince_fb", _ecore_evas_constructor_software_16_wince_fb},
682   {"software_16_wince_gapi", _ecore_evas_constructor_software_16_wince_gapi},
683   {"software_16_wince_gdi", _ecore_evas_constructor_software_16_wince_gdi},
684 #endif
685
686   /* Apple */
687 #ifdef BUILD_ECORE_EVAS_COCOA
688   {"cocoa", _ecore_evas_constructor_cocoa},
689 #endif
690
691   /* Last chance to have a window */
692 #ifdef BUILD_ECORE_EVAS_OPENGL_SDL
693   {"opengl_sdl", _ecore_evas_constructor_opengl_sdl},
694 #endif
695
696 #ifdef BUILD_ECORE_EVAS_SOFTWARE_SDL
697   {"sdl", _ecore_evas_constructor_sdl},
698   {"software_16_sdl", _ecore_evas_constructor_sdl16},
699 #endif
700
701   /* independent */
702 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
703   {"buffer", _ecore_evas_constructor_buffer},
704 #endif
705
706 #ifdef BUILD_ECORE_EVAS_EWS
707   {"ews", _ecore_evas_constructor_ews},
708 #endif
709   {NULL, NULL}
710 };
711
712 EAPI Eina_List *
713 ecore_evas_engines_get(void)
714 {
715    const struct ecore_evas_engine *itr;
716    Eina_List *lst = NULL;
717
718    for (itr = _engines; itr->name; itr++)
719      lst = eina_list_append(lst, itr->name);
720
721    return lst;
722 }
723
724 EAPI void
725 ecore_evas_engines_free(Eina_List *engines)
726 {
727    eina_list_free(engines);
728 }
729
730 static Ecore_Evas *
731 _ecore_evas_new_auto_discover(int x, int y, int w, int h, const char *extra_options)
732 {
733    const struct ecore_evas_engine *itr;
734
735    DBG("auto discover engine");
736
737    for (itr = _engines; itr->constructor; itr++)
738      {
739         Ecore_Evas *ee = itr->constructor(x, y, w, h, extra_options);
740         if (ee)
741           {
742              INF("auto discovered '%s'", itr->name);
743              return ee;
744           }
745      }
746
747    WRN("could not auto discover.");
748    return NULL;
749 }
750
751 EAPI Ecore_Evas *
752 ecore_evas_new(const char *engine_name, int x, int y, int w, int h, const char *extra_options)
753 {
754    const struct ecore_evas_engine *itr;
755
756    if (!engine_name)
757      {
758         engine_name = getenv("ECORE_EVAS_ENGINE");
759         if (engine_name)
760           DBG("no engine_name provided, using ECORE_EVAS_ENGINE='%s'",
761               engine_name);
762      }
763    if (!engine_name)
764      return _ecore_evas_new_auto_discover(x, y, w, h, extra_options);
765
766    for (itr = _engines; itr->name; itr++)
767      if (strcmp(itr->name, engine_name) == 0)
768        {
769           INF("using engine '%s', extra_options=%s",
770               engine_name, extra_options ? extra_options : "(null)");
771           return itr->constructor(x, y, w, h, extra_options);
772        }
773
774    WRN("unknown engine '%s'", engine_name);
775    return NULL;
776 }
777
778 EAPI const char *
779 ecore_evas_engine_name_get(const Ecore_Evas *ee)
780 {
781    if (!ee)
782      return NULL;
783    return ee->driver;
784 }
785
786 EAPI Ecore_Evas *
787 ecore_evas_ecore_evas_get(const Evas *e)
788 {
789    Ecore_Evas *ee = evas_data_attach_get(e);
790    if (!ee) return NULL;
791    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
792      {
793         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, "ecore_evas_ecore_evas_get");
794         return NULL;
795      }
796    return ee;
797 }
798
799 EAPI void
800 ecore_evas_free(Ecore_Evas *ee)
801 {
802    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
803      {
804         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
805                          "ecore_evas_free");
806         return;
807      }
808    _ecore_evas_free(ee);
809    return;
810 }
811
812 EAPI void *
813 ecore_evas_data_get(const Ecore_Evas *ee, const char *key)
814 {
815    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
816      {
817         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
818                          "ecore_evas_data_get");
819         return NULL;
820      }
821
822    if (!key) return NULL;
823    if (!ee->data) return NULL;
824
825    return eina_hash_find(ee->data, key);
826 }
827
828 EAPI void
829 ecore_evas_data_set(Ecore_Evas *ee, const char *key, const void *data)
830 {
831    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
832      {
833         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
834                          "ecore_evas_data_set");
835         return;
836      }
837
838    if (!key) return;
839
840    if (ee->data)
841      eina_hash_del(ee->data, key, NULL);
842    if (data)
843      {
844        if (!ee->data)
845          ee->data = eina_hash_string_superfast_new(NULL);
846        eina_hash_add(ee->data, key, data);
847      }
848 }
849
850 #define IFC(_ee, _fn)  if (_ee->engine.func->_fn) {_ee->engine.func->_fn
851 #define IFE            return;}
852
853 EAPI void
854 ecore_evas_callback_resize_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
855 {
856    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
857      {
858         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
859                          "ecore_evas_callback_resize_set");
860         return;
861      }
862    IFC(ee, fn_callback_resize_set) (ee, func);
863    IFE;
864    ee->func.fn_resize = func;
865 }
866
867 EAPI void
868 ecore_evas_callback_move_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
869 {
870    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
871      {
872         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
873                          "ecore_evas_callback_move_set");
874         return;
875      }
876    IFC(ee, fn_callback_move_set) (ee, func);
877    IFE;
878    ee->func.fn_move = func;
879 }
880
881 EAPI void
882 ecore_evas_callback_show_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
883 {
884    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
885      {
886         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
887                          "ecore_evas_callback_show_set");
888         return;
889      }
890    IFC(ee, fn_callback_show_set) (ee, func);
891    IFE;
892    ee->func.fn_show = func;
893 }
894
895 EAPI void
896 ecore_evas_callback_hide_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
897 {
898    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
899      {
900         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
901                          "ecore_evas_callback_hide_set");
902         return;
903      }
904    IFC(ee, fn_callback_hide_set) (ee, func);
905    IFE;
906    ee->func.fn_hide = func;
907 }
908
909 EAPI void
910 ecore_evas_callback_delete_request_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
911 {
912    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
913      {
914         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
915                          "ecore_evas_callback_delete_request_set");
916         return;
917      }
918    IFC(ee, fn_callback_delete_request_set) (ee, func);
919    IFE;
920    ee->func.fn_delete_request = func;
921 }
922
923 EAPI void
924 ecore_evas_callback_destroy_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
925 {
926    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
927      {
928         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
929                          "ecore_evas_callback_destroy_set");
930         return;
931      }
932    IFC(ee, fn_callback_destroy_set) (ee, func);
933    IFE;
934    ee->func.fn_destroy = func;
935 }
936
937 EAPI void
938 ecore_evas_callback_focus_in_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
939 {
940    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
941      {
942         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
943                          "ecore_evas_callback_focus_in_set");
944         return;
945      }
946    IFC(ee, fn_callback_focus_in_set) (ee, func);
947    IFE;
948    ee->func.fn_focus_in = func;
949 }
950
951 EAPI void
952 ecore_evas_callback_focus_out_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
953 {
954    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
955      {
956         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
957                          "ecore_evas_callback_focus_out_set");
958         return;
959      }
960    IFC(ee, fn_callback_focus_out_set) (ee, func);
961    IFE;
962    ee->func.fn_focus_out = func;
963 }
964
965 EAPI void
966 ecore_evas_callback_sticky_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
967 {
968    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
969      {
970         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
971                          "ecore_evas_callback_sticky_set");
972         return;
973      }
974    IFC(ee, fn_callback_sticky_set) (ee, func);
975    IFE;
976    ee->func.fn_sticky = func;
977 }
978
979 EAPI void
980 ecore_evas_callback_unsticky_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
981 {
982    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
983      {
984         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
985                          "ecore_evas_callback_unsticky_set");
986         return;
987      }
988    IFC(ee, fn_callback_unsticky_set) (ee, func);
989    IFE;
990    ee->func.fn_unsticky = func;
991 }
992
993 EAPI void
994 ecore_evas_callback_mouse_in_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
995 {
996    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
997      {
998         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
999                          "ecore_evas_callback_mouse_in_set");
1000         return;
1001      }
1002    IFC(ee, fn_callback_mouse_in_set) (ee, func);
1003    IFE;
1004    ee->func.fn_mouse_in = func;
1005 }
1006
1007 EAPI void
1008 ecore_evas_callback_mouse_out_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
1009 {
1010    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1011      {
1012         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1013                          "ecore_evas_callback_mouse_out_set");
1014         return;
1015      }
1016    IFC(ee, fn_callback_mouse_out_set) (ee, func);
1017    IFE;
1018    ee->func.fn_mouse_out = func;
1019 }
1020
1021 EAPI void
1022 ecore_evas_callback_pre_render_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
1023 {
1024    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1025      {
1026         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1027                          "ecore_evas_callback_pre_render_set");
1028         return;
1029      }
1030    IFC(ee, fn_callback_pre_render_set) (ee, func);
1031    IFE;
1032    ee->func.fn_pre_render = func;
1033 }
1034
1035 EAPI void
1036 ecore_evas_callback_post_render_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
1037 {
1038    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1039      {
1040         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1041                          "ecore_evas_callback_post_render_set");
1042         return;
1043      }
1044    IFC(ee, fn_callback_post_render_set) (ee, func);
1045    IFE;
1046    ee->func.fn_post_render = func;
1047 }
1048
1049 EAPI void
1050 ecore_evas_callback_pre_free_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee))
1051 {
1052    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1053      {
1054         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1055                          "ecore_evas_callback_pre_free_set");
1056         return;
1057      }
1058    ee->func.fn_pre_free = func;
1059 }
1060
1061 /**
1062  * Get an Ecore_Evas's Evas
1063  * @param ee The Ecore_Evas whose Evas you wish to get
1064  * @return The Evas wrapped by @p ee
1065  *
1066  * This function returns the Evas contained within @p ee.
1067  */
1068 EAPI Evas *
1069 ecore_evas_get(const Ecore_Evas *ee)
1070 {
1071    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1072      {
1073         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1074                          "ecore_evas_get");
1075         return NULL;
1076      }
1077    return ee->evas;
1078 }
1079
1080 EAPI void
1081 ecore_evas_move(Ecore_Evas *ee, int x, int y)
1082 {
1083    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1084      {
1085         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1086                          "ecore_evas_move");
1087         return;
1088      }
1089    if (ee->prop.fullscreen) return;
1090    IFC(ee, fn_move) (ee, x, y);
1091    IFE;
1092 }
1093
1094 /**
1095  * Provide Managed move co-ordinates for an Ecore_Evas
1096  * @param ee The Ecore_Evas to move
1097  * @param x The x coordinate to set as the managed location
1098  * @param y The y coordinate to set as the managed location
1099  *
1100  * This sets the managed geometry position of the @p ee to (@p x, @p y)
1101  */
1102 EAPI void
1103 ecore_evas_managed_move(Ecore_Evas *ee, int x, int y)
1104 {
1105    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1106      {
1107         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1108                          "ecore_evas_move");
1109         return;
1110      }
1111    IFC(ee, fn_managed_move) (ee, x, y);
1112    IFE;
1113 }
1114
1115 EAPI void
1116 ecore_evas_resize(Ecore_Evas *ee, int w, int h)
1117 {
1118    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1119      {
1120         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1121                          "ecore_evas_resize");
1122         return;
1123      }
1124    if (ee->prop.fullscreen) return;
1125    if (w < 1) w = 1;
1126    if (h < 1) h = 1;
1127    if ((ee->rotation == 90) || (ee->rotation == 270))
1128      {
1129         IFC(ee, fn_resize) (ee, h, w);
1130         IFE;
1131      }
1132    else
1133      {
1134         IFC(ee, fn_resize) (ee, w, h);
1135         IFE;
1136      }
1137 }
1138
1139 EAPI void
1140 ecore_evas_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
1141 {
1142    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1143      {
1144         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1145                          "ecore_evas_move_resize");
1146         return;
1147      }
1148    if (ee->prop.fullscreen) return;
1149    if (w < 1) w = 1;
1150    if (h < 1) h = 1;
1151    if ((ee->rotation == 90) || (ee->rotation == 270))
1152      {
1153         IFC(ee, fn_move_resize) (ee, x, y, h, w);
1154         IFE;
1155      }
1156    else
1157      {
1158         IFC(ee, fn_move_resize) (ee, x, y, w, h);
1159         IFE;
1160      }
1161 }
1162
1163 EAPI void
1164 ecore_evas_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h)
1165 {
1166    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1167      {
1168         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1169                          "ecore_evas_geometry_get");
1170         return;
1171      }
1172    if ((ee->rotation == 90) || (ee->rotation == 270))
1173      {
1174         if (x) *x = ee->x;
1175         if (y) *y = ee->y;
1176         if (w) *w = ee->h;
1177         if (h) *h = ee->w;
1178      }
1179    else
1180      {
1181         if (x) *x = ee->x;
1182         if (y) *y = ee->y;
1183         if (w) *w = ee->w;
1184         if (h) *h = ee->h;
1185      }
1186 }
1187
1188 EAPI void
1189 ecore_evas_request_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h)
1190 {
1191    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1192      {
1193         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1194                          "ecore_evas_request_geometry_get");
1195         return;
1196      }
1197    if ((ee->rotation == 90) || (ee->rotation == 270))
1198      {
1199         if (x) *x = ee->req.x;
1200         if (y) *y = ee->req.y;
1201         if (w) *w = ee->req.h;
1202         if (h) *h = ee->req.w;
1203      }
1204    else
1205      {
1206         if (x) *x = ee->req.x;
1207         if (y) *y = ee->req.y;
1208         if (w) *w = ee->req.w;
1209         if (h) *h = ee->req.h;
1210      }
1211 }
1212
1213 EAPI void
1214 ecore_evas_rotation_set(Ecore_Evas *ee, int rot)
1215 {
1216    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1217      {
1218         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1219                          "ecore_evas_rotation_set");
1220         return;
1221      }
1222    rot = rot % 360;
1223    while (rot < 0) rot += 360;
1224    while (rot >= 360) rot -= 360;
1225    IFC(ee, fn_rotation_set) (ee, rot, 0);
1226    /* make sure everything gets redrawn */
1227    evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1228    evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
1229    IFE;
1230 }
1231
1232 EAPI void
1233 ecore_evas_rotation_with_resize_set(Ecore_Evas *ee, int rot)
1234 {
1235    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1236      {
1237         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1238                          "ecore_evas_rotation_set");
1239         return;
1240      }
1241    rot = rot % 360;
1242    while (rot < 0) rot += 360;
1243    while (rot >= 360) rot -= 360;
1244    IFC(ee, fn_rotation_set) (ee, rot, 1);
1245    /* make sure everything gets redrawn */
1246    evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1247    evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
1248    IFE;
1249 }
1250
1251 EAPI int
1252 ecore_evas_rotation_get(const Ecore_Evas *ee)
1253 {
1254    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1255      {
1256         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1257                          "ecore_evas_rotation_get");
1258         return 0;
1259      }
1260    return ee->rotation;
1261 }
1262
1263 /**
1264  * Set whether an Ecore_Evas is shaped or not.
1265  * @param ee The Ecore_Evas to shape
1266  * @param shaped EINA_TRUE to shape, EINA_FALSE to not
1267  *
1268  * This function allows one to make an Ecore_Evas shaped to the contents of the
1269  * evas. If @p shaped is EINA_TRUE, @p ee will be transparent in parts of the evas that
1270  * contain no objects. If @p shaped is EINA_FALSE, then @p ee will be rectangular, and
1271  * and parts with no data will show random framebuffer artifacting. For
1272  * non-shaped Ecore_Evases, it is recommend to cover the entire evas with a
1273  * background object.
1274  */
1275 EAPI void
1276 ecore_evas_shaped_set(Ecore_Evas *ee, Eina_Bool shaped)
1277 {
1278    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1279      {
1280         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1281                          "ecore_evas_shaped_set");
1282         return;
1283      }
1284    IFC(ee, fn_shaped_set) (ee, shaped);
1285    IFE;
1286 }
1287
1288 /**
1289  * Query whether an Ecore_Evas is shaped or not.
1290  * @param ee The Ecore_Evas to query.
1291  * @return EINA_TRUE if shaped, EINA_FALSE if not.
1292  *
1293  * This function returns EINA_TRUE if @p ee is shaped, and EINA_FALSE if not.
1294  */
1295 EAPI Eina_Bool
1296 ecore_evas_shaped_get(const Ecore_Evas *ee)
1297 {
1298    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1299      {
1300         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1301                          "ecore_evas_shaped_get");
1302         return EINA_FALSE;
1303      }
1304    return ee->shaped ? EINA_TRUE : EINA_FALSE;
1305 }
1306
1307 EAPI void
1308 ecore_evas_alpha_set(Ecore_Evas *ee, Eina_Bool alpha)
1309 {
1310    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1311      {
1312         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1313                          "ecore_evas_alpha_set");
1314         return;
1315      }
1316    IFC(ee, fn_alpha_set) (ee, alpha);
1317    IFE;
1318 }
1319
1320 EAPI Eina_Bool
1321 ecore_evas_alpha_get(const Ecore_Evas *ee)
1322 {
1323    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1324      {
1325         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1326                          "ecore_evas_alpha_get");
1327         return EINA_FALSE;
1328      }
1329    return ee->alpha ? EINA_TRUE : EINA_FALSE;
1330 }
1331
1332 EAPI void
1333 ecore_evas_transparent_set(Ecore_Evas *ee, Eina_Bool transparent)
1334 {
1335    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1336      {
1337         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1338                          "ecore_evas_transparent_set");
1339         return;
1340      }
1341    IFC(ee, fn_transparent_set) (ee, transparent);
1342    IFE;
1343 }
1344
1345 EAPI Eina_Bool
1346 ecore_evas_transparent_get(const Ecore_Evas *ee)
1347 {
1348    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1349      {
1350         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1351                          "ecore_evas_transparent_get");
1352         return EINA_FALSE;
1353      }
1354    return ee->transparent ? EINA_TRUE : 0;
1355 }
1356
1357 EAPI void
1358 ecore_evas_show(Ecore_Evas *ee)
1359 {
1360    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1361      {
1362         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1363                          "ecore_evas_show");
1364         return;
1365      }
1366    IFC(ee, fn_show) (ee);
1367    IFE;
1368 }
1369
1370 EAPI void
1371 ecore_evas_hide(Ecore_Evas *ee)
1372 {
1373    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1374      {
1375         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1376                          "ecore_evas_hide");
1377         return;
1378      }
1379    IFC(ee, fn_hide) (ee);
1380    IFE;
1381 }
1382
1383  EAPI int
1384 ecore_evas_visibility_get(const Ecore_Evas *ee)
1385 {
1386    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1387      {
1388         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1389                          "ecore_evas_visibility_get");
1390         return 0;
1391      }
1392    return ee->visible ? 1:0;
1393 }
1394
1395 EAPI void
1396 ecore_evas_raise(Ecore_Evas *ee)
1397 {
1398    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1399      {
1400         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1401                          "ecore_evas_raise");
1402         return;
1403      }
1404    IFC(ee, fn_raise) (ee);
1405    IFE;
1406 }
1407
1408 EAPI void
1409 ecore_evas_lower(Ecore_Evas *ee)
1410 {
1411    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1412      {
1413         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1414                          "ecore_evas_lower");
1415         return;
1416      }
1417    IFC(ee, fn_lower) (ee);
1418    IFE;
1419 }
1420
1421 /**
1422  * Activate (set focus to, via the window manager) an Ecore_Evas' window.
1423  * @param ee The Ecore_Evas to activate.
1424  *
1425  * This functions activates the Ecore_Evas.
1426  */
1427 EAPI void
1428 ecore_evas_activate(Ecore_Evas *ee)
1429 {
1430    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1431      {
1432         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1433                          "ecore_evas_activate");
1434         return;
1435      }
1436    IFC(ee, fn_activate) (ee);
1437    IFE;
1438 }
1439
1440 EAPI void
1441 ecore_evas_title_set(Ecore_Evas *ee, const char *t)
1442 {
1443    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1444      {
1445         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1446                          "ecore_evas_title_set");
1447         return;
1448      }
1449    IFC(ee, fn_title_set) (ee, t);
1450    IFE;
1451 }
1452
1453 EAPI const char *
1454 ecore_evas_title_get(const Ecore_Evas *ee)
1455 {
1456    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1457      {
1458         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1459                          "ecore_evas_title_get");
1460         return NULL;
1461      }
1462    return ee->prop.title;
1463 }
1464
1465 EAPI void
1466 ecore_evas_name_class_set(Ecore_Evas *ee, const char *n, const char *c)
1467 {
1468    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1469      {
1470         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1471                          "ecore_evas_name_class_set");
1472         return;
1473      }
1474    IFC(ee, fn_name_class_set) (ee, n, c);
1475    IFE;
1476 }
1477
1478 EAPI void
1479 ecore_evas_name_class_get(const Ecore_Evas *ee, const char **n, const char **c)
1480 {
1481    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1482      {
1483         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1484                          "ecore_evas_name_class_get");
1485         return;
1486      }
1487    if (n) *n = ee->prop.name;
1488    if (c) *c = ee->prop.clas;
1489 }
1490
1491 EAPI void
1492 ecore_evas_size_min_set(Ecore_Evas *ee, int w, int h)
1493 {
1494    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1495      {
1496         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1497                          "ecore_evas_size_min_set");
1498         return;
1499      }
1500    if (w < 0) w = 0;
1501    if (h < 0) h = 0;
1502    if ((ee->rotation == 90) || (ee->rotation == 270))
1503      {
1504         IFC(ee, fn_size_min_set) (ee, h, w);
1505         IFE;
1506      }
1507    else
1508      {
1509         IFC(ee, fn_size_min_set) (ee, w, h);
1510         IFE;
1511      }
1512 }
1513
1514 EAPI void
1515 ecore_evas_size_min_get(const Ecore_Evas *ee, int *w, int *h)
1516 {
1517    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1518      {
1519         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1520                          "ecore_evas_size_min_get");
1521         return;
1522      }
1523    if ((ee->rotation == 90) || (ee->rotation == 270))
1524      {
1525         if (w) *w = ee->prop.min.h;
1526         if (h) *h = ee->prop.min.w;
1527      }
1528    else
1529      {
1530         if (w) *w = ee->prop.min.w;
1531         if (h) *h = ee->prop.min.h;
1532      }
1533 }
1534
1535 EAPI void
1536 ecore_evas_size_max_set(Ecore_Evas *ee, int w, int h)
1537 {
1538    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1539      {
1540         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1541                          "ecore_evas_size_max_set");
1542         return;
1543      }
1544    if (w < 0) w = 0;
1545    if (h < 0) h = 0;
1546    if ((ee->rotation == 90) || (ee->rotation == 270))
1547      {
1548         IFC(ee, fn_size_max_set) (ee, h, w);
1549         IFE;
1550      }
1551    else
1552      {
1553         IFC(ee, fn_size_max_set) (ee, w, h);
1554         IFE;
1555      }
1556 }
1557
1558 EAPI void
1559 ecore_evas_size_max_get(const Ecore_Evas *ee, int *w, int *h)
1560 {
1561    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1562      {
1563         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1564                          "ecore_evas_size_max_get");
1565         return;
1566      }
1567    if ((ee->rotation == 90) || (ee->rotation == 270))
1568      {
1569         if (w) *w = ee->prop.max.h;
1570         if (h) *h = ee->prop.max.w;
1571      }
1572    else
1573      {
1574         if (w) *w = ee->prop.max.w;
1575         if (h) *h = ee->prop.max.h;
1576      }
1577 }
1578
1579 EAPI void
1580 ecore_evas_size_base_set(Ecore_Evas *ee, int w, int h)
1581 {
1582    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1583      {
1584         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1585                          "ecore_evas_size_base_set");
1586         return;
1587      }
1588    if (w < 0) w = 0;
1589    if (h < 0) h = 0;
1590    if ((ee->rotation == 90) || (ee->rotation == 270))
1591      {
1592         IFC(ee, fn_size_base_set) (ee, h, w);
1593         IFE;
1594      }
1595    else
1596      {
1597         IFC(ee, fn_size_base_set) (ee, w, h);
1598         IFE;
1599      }
1600 }
1601
1602 EAPI void
1603 ecore_evas_size_base_get(const Ecore_Evas *ee, int *w, int *h)
1604 {
1605    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1606      {
1607         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1608                          "ecore_evas_size_base_get");
1609         return;
1610      }
1611    if ((ee->rotation == 90) || (ee->rotation == 270))
1612      {
1613         if (w) *w = ee->prop.base.h;
1614         if (h) *h = ee->prop.base.w;
1615      }
1616    else
1617      {
1618         if (w) *w = ee->prop.base.w;
1619         if (h) *h = ee->prop.base.h;
1620      }
1621 }
1622
1623 EAPI void
1624 ecore_evas_size_step_set(Ecore_Evas *ee, int w, int h)
1625 {
1626    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1627      {
1628         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1629                          "ecore_evas_size_step_set");
1630         return;
1631      }
1632    if (w < 0) w = 0;
1633    if (h < 0) h = 0;
1634    if ((ee->rotation == 90) || (ee->rotation == 270))
1635      {
1636         IFC(ee, fn_size_step_set) (ee, h, w);
1637         IFE;
1638      }
1639    else
1640      {
1641         IFC(ee, fn_size_step_set) (ee, w, h);
1642         IFE;
1643      }
1644 }
1645
1646 EAPI void
1647 ecore_evas_size_step_get(const Ecore_Evas *ee, int *w, int *h)
1648 {
1649    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1650      {
1651         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1652                          "ecore_evas_size_step_get");
1653         return;
1654      }
1655    if ((ee->rotation == 90) || (ee->rotation == 270))
1656      {
1657         if (w) *w = ee->prop.step.h;
1658         if (h) *h = ee->prop.step.w;
1659      }
1660    else
1661      {
1662         if (w) *w = ee->prop.step.w;
1663         if (h) *h = ee->prop.step.h;
1664      }
1665 }
1666
1667 EAPI void
1668 ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
1669 {
1670    Evas_Object  *obj = NULL;
1671
1672    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1673      {
1674         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1675                          "ecore_evas_cursor_set");
1676         return;
1677      }
1678
1679    if (file)
1680      {
1681         int x, y;
1682
1683         obj = evas_object_image_add(ee->evas);
1684         evas_object_image_file_set(obj, file, NULL);
1685         evas_object_image_size_get(obj, &x, &y);
1686         evas_object_resize(obj, x, y);
1687         evas_object_image_fill_set(obj, 0, 0, x, y);
1688      }
1689
1690    IFC(ee, fn_object_cursor_set) (ee, obj, layer, hot_x, hot_y);
1691    IFE;
1692 }
1693
1694 EAPI void
1695 ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
1696 {
1697    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1698      {
1699         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1700                          "ecore_evas_cursor_set");
1701         return;
1702      }
1703    IFC(ee, fn_object_cursor_set) (ee, obj, layer, hot_x, hot_y);
1704    IFE;
1705 }
1706
1707 EAPI void
1708 ecore_evas_cursor_get(const Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y)
1709 {
1710    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1711      {
1712         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1713                          "ecore_evas_cursor_get");
1714         return;
1715      }
1716    if (obj) *obj = ee->prop.cursor.object;
1717    if (layer) *layer = ee->prop.cursor.layer;
1718    if (hot_x) *hot_x = ee->prop.cursor.hot.x;
1719    if (hot_y) *hot_y = ee->prop.cursor.hot.y;
1720 }
1721
1722 EAPI void
1723 ecore_evas_layer_set(Ecore_Evas *ee, int layer)
1724 {
1725    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1726      {
1727         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1728                          "ecore_evas_layer_set");
1729         return;
1730      }
1731    IFC(ee, fn_layer_set) (ee, layer);
1732    IFE;
1733 }
1734
1735 EAPI int
1736 ecore_evas_layer_get(const Ecore_Evas *ee)
1737 {
1738    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1739      {
1740         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1741                          "ecore_evas_layer_get");
1742         return 0;
1743      }
1744    return ee->prop.layer;
1745 }
1746
1747 EAPI void
1748 ecore_evas_focus_set(Ecore_Evas *ee, Eina_Bool on)
1749 {
1750    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1751      {
1752         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1753                          "ecore_evas_focus_set");
1754         return;
1755      }
1756    IFC(ee, fn_focus_set) (ee, on);
1757    IFE;
1758 }
1759
1760 EAPI Eina_Bool
1761 ecore_evas_focus_get(const Ecore_Evas *ee)
1762 {
1763    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1764      {
1765         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1766                          "ecore_evas_focus_get");
1767         return EINA_FALSE;
1768      }
1769    return ee->prop.focused ? EINA_TRUE : EINA_FALSE;
1770 }
1771
1772 EAPI void
1773 ecore_evas_iconified_set(Ecore_Evas *ee, Eina_Bool on)
1774 {
1775    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1776      {
1777         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1778                          "ecore_evas_iconified_set");
1779         return;
1780      }
1781    IFC(ee, fn_iconified_set) (ee, on);
1782    IFE;
1783 }
1784
1785 EAPI Eina_Bool
1786 ecore_evas_iconified_get(const Ecore_Evas *ee)
1787 {
1788    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1789      {
1790         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1791                          "ecore_evas_iconified_get");
1792         return EINA_FALSE;
1793      }
1794    return ee->prop.iconified ? EINA_TRUE : EINA_FALSE;
1795 }
1796
1797 EAPI void
1798 ecore_evas_borderless_set(Ecore_Evas *ee, Eina_Bool on)
1799 {
1800    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1801      {
1802         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1803                          "ecore_evas_borderless_set");
1804         return;
1805      }
1806    IFC(ee, fn_borderless_set) (ee, on);
1807    IFE;
1808 }
1809
1810 EAPI Eina_Bool
1811 ecore_evas_borderless_get(const Ecore_Evas *ee)
1812 {
1813    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1814      {
1815         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1816                          "ecore_evas_borderless_get");
1817         return EINA_FALSE;
1818      }
1819    return ee->prop.borderless ? EINA_TRUE : EINA_FALSE;
1820 }
1821
1822 /**
1823  * Tell the WM whether or not to ignore an Ecore_Evas' window
1824  * @param ee The Ecore_Evas
1825  * @param on EINA_TRUE to ignore, EINA_FALSE to not.
1826  *
1827  * This function causes the window manager to ignore @p ee if @p on is EINA_TRUE,
1828  * or not ignore @p ee if @p on is EINA_FALSE.
1829  */
1830 EAPI void
1831 ecore_evas_override_set(Ecore_Evas *ee, Eina_Bool on)
1832 {
1833    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1834      {
1835         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1836                          "ecore_evas_override_set");
1837         return;
1838      }
1839    IFC(ee, fn_override_set) (ee, on);
1840    IFE;
1841 }
1842
1843 /**
1844  * Query whether an Ecore_Evas' window is overridden or not
1845  * @param ee The Ecore_Evas to set
1846  * @return EINA_TRUE if @p ee is overridden, EINA_FALSE if not.
1847  *
1848  */
1849 EAPI Eina_Bool
1850 ecore_evas_override_get(const Ecore_Evas *ee)
1851 {
1852    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1853      {
1854         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1855                          "ecore_evas_override_get");
1856         return EINA_FALSE;
1857      }
1858    return ee->prop.override ? EINA_TRUE : EINA_FALSE;
1859 }
1860
1861 EAPI void
1862 ecore_evas_maximized_set(Ecore_Evas *ee, Eina_Bool on)
1863 {
1864    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1865      {
1866         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1867                          "ecore_evas_maximized_set");
1868         return;
1869      }
1870    IFC(ee, fn_maximized_set) (ee, on);
1871    IFE;
1872 }
1873
1874 EAPI Eina_Bool
1875 ecore_evas_maximized_get(const Ecore_Evas *ee)
1876 {
1877    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1878      {
1879         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1880                          "ecore_evas_maximized_get");
1881         return EINA_FALSE;
1882      }
1883    return ee->prop.maximized ? EINA_TRUE : EINA_FALSE;
1884 }
1885
1886 EAPI void
1887 ecore_evas_fullscreen_set(Ecore_Evas *ee, Eina_Bool on)
1888 {
1889    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1890      {
1891         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1892                          "ecore_evas_fullscreen_set");
1893         return;
1894      }
1895    IFC(ee, fn_fullscreen_set) (ee, on);
1896    IFE;
1897 }
1898
1899 EAPI Eina_Bool
1900 ecore_evas_fullscreen_get(const Ecore_Evas *ee)
1901 {
1902    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1903      {
1904         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1905                          "ecore_evas_fullscreen_get");
1906         return EINA_FALSE;
1907      }
1908    return ee->prop.fullscreen ? EINA_TRUE : EINA_FALSE;
1909 }
1910
1911 /**
1912  * Set whether or not an Ecore_Evas' window should avoid damage
1913  *
1914  * @param ee The Ecore_Evas
1915  * @param The type of the damage management
1916  *
1917  * This function causes @p ee to be drawn to a pixmap to avoid recalculations.
1918  * On expose events it will copy from the pixmap to the window.
1919  */
1920 EAPI void
1921 ecore_evas_avoid_damage_set(Ecore_Evas *ee, Ecore_Evas_Avoid_Damage_Type on)
1922 {
1923    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1924      {
1925         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1926                          "ecore_evas_avoid_damage_set");
1927         return;
1928      }
1929    IFC(ee, fn_avoid_damage_set) (ee, on);
1930    IFE;
1931 }
1932
1933 /**
1934  * Query whether an Ecore_Evas' window avoids damage or not
1935  * @param ee The Ecore_Evas to set
1936  * @return The type of the damage management
1937  *
1938  */
1939 EAPI Ecore_Evas_Avoid_Damage_Type
1940 ecore_evas_avoid_damage_get(const Ecore_Evas *ee)
1941 {
1942    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1943      {
1944         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1945                          "ecore_evas_avoid_damage_get");
1946         return ECORE_EVAS_AVOID_DAMAGE_NONE;
1947      }
1948    return ee->prop.avoid_damage;
1949 }
1950
1951 /**
1952  * Set the withdrawn state of an Ecore_Evas' window.
1953  * @param ee The Ecore_Evas whose window's withdrawn state is set.
1954  * @param withdrawn The Ecore_Evas window's new withdrawn state.
1955  *
1956  */
1957 EAPI void
1958 ecore_evas_withdrawn_set(Ecore_Evas *ee, Eina_Bool withdrawn)
1959 {
1960    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1961      {
1962         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1963                          "ecore_evas_withdrawn_set");
1964         return;
1965      }
1966
1967    IFC(ee, fn_withdrawn_set) (ee, withdrawn);
1968    IFE;
1969 }
1970
1971 /**
1972  * Returns the withdrawn state of an Ecore_Evas' window.
1973  * @param ee The Ecore_Evas whose window's withdrawn state is returned.
1974  * @return The Ecore_Evas window's withdrawn state.
1975  *
1976  */
1977 EAPI Eina_Bool
1978 ecore_evas_withdrawn_get(const Ecore_Evas *ee)
1979 {
1980    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
1981      {
1982         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
1983                          "ecore_evas_withdrawn_get");
1984         return EINA_FALSE;
1985      } else
1986      return ee->prop.withdrawn ? EINA_TRUE : EINA_FALSE;
1987 }
1988
1989 /**
1990  * Set the sticky state of an Ecore_Evas window.
1991  *
1992  * @param ee The Ecore_Evas whose window's sticky state is set.
1993  * @param sticky The Ecore_Evas window's new sticky state.
1994  *
1995  */
1996 EAPI void
1997 ecore_evas_sticky_set(Ecore_Evas *ee, Eina_Bool sticky)
1998 {
1999    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2000      {
2001         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2002                          "ecore_evas_sticky_set");
2003         return;
2004      }
2005
2006    IFC(ee, fn_sticky_set) (ee, sticky);
2007    IFE;
2008 }
2009
2010 /**
2011  * Returns the sticky state of an Ecore_Evas' window.
2012  *
2013  * @param ee The Ecore_Evas whose window's sticky state is returned.
2014  * @return The Ecore_Evas window's sticky state.
2015  *
2016  */
2017 EAPI Eina_Bool
2018 ecore_evas_sticky_get(const Ecore_Evas *ee)
2019 {
2020    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2021      {
2022         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2023                          "ecore_evas_sticky_get");
2024         return EINA_FALSE;
2025      } else
2026      return ee->prop.sticky ? EINA_TRUE : EINA_FALSE;
2027 }
2028
2029 EAPI void
2030 ecore_evas_ignore_events_set(Ecore_Evas *ee, Eina_Bool ignore)
2031 {
2032    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2033      {
2034         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2035                          "ecore_evas_ignore_events_set");
2036         return;
2037      }
2038
2039    IFC(ee, fn_ignore_events_set) (ee, ignore);
2040    IFE;
2041 }
2042
2043 EAPI Eina_Bool
2044 ecore_evas_ignore_events_get(const Ecore_Evas *ee)
2045 {
2046    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2047      {
2048         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2049                          "ecore_evas_ignore_events_get");
2050         return EINA_FALSE;
2051      }
2052    return ee->ignore_events ? EINA_TRUE : EINA_FALSE;
2053 }
2054
2055 EAPI void
2056 ecore_evas_manual_render_set(Ecore_Evas *ee, Eina_Bool manual_render)
2057 {
2058    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2059      {
2060         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2061                          "ecore_evas_manual_render_set");
2062         return;
2063      }
2064    ee->manual_render = manual_render;
2065 }
2066
2067 EAPI Eina_Bool
2068 ecore_evas_manual_render_get(const Ecore_Evas *ee)
2069 {
2070    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2071      {
2072         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2073                          "ecore_evas_manual_render_get");
2074         return EINA_FALSE;
2075      }
2076    return ee->manual_render ? EINA_TRUE : EINA_FALSE;
2077 }
2078
2079 EAPI void
2080 ecore_evas_manual_render(Ecore_Evas *ee)
2081 {
2082    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2083      {
2084         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2085                          "ecore_evas_manual_render");
2086         return;
2087      }
2088    if (ee->engine.func->fn_render)
2089      ee->engine.func->fn_render(ee);
2090 }
2091
2092 EAPI void
2093 ecore_evas_comp_sync_set(Ecore_Evas *ee, Eina_Bool do_sync)
2094 {
2095    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2096      {
2097         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2098                          "ecore_evas_comp_sync_set");
2099         return;
2100      }
2101    ee->no_comp_sync = !do_sync;
2102 }
2103
2104 EAPI Eina_Bool
2105 ecore_evas_comp_sync_get(const Ecore_Evas *ee)
2106 {
2107    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2108      {
2109         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2110                          "ecore_evas_comp_sync_get");
2111         return EINA_FALSE;
2112      }
2113    return !ee->no_comp_sync;
2114 }
2115
2116 EAPI Ecore_Window
2117 ecore_evas_window_get(const Ecore_Evas *ee)
2118 {
2119    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2120    {
2121       ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2122          "ecore_evas_window_get");
2123       return 0;
2124    }
2125
2126    return ee->prop.window;
2127 }
2128
2129 EAPI void
2130 ecore_evas_screen_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h)
2131 {
2132    if (x) *x = 0;
2133    if (y) *y = 0;
2134    if (w) *w = 0;
2135    if (h) *h = 0;
2136    if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
2137      {
2138         ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
2139                          "ecore_evas_screen_geometry_get");
2140         return;
2141      }
2142
2143    IFC(ee, fn_screen_geometry_get) (ee, x, y, w, h);
2144    IFE;
2145 }
2146
2147 /* fps debug calls - for debugging how much time your app actually spends */
2148 /* rendering graphics... :) */
2149
2150 static int _ecore_evas_fps_debug_init_count = 0;
2151 static int _ecore_evas_fps_debug_fd = -1;
2152 unsigned int *_ecore_evas_fps_rendertime_mmap = NULL;
2153
2154 void
2155 _ecore_evas_fps_debug_init(void)
2156 {
2157    char buf[4096];
2158    const char *tmp;
2159
2160    _ecore_evas_fps_debug_init_count++;
2161    if (_ecore_evas_fps_debug_init_count > 1) return;
2162
2163 #ifndef HAVE_EVIL
2164    tmp = "/tmp";
2165 #else
2166    tmp = evil_tmpdir_get ();
2167 #endif /* HAVE_EVIL */
2168    snprintf(buf, sizeof(buf), "%s/.ecore_evas_fps_debug-%i", tmp, (int)getpid());
2169    _ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
2170    if (_ecore_evas_fps_debug_fd < 0)
2171      {
2172         unlink(buf);
2173         _ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
2174      }
2175    if (_ecore_evas_fps_debug_fd >= 0)
2176      {
2177         unsigned int zero = 0;
2178         char *buf2 = (char *)&zero;
2179         ssize_t todo = sizeof(unsigned int);
2180
2181         while (todo > 0)
2182           {
2183              ssize_t r = write(_ecore_evas_fps_debug_fd, buf2, todo);
2184              if (r > 0)
2185                {
2186                   todo -= r;
2187                   buf2 += r;
2188                }
2189              else if ((r < 0) && (errno == EINTR))
2190                continue;
2191              else
2192                {
2193                   ERR("could not write to file '%s' fd %d: %s",
2194                       buf, _ecore_evas_fps_debug_fd, strerror(errno));
2195                   close(_ecore_evas_fps_debug_fd);
2196                   _ecore_evas_fps_debug_fd = -1;
2197                   return;
2198                }
2199           }
2200         _ecore_evas_fps_rendertime_mmap = mmap(NULL, sizeof(unsigned int),
2201                                                PROT_READ | PROT_WRITE,
2202                                                MAP_SHARED,
2203                                                _ecore_evas_fps_debug_fd, 0);
2204         if (_ecore_evas_fps_rendertime_mmap == MAP_FAILED)
2205           _ecore_evas_fps_rendertime_mmap = NULL;
2206      }
2207 }
2208
2209 void
2210 _ecore_evas_fps_debug_shutdown(void)
2211 {
2212    _ecore_evas_fps_debug_init_count--;
2213    if (_ecore_evas_fps_debug_init_count > 0) return;
2214    if (_ecore_evas_fps_debug_fd >= 0)
2215      {
2216         char buf[4096];
2217
2218         snprintf(buf, sizeof(buf), "/tmp/.ecore_evas_fps_debug-%i", (int)getpid());
2219         unlink(buf);
2220         if (_ecore_evas_fps_rendertime_mmap)
2221           {
2222              munmap(_ecore_evas_fps_rendertime_mmap, sizeof(int));
2223              _ecore_evas_fps_rendertime_mmap = NULL;
2224           }
2225         close(_ecore_evas_fps_debug_fd);
2226         _ecore_evas_fps_debug_fd = -1;
2227      }
2228 }
2229
2230 void
2231 _ecore_evas_fps_debug_rendertime_add(double t)
2232 {
2233    static double rtime = 0.0;
2234    static double rlapse = 0.0;
2235    static int frames = 0;
2236    static int flapse = 0;
2237    double tim;
2238
2239    tim = ecore_time_get();
2240    rtime += t;
2241    frames++;
2242    if (rlapse == 0.0)
2243      {
2244         rlapse = tim;
2245         flapse = frames;
2246      }
2247    else if ((tim - rlapse) >= 0.5)
2248      {
2249         printf("FRAME: %i, FPS: %3.1f, RTIME %3.0f%%\n",
2250                frames,
2251                (frames - flapse) / (tim - rlapse),
2252                (100.0 * rtime) / (tim - rlapse)
2253                );
2254         rlapse = tim;
2255         flapse = frames;
2256         rtime = 0.0;
2257      }
2258 }
2259
2260 void
2261 _ecore_evas_register(Ecore_Evas *ee)
2262 {
2263    ee->registered = 1;
2264    ecore_evases = (Ecore_Evas *)eina_inlist_prepend
2265      (EINA_INLIST_GET(ecore_evases), EINA_INLIST_GET(ee));
2266 }
2267
2268 void
2269 _ecore_evas_ref(Ecore_Evas *ee)
2270 {
2271    ee->refcount++;
2272 }
2273
2274 void
2275 _ecore_evas_unref(Ecore_Evas *ee)
2276 {
2277    ee->refcount--;
2278    if (ee->refcount == 0)
2279      {
2280         if (ee->deleted) _ecore_evas_free(ee);
2281      }
2282    else if (ee->refcount < -1)
2283      ERR("Ecore_Evas %p->refcount=%d < 0", ee, ee->refcount);
2284 }
2285
2286 void
2287 _ecore_evas_free(Ecore_Evas *ee)
2288 {
2289    ee->deleted = EINA_TRUE;
2290    if (ee->refcount > 0) return;
2291
2292    if (ee->func.fn_pre_free) ee->func.fn_pre_free(ee);
2293    while (ee->sub_ecore_evas)
2294      {
2295         _ecore_evas_free(ee->sub_ecore_evas->data);
2296      }
2297    if (ee->data) eina_hash_free(ee->data);
2298    ee->data = NULL;
2299    if (ee->name) free(ee->name);
2300    ee->name = NULL;
2301    if (ee->prop.title) free(ee->prop.title);
2302    ee->prop.title = NULL;
2303    if (ee->prop.name) free(ee->prop.name);
2304    ee->prop.name = NULL;
2305    if (ee->prop.clas) free(ee->prop.clas);
2306    ee->prop.clas = NULL;
2307    if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
2308    ee->prop.cursor.object = NULL;
2309    if (ee->evas) evas_free(ee->evas);
2310    ee->evas = NULL;
2311    ECORE_MAGIC_SET(ee, ECORE_MAGIC_NONE);
2312    ee->driver = NULL;
2313    if (ee->engine.idle_flush_timer)
2314      ecore_timer_del(ee->engine.idle_flush_timer);
2315    if (ee->engine.func->fn_free) ee->engine.func->fn_free(ee);
2316    if (ee->registered)
2317      {
2318         ecore_evases = (Ecore_Evas *)eina_inlist_remove
2319           (EINA_INLIST_GET(ecore_evases), EINA_INLIST_GET(ee));
2320      }
2321    free(ee);
2322 }
2323
2324 static Eina_Bool
2325 _ecore_evas_cb_idle_flush(void *data)
2326 {
2327    Ecore_Evas *ee;
2328
2329    ee = (Ecore_Evas *)data;
2330    evas_render_idle_flush(ee->evas);
2331    ee->engine.idle_flush_timer = NULL;
2332    return ECORE_CALLBACK_CANCEL;
2333 }
2334
2335 static Eina_Bool
2336 _ecore_evas_async_events_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__)
2337 {
2338    evas_async_events_process();
2339
2340    return ECORE_CALLBACK_RENEW;
2341 }
2342
2343 void
2344 _ecore_evas_idle_timeout_update(Ecore_Evas *ee)
2345 {
2346    if (ee->engine.idle_flush_timer)
2347      ecore_timer_del(ee->engine.idle_flush_timer);
2348    ee->engine.idle_flush_timer = ecore_timer_add(IDLE_FLUSH_TIME,
2349                                                  _ecore_evas_cb_idle_flush,
2350                                                  ee);
2351 }
2352
2353 void
2354 _ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timestamp)
2355 {
2356    ee->mouse.x = x;
2357    ee->mouse.y = y;
2358    if (ee->prop.cursor.object)
2359      {
2360         evas_object_show(ee->prop.cursor.object);
2361         if (ee->rotation == 0)
2362           evas_object_move(ee->prop.cursor.object,
2363                            x - ee->prop.cursor.hot.x,
2364                            y - ee->prop.cursor.hot.y);
2365         else if (ee->rotation == 90)
2366           evas_object_move(ee->prop.cursor.object,
2367                            ee->h - y - 1 - ee->prop.cursor.hot.x,
2368                            x - ee->prop.cursor.hot.y);
2369         else if (ee->rotation == 180)
2370           evas_object_move(ee->prop.cursor.object,
2371                            ee->w - x - 1 - ee->prop.cursor.hot.x,
2372                            ee->h - y - 1 - ee->prop.cursor.hot.y);
2373         else if (ee->rotation == 270)
2374           evas_object_move(ee->prop.cursor.object,
2375                            y - ee->prop.cursor.hot.x,
2376                            ee->w - x - 1 - ee->prop.cursor.hot.y);
2377      }
2378    if (ee->rotation == 0)
2379      evas_event_feed_mouse_move(ee->evas, x, y, timestamp, NULL);
2380    else if (ee->rotation == 90)
2381      evas_event_feed_mouse_move(ee->evas, ee->h - y - 1, x, timestamp, NULL);
2382    else if (ee->rotation == 180)
2383      evas_event_feed_mouse_move(ee->evas, ee->w - x - 1, ee->h - y - 1, timestamp, NULL);
2384    else if (ee->rotation == 270)
2385      evas_event_feed_mouse_move(ee->evas, y, ee->w - x - 1, timestamp, NULL);
2386 }
2387
2388 void
2389 _ecore_evas_mouse_multi_move_process(Ecore_Evas *ee, int device,
2390                                      int x, int y,
2391                                      double radius,
2392                                      double radius_x, double radius_y,
2393                                      double pressure,
2394                                      double angle,
2395                                      double mx, double my,
2396                                      unsigned int timestamp)
2397 {
2398    if (ee->rotation == 0)
2399       evas_event_feed_multi_move(ee->evas, device,
2400                                  x, y,
2401                                  radius,
2402                                  radius_x, radius_y,
2403                                  pressure,
2404                                  angle - ee->rotation,
2405                                  mx, my,
2406                                  timestamp, NULL);
2407    else if (ee->rotation == 90)
2408       evas_event_feed_multi_move(ee->evas, device,
2409                                  ee->h - y - 1, x,
2410                                  radius,
2411                                  radius_y, radius_x,
2412                                  pressure,
2413                                  angle - ee->rotation,
2414                                  ee->h - my - 1, mx,
2415                                  timestamp, NULL);
2416    else if (ee->rotation == 180)
2417       evas_event_feed_multi_move(ee->evas, device,
2418                                  ee->w - x - 1, ee->h - y - 1,
2419                                  radius,
2420                                  radius_x, radius_y,
2421                                  pressure,
2422                                  angle - ee->rotation,
2423                                  ee->w - mx - 1, ee->h - my - 1,
2424                                  timestamp, NULL);
2425    else if (ee->rotation == 270)
2426       evas_event_feed_multi_move(ee->evas, device,
2427                                  y, ee->w - x - 1,
2428                                  radius,
2429                                  radius_y, radius_x,
2430                                  pressure,
2431                                  angle - ee->rotation,
2432                                  my, ee->w - mx - 1,
2433                                  timestamp, NULL);
2434 }
2435
2436 void
2437 _ecore_evas_mouse_multi_down_process(Ecore_Evas *ee, int device,
2438                                      int x, int y,
2439                                      double radius,
2440                                      double radius_x, double radius_y,
2441                                      double pressure,
2442                                      double angle,
2443                                      double mx, double my,
2444                                      Evas_Button_Flags flags,
2445                                      unsigned int timestamp)
2446 {
2447    if (ee->rotation == 0)
2448       evas_event_feed_multi_down(ee->evas, device,
2449                                  x, y,
2450                                  radius,
2451                                  radius_x, radius_y,
2452                                  pressure,
2453                                  angle - ee->rotation,
2454                                  mx, my,
2455                                  flags, timestamp, NULL);
2456    else if (ee->rotation == 90)
2457       evas_event_feed_multi_down(ee->evas, device,
2458                                  ee->h - y - 1, x,
2459                                  radius,
2460                                  radius_y, radius_x,
2461                                  pressure,
2462                                  angle - ee->rotation,
2463                                  ee->h - my - 1, mx,
2464                                  flags, timestamp, NULL);
2465    else if (ee->rotation == 180)
2466       evas_event_feed_multi_down(ee->evas, device,
2467                                  ee->w - x - 1, ee->h - y - 1,
2468                                  radius,
2469                                  radius_x, radius_y,
2470                                  pressure,
2471                                  angle - ee->rotation,
2472                                  ee->w - mx - 1, ee->h - my - 1,
2473                                  flags, timestamp, NULL);
2474    else if (ee->rotation == 270)
2475       evas_event_feed_multi_down(ee->evas, device,
2476                                  y, ee->w - x - 1,
2477                                  radius,
2478                                  radius_y, radius_x,
2479                                  pressure,
2480                                  angle - ee->rotation,
2481                                  my, ee->w - mx - 1,
2482                                  flags, timestamp, NULL);
2483 }
2484
2485 void
2486 _ecore_evas_mouse_multi_up_process(Ecore_Evas *ee, int device,
2487                                    int x, int y,
2488                                    double radius,
2489                                    double radius_x, double radius_y,
2490                                    double pressure,
2491                                    double angle,
2492                                    double mx, double my,
2493                                    Evas_Button_Flags flags,
2494                                    unsigned int timestamp)
2495 {
2496    if (ee->rotation == 0)
2497       evas_event_feed_multi_up(ee->evas, device,
2498                                x, y,
2499                                radius,
2500                                radius_x, radius_y,
2501                                pressure,
2502                                angle - ee->rotation,
2503                                mx, my,
2504                                flags, timestamp, NULL);
2505    else if (ee->rotation == 90)
2506       evas_event_feed_multi_up(ee->evas, device,
2507                                ee->h - y - 1, x,
2508                                radius,
2509                                radius_y, radius_x,
2510                                pressure,
2511                                angle - ee->rotation,
2512                                ee->h - my - 1, mx,
2513                                flags, timestamp, NULL);
2514    else if (ee->rotation == 180)
2515       evas_event_feed_multi_up(ee->evas, device,
2516                                ee->w - x - 1, ee->h - y - 1,
2517                                radius,
2518                                radius_x, radius_y,
2519                                pressure,
2520                                angle - ee->rotation,
2521                                ee->w - mx - 1, ee->h - my - 1,
2522                                flags, timestamp, NULL);
2523    else if (ee->rotation == 270)
2524       evas_event_feed_multi_up(ee->evas, device,
2525                                y, ee->w - x - 1,
2526                                radius,
2527                                radius_y, radius_x,
2528                                pressure,
2529                                angle - ee->rotation,
2530                                my, ee->w - mx - 1,
2531                                flags, timestamp, NULL);
2532 }
2533
2534 EAPI Eina_List *
2535 ecore_evas_ecore_evas_list_get(void)
2536 {
2537    Ecore_Evas *ee;
2538    Eina_List *l = NULL;
2539
2540    EINA_INLIST_FOREACH(ecore_evases, ee)
2541      {
2542         l = eina_list_append(l, ee);
2543      }
2544
2545    return l;
2546 }
2547
2548 EAPI void
2549 ecore_evas_input_event_register(Ecore_Evas *ee)
2550 {
2551    ecore_event_window_register((Ecore_Window)ee, ee, ee->evas,
2552                                (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
2553                                (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
2554                                (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
2555                                (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
2556 }
2557
2558 EAPI void
2559 ecore_evas_input_event_unregister(Ecore_Evas *ee)
2560 {
2561    ecore_event_window_unregister((Ecore_Window)ee);
2562 }