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