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