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