Add wm_rotation infrastructure support
[platform/upstream/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 #ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
83 # include "Ecore_Wayland.h"
84 # include <Evas_Engine_Wayland_Shm.h>
85 #endif
86
87 #ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
88 # include "Ecore_Wayland.h"
89 # include <Evas_Engine_Wayland_Egl.h>
90 #endif
91
92 /** Log domain macros and variables **/
93
94 extern int _ecore_evas_log_dom;
95
96 #ifdef ECORE_EVAS_DEFAULT_LOG_COLOR
97 # undef ECORE_EVAS_DEFAULT_LOG_COLOR
98 #endif
99 #define ECORE_EVAS_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
100
101 #ifdef ERR
102 # undef ERR
103 #endif
104 #define ERR(...) EINA_LOG_DOM_ERR(_ecore_evas_log_dom, __VA_ARGS__)
105 #ifdef DBG
106 # undef DBG
107 #endif
108 #define DBG(...) EINA_LOG_DOM_DBG(_ecore_evas_log_dom, __VA_ARGS__)
109 #ifdef INF
110 # undef INF
111 #endif
112 #define INF(...) EINA_LOG_DOM_INFO(_ecore_evas_log_dom, __VA_ARGS__)
113 #ifdef WRN
114 # undef WRN
115 #endif
116 #define WRN(...) EINA_LOG_DOM_WARN(_ecore_evas_log_dom, __VA_ARGS__)
117 #ifdef CRIT
118 # undef CRIT
119 #endif
120 #define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_evas_log_dom, __VA_ARGS__)
121
122
123 #define IDLE_FLUSH_TIME 0.5
124 #ifndef _ECORE_EVAS_H
125 typedef struct _Ecore_Evas Ecore_Evas;
126 typedef void   (*Ecore_Evas_Event_Cb) (Ecore_Evas *ee);
127 #endif
128
129 typedef struct _Ecore_Evas_Engine Ecore_Evas_Engine;
130 typedef struct _Ecore_Evas_Engine_Func Ecore_Evas_Engine_Func;
131
132 struct _Ecore_Evas_Engine_Func
133 {
134    void (*fn_free) (Ecore_Evas *ee);
135    void (*fn_callback_resize_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
136    void (*fn_callback_move_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
137    void (*fn_callback_show_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
138    void (*fn_callback_hide_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
139    void (*fn_callback_delete_request_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
140    void (*fn_callback_destroy_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
141    void (*fn_callback_focus_in_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
142    void (*fn_callback_focus_out_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
143    void (*fn_callback_mouse_in_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
144    void (*fn_callback_mouse_out_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
145    void (*fn_callback_sticky_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
146    void (*fn_callback_unsticky_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
147    void (*fn_callback_pre_render_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
148    void (*fn_callback_post_render_set) (Ecore_Evas *ee, Ecore_Evas_Event_Cb func);
149    void (*fn_move) (Ecore_Evas *ee, int x, int y);
150    void (*fn_managed_move) (Ecore_Evas *ee, int x, int y);
151    void (*fn_resize) (Ecore_Evas *ee, int w, int h);
152    void (*fn_move_resize) (Ecore_Evas *ee, int x, int y, int w, int h);
153    void (*fn_rotation_set) (Ecore_Evas *ee, int rot, int resize);
154    void (*fn_shaped_set) (Ecore_Evas *ee, int shaped);
155    void (*fn_show) (Ecore_Evas *ee);
156    void (*fn_hide) (Ecore_Evas *ee);
157    void (*fn_raise) (Ecore_Evas *ee);
158    void (*fn_lower) (Ecore_Evas *ee);
159    void (*fn_activate) (Ecore_Evas *ee);
160    void (*fn_title_set) (Ecore_Evas *ee, const char *t);
161    void (*fn_name_class_set) (Ecore_Evas *ee, const char *n, const char *c);
162    void (*fn_size_min_set) (Ecore_Evas *ee, int w, int h);
163    void (*fn_size_max_set) (Ecore_Evas *ee, int w, int h);
164    void (*fn_size_base_set) (Ecore_Evas *ee, int w, int h);
165    void (*fn_size_step_set) (Ecore_Evas *ee, int w, int h);
166    void (*fn_object_cursor_set) (Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y);
167    void (*fn_layer_set) (Ecore_Evas *ee, int layer);
168    void (*fn_focus_set) (Ecore_Evas *ee, int on);
169    void (*fn_iconified_set) (Ecore_Evas *ee, int on);
170    void (*fn_borderless_set) (Ecore_Evas *ee, int on);
171    void (*fn_override_set) (Ecore_Evas *ee, int on);
172    void (*fn_maximized_set) (Ecore_Evas *ee, int on);
173    void (*fn_fullscreen_set) (Ecore_Evas *ee, int on);
174    void (*fn_avoid_damage_set) (Ecore_Evas *ee, int on);
175    void (*fn_withdrawn_set) (Ecore_Evas *ee, int withdrawn);
176    void (*fn_sticky_set) (Ecore_Evas *ee, int sticky);
177    void (*fn_ignore_events_set) (Ecore_Evas *ee, int ignore);
178    void (*fn_alpha_set) (Ecore_Evas *ee, int alpha);
179    void (*fn_transparent_set) (Ecore_Evas *ee, int transparent);
180    void (*fn_profiles_set) (Ecore_Evas *ee, const char **profiles, int num_profiles);
181
182    void (*fn_window_group_set) (Ecore_Evas *ee, const Ecore_Evas *ee_group);
183    void (*fn_aspect_set) (Ecore_Evas *ee, double aspect);
184    void (*fn_urgent_set) (Ecore_Evas *ee, int urgent);
185    void (*fn_modal_set) (Ecore_Evas *ee, int modal);
186    void (*fn_demands_attention_set) (Ecore_Evas *ee, int demand);
187    void (*fn_focus_skip_set) (Ecore_Evas *ee, int skip);
188
189    int (*fn_render) (Ecore_Evas *ee);
190    void (*fn_screen_geometry_get) (const Ecore_Evas *ee, int *x, int *y, int *w, int *h);
191    void (*fn_screen_dpi_get) (const Ecore_Evas *ee, int *xdpi, int *ydpi);
192    void (*fn_wm_rot_preferred_rotation_set) (Ecore_Evas *ee, int rot);
193    void (*fn_wm_rot_available_rotations_set) (Ecore_Evas *ee, const int *rots, unsigned int count);
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 supported: 1;
227            unsigned char prepare : 1;
228            unsigned char request : 1;
229            unsigned char done : 1;
230            unsigned char configure_coming : 1;
231       } wm_rot;
232       struct {
233            unsigned char modal : 1;
234            unsigned char sticky : 1;
235            unsigned char maximized_v : 1;
236            unsigned char maximized_h : 1;
237            unsigned char shaded : 1;
238            unsigned char skip_taskbar : 1;
239            unsigned char skip_pager : 1;
240            unsigned char fullscreen : 1;
241            unsigned char above : 1;
242            unsigned char below : 1;
243       } state;
244       Ecore_X_Window win_shaped_input;
245    } x;
246 #endif
247 #ifdef BUILD_ECORE_EVAS_FB
248    struct {
249       int real_w;
250       int real_h;
251    } fb;
252 #endif
253 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
254    struct {
255       void *pixels;
256       Evas_Object *image;
257       void  (*free_func) (void *data, void *pix);
258       void *(*alloc_func) (void *data, int size);
259       void *data;
260    } buffer;
261 #endif
262 #ifdef BUILD_ECORE_EVAS_DIRECTFB
263    struct {
264       Ecore_DirectFB_Window *window;
265    } directfb;
266 #endif
267 #ifdef BUILD_ECORE_EVAS_WIN32
268    struct {
269       Ecore_Win32_Window *parent;
270       struct {
271          unsigned char region     : 1;
272          unsigned char fullscreen : 1;
273       } state;
274    } win32;
275 #endif
276 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
277    struct {
278       Ecore_WinCE_Window *window;
279       struct {
280          unsigned char fullscreen : 1;
281       } state;
282    } wince;
283 #endif
284 #ifdef BUILD_ECORE_EVAS_EWS
285    struct {
286       Evas_Object *image;
287    } ews;
288 #endif
289
290 #if defined(BUILD_ECORE_EVAS_WAYLAND_SHM) || defined(BUILD_ECORE_EVAS_WAYLAND_EGL)
291    struct 
292      {
293         Ecore_Wl_Window *parent, *win;
294         Evas_Object *frame;
295
296 # if defined(BUILD_ECORE_EVAS_WAYLAND_SHM)
297         struct wl_shm_pool *pool;
298         size_t pool_size;
299         void *pool_data;
300         struct wl_buffer *buffer;
301         Eina_Bool buffer_valid;
302 # endif
303
304      } wl;
305 #endif
306
307    Ecore_Timer *idle_flush_timer;
308 };
309
310 struct _Ecore_Evas
311 {
312    EINA_INLIST;
313    ECORE_MAGIC;
314    Evas       *evas;
315    const char *driver;
316    char       *name;
317    int         x, y, w, h;
318    short       rotation;
319    Eina_Bool   shaped  : 1;
320    Eina_Bool   visible : 1;
321    Eina_Bool   draw_ok : 1;
322    Eina_Bool   should_be_visible : 1;
323    Eina_Bool   alpha  : 1;
324    Eina_Bool   transparent  : 1;
325    Eina_Bool   in  : 1;
326
327    Eina_Hash  *data;
328
329    struct {
330       int      x, y, w, h;
331    } req;
332    
333    struct {
334       int      x, y;
335    } mouse;
336
337    struct {
338       int      w, h;
339    } expecting_resize;
340
341    struct {
342       char           *title;
343       char           *name;
344       char           *clas;
345       char           *profile;
346       struct {
347          Eina_Bool    supported;
348          int          angle;         // v0
349          Eina_Bool    win_resize;    // v0
350          int          w, h;          // v0
351          // added for the window manager rotation protocol
352          Eina_Bool    app_set;       // v1: app wants to communicate with the window manager to rotate
353          int          rot;           // v1: decided rotation by the window manager
354          int          preferred_rot; // v1: app specified rotation
355          int         *available_rots;// v1: app specified available rotations
356          unsigned int count;         // v1: number of elements of available rotations
357       } wm_rot;
358       struct {
359          int          w, h;
360       } min,
361         max,
362         base,
363         step;
364       struct {
365          Evas_Object *object;
366          int          layer;
367          struct {
368             int       x, y;
369          } hot;
370       } cursor;
371       int             layer;
372       Ecore_Window    window;
373       unsigned char   avoid_damage;
374       Ecore_Evas     *group_ee;
375       Ecore_Window    group_ee_win;
376       double          aspect;
377       char            focused      : 1;
378       char            iconified    : 1;
379       char            borderless   : 1;
380       char            override     : 1;
381       char            maximized    : 1;
382       char            fullscreen   : 1;
383       char            withdrawn    : 1;
384       char            sticky       : 1;
385       char            request_pos  : 1;
386       char            draw_frame   : 1;
387       char            hwsurface    : 1;
388       char            urgent           : 1;
389       char            modal            : 1;
390       char            demand_attention : 1;
391       char            focus_skip       : 1;
392   } prop;
393
394    struct {
395       void          (*fn_resize) (Ecore_Evas *ee);
396       void          (*fn_move) (Ecore_Evas *ee);
397       void          (*fn_show) (Ecore_Evas *ee);
398       void          (*fn_hide) (Ecore_Evas *ee);
399       void          (*fn_delete_request) (Ecore_Evas *ee);
400       void          (*fn_destroy) (Ecore_Evas *ee);
401       void          (*fn_focus_in) (Ecore_Evas *ee);
402       void          (*fn_focus_out) (Ecore_Evas *ee);
403       void          (*fn_sticky) (Ecore_Evas *ee);
404       void          (*fn_unsticky) (Ecore_Evas *ee);
405       void          (*fn_mouse_in) (Ecore_Evas *ee);
406       void          (*fn_mouse_out) (Ecore_Evas *ee);
407       void          (*fn_pre_render) (Ecore_Evas *ee);
408       void          (*fn_post_render) (Ecore_Evas *ee);
409       void          (*fn_pre_free) (Ecore_Evas *ee);
410       void          (*fn_state_change) (Ecore_Evas *ee);
411    } func;
412
413    Ecore_Evas_Engine engine;
414    Eina_List *sub_ecore_evas;
415
416    int refcount;
417
418    unsigned char ignore_events : 1;
419    unsigned char manual_render : 1;
420    unsigned char registered : 1;
421    unsigned char no_comp_sync  : 1;
422    unsigned char semi_sync  : 1;
423    unsigned char deleted : 1;
424    int           gl_sync_draw_done; // added by gl77.lee
425 };
426
427 void _ecore_evas_ref(Ecore_Evas *ee);
428 void _ecore_evas_unref(Ecore_Evas *ee);
429
430 #ifdef BUILD_ECORE_EVAS_X11
431 int _ecore_evas_x_shutdown(void);
432 #endif
433 #ifdef BUILD_ECORE_EVAS_FB
434 int _ecore_evas_fb_shutdown(void);
435 #endif
436 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
437 int _ecore_evas_buffer_shutdown(void);
438 int _ecore_evas_buffer_render(Ecore_Evas *ee);
439 #endif
440 #ifdef BUILD_ECORE_EVAS_DIRECTFB
441 int _ecore_evas_directfb_shutdown(void);
442 #endif
443 #ifdef BUILD_ECORE_EVAS_WIN32
444 int _ecore_evas_win32_shutdown(void);
445 #endif
446 #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
447 int _ecore_evas_wince_shutdown(void);
448 #endif
449 #ifdef BUILD_ECORE_EVAS_EWS
450 void _ecore_evas_ews_events_init(void);
451 int _ecore_evas_ews_shutdown(void);
452 #endif
453
454 #ifdef BUILD_ECORE_EVAS_WAYLAND_SHM
455 void _ecore_evas_wayland_shm_resize(Ecore_Evas *ee, int location);
456 void _ecore_evas_wayland_shm_move(Ecore_Evas *ee, int x, int y);
457 void _ecore_evas_wayland_shm_drag_start(Ecore_Evas *ee, Ecore_Evas *drag_ee, void *source);
458 void _ecore_evas_wayland_shm_pointer_set(Ecore_Evas *ee, int hot_x, int hot_y);
459 void _ecore_evas_wayland_shm_type_set(Ecore_Evas *ee, int type);
460 #endif
461
462 #ifdef BUILD_ECORE_EVAS_WAYLAND_EGL
463 void _ecore_evas_wayland_egl_resize(Ecore_Evas *ee, int location);
464 void _ecore_evas_wayland_egl_move(Ecore_Evas *ee, int x, int y);
465 void _ecore_evas_wayland_egl_drag_start(Ecore_Evas *ee, Ecore_Evas *drag_ee, void *source);
466 void _ecore_evas_wayland_egl_pointer_set(Ecore_Evas *ee, int hot_x, int hot_y);
467 void _ecore_evas_wayland_egl_type_set(Ecore_Evas *ee, int type);
468 #endif
469
470 void _ecore_evas_fps_debug_init(void);
471 void _ecore_evas_fps_debug_shutdown(void);
472 void _ecore_evas_fps_debug_rendertime_add(double t);
473 void _ecore_evas_register(Ecore_Evas *ee);
474 void _ecore_evas_free(Ecore_Evas *ee);
475 void _ecore_evas_idle_timeout_update(Ecore_Evas *ee);
476 void _ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timestamp);
477 void _ecore_evas_mouse_multi_move_process(Ecore_Evas *ee, int device,
478                                           int x, int y,
479                                           double radius,
480                                           double radius_x, double radius_y,
481                                           double pressure,
482                                           double angle,
483                                           double mx, double my,
484                                           unsigned int timestamp);
485 void _ecore_evas_mouse_multi_down_process(Ecore_Evas *ee, int device,
486                                           int x, int y,
487                                           double radius,
488                                           double radius_x, double radius_y,
489                                           double pressure,
490                                           double angle,
491                                           double mx, double my,
492                                           Evas_Button_Flags flags,
493                                           unsigned int timestamp);
494 void _ecore_evas_mouse_multi_up_process(Ecore_Evas *ee, int device,
495                                         int x, int y,
496                                         double radius,
497                                         double radius_x, double radius_y,
498                                         double pressure,
499                                         double angle,
500                                         double mx, double my,
501                                         Evas_Button_Flags flags,
502                                         unsigned int timestamp);
503
504 extern Eina_Bool _ecore_evas_app_comp_sync;
505
506 void _ecore_evas_extn_init(void);
507 void _ecore_evas_extn_shutdown(void);
508
509 #endif