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