Tizen 2.1 base
[framework/uifw/ecore.git] / src / lib / ecore_evas / ecore_evas_private.h
1 #ifndef _ECORE_EVAS_PRIVATE_H
2 #define _ECORE_EVAS_PRIVATE_H
3
4 #include <Evas.h>
5 #include <Ecore.h>
6 #include <ecore_private.h>
7 #include <Ecore_Input.h>
8 #include <Ecore_Input_Evas.h>
9
10 #define ECORE_MAGIC_EVAS 0x76543211
11
12 #ifdef BUILD_ECORE_EVAS_X11
13 # include <Ecore_X.h>
14 # include <Ecore_X_Atoms.h>
15 # ifdef HAVE_ECORE_X_XCB
16 #  include <xcb/xcb.h>
17 # endif
18 # ifdef HAVE_ECORE_X_XLIB
19 #  include <X11/Xlib.h>
20 #  include <X11/Xutil.h>
21 # endif
22 #endif
23
24 #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11
25 # include <Evas_Engine_Software_X11.h>
26 #endif
27
28 #ifdef BUILD_ECORE_EVAS_OPENGL_X11
29 # include <Evas_Engine_GL_X11.h>
30 #endif
31
32 #ifdef BUILD_ECORE_EVAS_SOFTWARE_8_X11
33 # include <Evas_Engine_Software_8_X11.h>
34 #endif
35
36 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_X11
37 # include <Evas_Engine_Software_16_X11.h>
38 #endif
39
40 #ifdef BUILD_ECORE_EVAS_FB
41 # include <Evas_Engine_FB.h>
42 #endif
43
44 #ifdef BUILD_ECORE_EVAS_DIRECTFB
45 # include <Evas_Engine_DirectFB.h>
46 # include "Ecore_DirectFB.h"
47 #endif
48
49 #if defined(BUILD_ECORE_EVAS_SOFTWARE_BUFFER) || defined(BUILD_ECORE_EVAS_EWS)
50 # include <Evas_Engine_Buffer.h>
51 #endif
52
53 #ifdef BUILD_ECORE_EVAS_WIN32
54 # include "Ecore_Win32.h"
55 # ifdef BUILD_ECORE_EVAS_SOFTWARE_GDI
56 #  include <Evas_Engine_Software_Gdi.h>
57 # endif
58 # ifdef BUILD_ECORE_EVAS_SOFTWARE_DDRAW
59 #  include <Evas_Engine_Software_DDraw.h>
60 # endif
61 # ifdef BUILD_ECORE_EVAS_DIRECT3D
62 #  include <Evas_Engine_Direct3D.h>
63 # endif
64 # ifdef BUILD_ECORE_EVAS_OPENGL_GLEW
65 #  include <Evas_Engine_GL_Glew.h>
66 # endif
67 # ifdef BUILD_ECORE_EVAS_SOFTWARE_16_DDRAW
68 #  include <Evas_Engine_Software_16_DDraw.h>
69 # endif
70 #endif
71
72 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
73 # include "Ecore_WinCE.h"
74 # include <Evas_Engine_Software_16_WinCE.h>
75 #endif
76
77 #ifdef BUILD_ECORE_EVAS_GL_COCOA
78 # include "Ecore_Cocoa.h"
79 # include <Evas_Engine_Gl_Cocoa.h>
80 #endif
81
82 #if defined(BUILD_ECORE_EVAS_WAYLAND_SHM) || defined(BUILD_ECORE_EVAS_WAYLAND_EGL)
83 # include "Ecore_Wayland.h"
84 #endif
85
86 #ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
87 # include <Evas_Engine_Wayland_Shm.h>
88 #endif
89
90 #ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
91 # include <Evas_Engine_Wayland_Egl.h>
92 #endif
93
94 /** Log domain macros and variables **/
95
96 extern int _ecore_evas_log_dom;
97
98 #ifdef ECORE_EVAS_DEFAULT_LOG_COLOR
99 # undef ECORE_EVAS_DEFAULT_LOG_COLOR
100 #endif
101 #define ECORE_EVAS_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
102
103 #ifdef ERR
104 # undef ERR
105 #endif
106 #define ERR(...) EINA_LOG_DOM_ERR(_ecore_evas_log_dom, __VA_ARGS__)
107 #ifdef DBG
108 # undef DBG
109 #endif
110 #define DBG(...) EINA_LOG_DOM_DBG(_ecore_evas_log_dom, __VA_ARGS__)
111 #ifdef INF
112 # undef INF
113 #endif
114 #define INF(...) EINA_LOG_DOM_INFO(_ecore_evas_log_dom, __VA_ARGS__)
115 #ifdef WRN
116 # undef WRN
117 #endif
118 #define WRN(...) EINA_LOG_DOM_WARN(_ecore_evas_log_dom, __VA_ARGS__)
119 #ifdef CRIT
120 # undef CRIT
121 #endif
122 #define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_evas_log_dom, __VA_ARGS__)
123
124
125 #define IDLE_FLUSH_TIME 0.5
126 #ifndef _ECORE_EVAS_H
127 typedef struct _Ecore_Evas Ecore_Evas;
128 typedef void   (*Ecore_Evas_Event_Cb) (Ecore_Evas *ee);
129 #endif
130
131 typedef struct _Ecore_Evas_Engine Ecore_Evas_Engine;
132 typedef struct _Ecore_Evas_Engine_Func Ecore_Evas_Engine_Func;
133
134 struct _Ecore_Evas_Engine_Func
135 {
136    void (*fn_free) (Ecore_Evas *ee);
137    void (*fn_callback_resize_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
138    void (*fn_callback_move_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
139    void (*fn_callback_show_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
140    void (*fn_callback_hide_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
141    void (*fn_callback_delete_request_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
142    void (*fn_callback_destroy_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
143    void (*fn_callback_focus_in_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
144    void (*fn_callback_focus_out_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
145    void (*fn_callback_mouse_in_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
146    void (*fn_callback_mouse_out_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
147    void (*fn_callback_sticky_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
148    void (*fn_callback_unsticky_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
149    void (*fn_callback_pre_render_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
150    void (*fn_callback_post_render_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
151    void (*fn_move) (Ecore_Evas *ee, int x, int y);
152    void (*fn_managed_move) (Ecore_Evas *ee, int x, int y);
153    void (*fn_resize) (Ecore_Evas *ee, int w, int h);
154    void (*fn_move_resize) (Ecore_Evas *ee, int x, int y, int w, int h);
155    void (*fn_rotation_set) (Ecore_Evas *ee, int rot, int resize);
156    void (*fn_shaped_set) (Ecore_Evas *ee, int shaped);
157    void (*fn_show) (Ecore_Evas *ee);
158    void (*fn_hide) (Ecore_Evas *ee);
159    void (*fn_raise) (Ecore_Evas *ee);
160    void (*fn_lower) (Ecore_Evas *ee);
161    void (*fn_activate) (Ecore_Evas *ee);
162    void (*fn_title_set) (Ecore_Evas *ee, const char *t);
163    void (*fn_name_class_set) (Ecore_Evas *ee, const char *n, const char *c);
164    void (*fn_size_min_set) (Ecore_Evas *ee, int w, int h);
165    void (*fn_size_max_set) (Ecore_Evas *ee, int w, int h);
166    void (*fn_size_base_set) (Ecore_Evas *ee, int w, int h);
167    void (*fn_size_step_set) (Ecore_Evas *ee, int w, int h);
168    void (*fn_object_cursor_set) (Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y);
169    void (*fn_layer_set) (Ecore_Evas *ee, int layer);
170    void (*fn_focus_set) (Ecore_Evas *ee, int on);
171    void (*fn_iconified_set) (Ecore_Evas *ee, int on);
172    void (*fn_borderless_set) (Ecore_Evas *ee, int on);
173    void (*fn_override_set) (Ecore_Evas *ee, int on);
174    void (*fn_maximized_set) (Ecore_Evas *ee, int on);
175    void (*fn_fullscreen_set) (Ecore_Evas *ee, int on);
176    void (*fn_avoid_damage_set) (Ecore_Evas *ee, int on);
177    void (*fn_withdrawn_set) (Ecore_Evas *ee, int withdrawn);
178    void (*fn_sticky_set) (Ecore_Evas *ee, int sticky);
179    void (*fn_ignore_events_set) (Ecore_Evas *ee, int ignore);
180    void (*fn_alpha_set) (Ecore_Evas *ee, int alpha);
181    void (*fn_transparent_set) (Ecore_Evas *ee, int transparent);
182    void (*fn_profiles_set) (Ecore_Evas *ee, const char **profiles, int num_profiles);
183
184    void (*fn_window_group_set) (Ecore_Evas *ee, const Ecore_Evas *ee_group);
185    void (*fn_aspect_set) (Ecore_Evas *ee, double aspect);
186    void (*fn_urgent_set) (Ecore_Evas *ee, int urgent);
187    void (*fn_modal_set) (Ecore_Evas *ee, int modal);
188    void (*fn_demands_attention_set) (Ecore_Evas *ee, int demand);
189    void (*fn_focus_skip_set) (Ecore_Evas *ee, int skip);
190
191    int (*fn_render) (Ecore_Evas *ee);
192    void (*fn_screen_geometry_get) (const Ecore_Evas *ee, int *x, int *y, int *w, int *h);
193    void (*fn_screen_dpi_get) (const Ecore_Evas *ee, int *xdpi, int *ydpi);
194 };
195
196 struct _Ecore_Evas_Engine
197 {
198    Ecore_Evas_Engine_Func *func;
199
200 /* TODO: UGLY! This should be an union or inheritance! */
201 #ifdef BUILD_ECORE_EVAS_X11
202    struct 
203      {
204       Ecore_X_Window win_root;
205       Eina_List     *win_extra;
206       Ecore_X_Pixmap pmap;
207       Ecore_X_Pixmap mask;
208       Ecore_X_GC     gc;
209       Ecore_X_XRegion *damages;
210       Ecore_X_Sync_Counter sync_counter;
211       Ecore_X_Window leader;
212       Ecore_X_Sync_Counter netwm_sync_counter;
213       int            netwm_sync_val_hi;
214       unsigned int   netwm_sync_val_lo;
215       int            sync_val; // bigger! this will screw up at 2 billion frames (414 days of continual rendering @ 60fps)
216       int            screen_num;
217       int            px, py, pw, ph;
218       unsigned char  direct_resize : 1;
219       unsigned char  using_bg_pixmap : 1;
220       unsigned char  managed : 1;
221       unsigned char  sync_began : 1;
222       unsigned char  sync_cancel : 1;
223       unsigned char  netwm_sync_set : 1;
224       unsigned char  configure_coming : 1;
225       struct {
226            unsigned char modal : 1;
227            unsigned char sticky : 1;
228            unsigned char maximized_v : 1;
229            unsigned char maximized_h : 1;
230            unsigned char shaded : 1;
231            unsigned char skip_taskbar : 1;
232            unsigned char skip_pager : 1;
233            unsigned char fullscreen : 1;
234            unsigned char above : 1;
235            unsigned char below : 1;
236       } state;
237       Ecore_X_Window win_shaped_input;
238    } x;
239 #endif
240 #ifdef BUILD_ECORE_EVAS_FB
241    struct {
242       int real_w;
243       int real_h;
244    } fb;
245 #endif
246 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
247    struct {
248       void *pixels;
249       Evas_Object *image;
250       void  (*free_func) (void *data, void *pix);
251       void *(*alloc_func) (void *data, int size);
252       void *data;
253    } buffer;
254 #endif
255 #ifdef BUILD_ECORE_EVAS_DIRECTFB
256    struct {
257       Ecore_DirectFB_Window *window;
258    } directfb;
259 #endif
260 #ifdef BUILD_ECORE_EVAS_WIN32
261    struct {
262       Ecore_Win32_Window *parent;
263       struct {
264          unsigned char region     : 1;
265          unsigned char fullscreen : 1;
266       } state;
267    } win32;
268 #endif
269 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
270    struct {
271       Ecore_WinCE_Window *window;
272       struct {
273          unsigned char fullscreen : 1;
274       } state;
275    } wince;
276 #endif
277 #ifdef BUILD_ECORE_EVAS_EWS
278    struct {
279       Evas_Object *image;
280    } ews;
281 #endif
282
283 #if defined(BUILD_ECORE_EVAS_WAYLAND_SHM) || defined(BUILD_ECORE_EVAS_WAYLAND_EGL)
284    struct 
285      {
286         Ecore_Wl_Window *parent, *win;
287         Evas_Object *frame;
288
289 # if defined(BUILD_ECORE_EVAS_WAYLAND_SHM)
290         struct wl_shm_pool *pool;
291         size_t pool_size;
292         void *pool_data;
293         struct wl_buffer *buffer;
294 # endif
295
296      } wl;
297 #endif
298
299    Ecore_Timer *idle_flush_timer;
300 };
301
302 struct _Ecore_Evas
303 {
304    EINA_INLIST;
305    ECORE_MAGIC;
306    Evas       *evas;
307    const char *driver;
308    char       *name;
309    int         x, y, w, h;
310    short       rotation;
311    Eina_Bool   shaped  : 1;
312    Eina_Bool   visible : 1;
313    Eina_Bool   draw_ok : 1;
314    Eina_Bool   should_be_visible : 1;
315    Eina_Bool   alpha  : 1;
316    Eina_Bool   transparent  : 1;
317    Eina_Bool   in  : 1;
318
319    Eina_Hash  *data;
320
321    struct {
322       int      x, y, w, h;
323    } req;
324    
325    struct {
326       int      x, y;
327    } mouse;
328
329    struct {
330       int      w, h;
331    } expecting_resize;
332
333    struct {
334       char           *title;
335       char           *name;
336       char           *clas;
337       char           *profile;
338       struct {
339          int          w, h;
340       } min,
341         max,
342         base,
343         step;
344       struct {
345          Evas_Object *object;
346          int          layer;
347          struct {
348             int       x, y;
349          } hot;
350       } cursor;
351       int             layer;
352       Ecore_Window    window;
353       unsigned char   avoid_damage;
354       Ecore_Evas     *group_ee;
355       Ecore_Window    group_ee_win;
356       double          aspect;
357       char            focused      : 1;
358       char            iconified    : 1;
359       char            borderless   : 1;
360       char            override     : 1;
361       char            maximized    : 1;
362       char            fullscreen   : 1;
363       char            withdrawn    : 1;
364       char            sticky       : 1;
365       char            request_pos  : 1;
366       char            draw_frame   : 1;
367       char            hwsurface    : 1;
368       char            urgent           : 1;
369       char            modal            : 1;
370       char            demand_attention : 1;
371       char            focus_skip       : 1;
372   } prop;
373
374    struct {
375       void          (*fn_resize) (Ecore_Evas *ee);
376       void          (*fn_move) (Ecore_Evas *ee);
377       void          (*fn_show) (Ecore_Evas *ee);
378       void          (*fn_hide) (Ecore_Evas *ee);
379       void          (*fn_delete_request) (Ecore_Evas *ee);
380       void          (*fn_destroy) (Ecore_Evas *ee);
381       void          (*fn_focus_in) (Ecore_Evas *ee);
382       void          (*fn_focus_out) (Ecore_Evas *ee);
383       void          (*fn_sticky) (Ecore_Evas *ee);
384       void          (*fn_unsticky) (Ecore_Evas *ee);
385       void          (*fn_mouse_in) (Ecore_Evas *ee);
386       void          (*fn_mouse_out) (Ecore_Evas *ee);
387       void          (*fn_pre_render) (Ecore_Evas *ee);
388       void          (*fn_post_render) (Ecore_Evas *ee);
389       void          (*fn_pre_free) (Ecore_Evas *ee);
390       void          (*fn_state_change) (Ecore_Evas *ee);
391    } func;
392
393    Ecore_Evas_Engine engine;
394    Eina_List *sub_ecore_evas;
395
396    int refcount;
397
398    unsigned char ignore_events : 1;
399    unsigned char manual_render : 1;
400    unsigned char registered : 1;
401    unsigned char no_comp_sync  : 1;
402    unsigned char semi_sync  : 1;
403    unsigned char deleted : 1;
404    int           gl_sync_draw_done; // added by gl77.lee
405 };
406
407 void _ecore_evas_ref(Ecore_Evas *ee);
408 void _ecore_evas_unref(Ecore_Evas *ee);
409
410 #ifdef BUILD_ECORE_EVAS_X11
411 int _ecore_evas_x_shutdown(void);
412 #endif
413 #ifdef BUILD_ECORE_EVAS_FB
414 int _ecore_evas_fb_shutdown(void);
415 #endif
416 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
417 int _ecore_evas_buffer_shutdown(void);
418 int _ecore_evas_buffer_render(Ecore_Evas *ee);
419 #endif
420 #ifdef BUILD_ECORE_EVAS_DIRECTFB
421 int _ecore_evas_directfb_shutdown(void);
422 #endif
423 #ifdef BUILD_ECORE_EVAS_WIN32
424 int _ecore_evas_win32_shutdown(void);
425 #endif
426 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
427 int _ecore_evas_wince_shutdown(void);
428 #endif
429 #ifdef BUILD_ECORE_EVAS_EWS
430 void _ecore_evas_ews_events_init(void);
431 int _ecore_evas_ews_shutdown(void);
432 #endif
433
434 #if defined(BUILD_ECORE_EVAS_WAYLAND_SHM) || defined(BUILD_ECORE_EVAS_WAYLAND_EGL)
435 int  _ecore_evas_wl_common_init(void);
436 int  _ecore_evas_wl_common_shutdown(void);
437 void _ecore_evas_wl_common_pre_free(Ecore_Evas *ee);
438 void _ecore_evas_wl_common_free(Ecore_Evas *ee);
439 void _ecore_evas_wl_common_callback_resize_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
440 void _ecore_evas_wl_common_callback_move_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
441 void _ecore_evas_wl_common_callback_delete_request_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
442 void _ecore_evas_wl_common_callback_focus_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
443 void _ecore_evas_wl_common_callback_focus_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
444 void _ecore_evas_wl_common_callback_mouse_in_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
445 void _ecore_evas_wl_common_callback_mouse_out_set(Ecore_Evas *ee, void (*func)(Ecore_Evas *ee));
446 void _ecore_evas_wl_common_move(Ecore_Evas *ee, int x, int y);
447 void _ecore_evas_wl_common_raise(Ecore_Evas *ee);
448 void _ecore_evas_wl_common_title_set(Ecore_Evas *ee, const char *title);
449 void _ecore_evas_wl_common_name_class_set(Ecore_Evas *ee, const char *n, const char *c);
450 void _ecore_evas_wl_common_size_min_set(Ecore_Evas *ee, int w, int h);
451 void _ecore_evas_wl_common_size_max_set(Ecore_Evas *ee, int w, int h);
452 void _ecore_evas_wl_common_size_base_set(Ecore_Evas *ee, int w, int h);
453 void _ecore_evas_wl_common_size_step_set(Ecore_Evas *ee, int w, int h);
454 void _ecore_evas_wl_common_layer_set(Ecore_Evas *ee, int layer);
455 void _ecore_evas_wl_common_iconified_set(Ecore_Evas *ee, int iconify);
456 void _ecore_evas_wl_common_maximized_set(Ecore_Evas *ee, int max);
457 void _ecore_evas_wl_common_fullscreen_set(Ecore_Evas *ee, int full);
458 void _ecore_evas_wl_common_ignore_events_set(Ecore_Evas *ee, int ignore);
459 int  _ecore_evas_wl_common_pre_render(Ecore_Evas *ee);
460 int  _ecore_evas_wl_common_render_updates(Ecore_Evas *ee);
461 void _ecore_evas_wl_common_post_render(Ecore_Evas *ee);
462 int  _ecore_evas_wl_common_render(Ecore_Evas *ee);
463 void _ecore_evas_wl_common_screen_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h);
464 void _ecore_evas_wl_common_screen_dpi_get(const Ecore_Evas *ee, int *xdpi, int *ydpi);
465
466 Evas_Object * _ecore_evas_wl_common_frame_add(Evas *evas);
467
468 #ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
469 void _ecore_evas_wayland_shm_resize(Ecore_Evas *ee, int location);
470 #endif
471
472 #ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
473 void _ecore_evas_wayland_egl_resize(Ecore_Evas *ee, int location);
474 #endif
475 #endif
476
477 void _ecore_evas_fps_debug_init(void);
478 void _ecore_evas_fps_debug_shutdown(void);
479 void _ecore_evas_fps_debug_rendertime_add(double t);
480 void _ecore_evas_register(Ecore_Evas *ee);
481 void _ecore_evas_free(Ecore_Evas *ee);
482 void _ecore_evas_idle_timeout_update(Ecore_Evas *ee);
483 void _ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timestamp);
484 void _ecore_evas_mouse_multi_move_process(Ecore_Evas *ee, int device,
485                                           int x, int y,
486                                           double radius,
487                                           double radius_x, double radius_y,
488                                           double pressure,
489                                           double angle,
490                                           double mx, double my,
491                                           unsigned int timestamp);
492 void _ecore_evas_mouse_multi_down_process(Ecore_Evas *ee, int device,
493                                           int x, int y,
494                                           double radius,
495                                           double radius_x, double radius_y,
496                                           double pressure,
497                                           double angle,
498                                           double mx, double my,
499                                           Evas_Button_Flags flags,
500                                           unsigned int timestamp);
501 void _ecore_evas_mouse_multi_up_process(Ecore_Evas *ee, int device,
502                                         int x, int y,
503                                         double radius,
504                                         double radius_x, double radius_y,
505                                         double pressure,
506                                         double angle,
507                                         double mx, double my,
508                                         Evas_Button_Flags flags,
509                                         unsigned int timestamp);
510
511 extern Eina_Bool _ecore_evas_app_comp_sync;
512
513 void _ecore_evas_extn_init(void);
514 void _ecore_evas_extn_shutdown(void);
515
516 #endif