e_input: Fix build error due to deprecate
[platform/upstream/enlightenment.git] / src / include / e_comp_wl.h
1 #ifndef E_COMP_WL_H
2 #define E_COMP_WL_H
3
4 #include <e_types.h>
5 #include <e_comp.h>
6 #include <e_client.h>
7 #include <e_explicit_sync.h>
8 #include <e_presentation_time.h>
9 #include <e_dnd.h>
10 #include <e_devicemgr.h>
11 #include <e_util_transform.h>
12
13 #ifdef __cplusplus
14 #include <atomic>
15 using namespace std;
16 #else
17 #include <stdatomic.h>
18 #endif
19 #include <tbm_surface.h>
20 #include <glib.h>
21 #include <Evas.h>
22
23 /* NB: Turn off shadow warnings for Wayland includes */
24 #pragma GCC diagnostic push
25 #pragma GCC diagnostic ignored "-Wshadow"
26 #define WL_HIDE_DEPRECATED
27 #include <wayland-server.h>
28 #pragma GCC diagnostic pop
29
30 #include <xkbcommon/xkbcommon.h>
31
32 #ifdef __linux__
33 #include <linux/input.h>
34 #else
35 #define BTN_LEFT 0x110
36 #define BTN_RIGHT 0x111
37 #define BTN_MIDDLE 0x112
38 #define BTN_SIDE 0x113
39 #define BTN_EXTRA 0x114
40 #define BTN_FORWARD 0x115
41 #define BTN_BACK 0x116
42 #endif
43
44 #define container_of(ptr, type, member) \
45    ({ \
46       const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
47       (type *)( (char *)__mptr - offsetof(type,member) ); \
48    })
49
50 typedef struct _E_Comp_Wl_Hook E_Comp_Wl_Hook;
51 typedef struct _E_Comp_Wl_Pid_Hook E_Comp_Wl_Pid_Hook;
52
53 typedef struct _E_Comp_Wl_Aux_Hint  E_Comp_Wl_Aux_Hint;
54 typedef struct _E_Comp_Wl_Buffer_Viewport E_Comp_Wl_Buffer_Viewport;
55 typedef struct _E_Comp_Wl_Subsurf_Data E_Comp_Wl_Subsurf_Data;
56 typedef struct _E_Comp_Wl_Surface_State E_Comp_Wl_Surface_State;
57 typedef struct _E_Comp_Wl_Data E_Comp_Wl_Data;
58 typedef struct _E_Comp_Wl_Output E_Comp_Wl_Output;
59 typedef struct _E_Comp_Wl_Intercept_Hook E_Comp_Wl_Intercept_Hook;
60 typedef struct _E_Comp_Wl_Evas_Gl E_Comp_Wl_Evas_Gl;
61 typedef struct _E_Comp_Wl_Seat E_Comp_Wl_Seat;
62 typedef struct _E_Comp_Wl_Pointer_Constraint E_Comp_Wl_Pointer_Constraint;
63
64 typedef enum _E_Comp_Wl_Buffer_Type
65 {
66    E_COMP_WL_BUFFER_TYPE_NONE = 0,
67    E_COMP_WL_BUFFER_TYPE_SHM = 1,
68    E_COMP_WL_BUFFER_TYPE_NATIVE = 2,
69    E_COMP_WL_BUFFER_TYPE_VIDEO = 3,
70    E_COMP_WL_BUFFER_TYPE_TBM = 4,
71    E_COMP_WL_BUFFER_TYPE_SINGLE_PIXEL = 5,
72 } E_Comp_Wl_Buffer_Type;
73
74 typedef enum _E_Comp_Wl_Hook_Point
75 {
76    E_COMP_WL_HOOK_SHELL_SURFACE_READY,
77    E_COMP_WL_HOOK_SUBSURFACE_CREATE,
78    E_COMP_WL_HOOK_SUBSURFACE_COMMIT_TO_CACHE,
79    E_COMP_WL_HOOK_SUBSURFACE_SYNCHRONIZED_COMMIT,
80    E_COMP_WL_HOOK_BUFFER_CHANGE,
81    E_COMP_WL_HOOK_CLIENT_REUSE,
82    E_COMP_WL_HOOK_BUFFER_SIZE_CHANGE,
83    E_COMP_WL_HOOK_DEL,
84    E_COMP_WL_HOOK_CLIENT_ALPHA_CHANGE,
85    E_COMP_WL_HOOK_CLIENT_SURFACE_COMMIT,
86    E_COMP_WL_HOOK_CLIENT_BEFORE_SURFACE_COMMIT,
87    E_COMP_WL_HOOK_LAST,
88 } E_Comp_Wl_Hook_Point;
89
90 typedef enum _E_Comp_Wl_Pid_Hook_Point
91 {
92    E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE,
93    E_COMP_WL_PID_HOOK_LAST,
94 } E_Comp_Wl_Pid_Hook_Point;
95
96 typedef enum _E_Comp_Wl_Sh_Surf_Role
97 {
98    E_COMP_WL_SH_SURF_ROLE_NONE = 0,
99    E_COMP_WL_SH_SURF_ROLE_TOPLV = 1,
100    E_COMP_WL_SH_SURF_ROLE_POPUP = 2,
101 } E_Comp_Wl_Sh_Surf_Role;
102
103 typedef enum _E_Comp_Wl_Intercept_Hook_Point
104 {
105    E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_IN,
106    E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_OUT,
107    E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_MOVE,
108    E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_WHEEL,
109    E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_DOWN,
110    E_COMP_WL_INTERCEPT_HOOK_CURSOR_TIMER_MOUSE_UP,
111    E_COMP_WL_INTERCEPT_HOOK_LAST,
112 } E_Comp_Wl_Intercept_Hook_Point;
113
114 typedef void (*E_Comp_Wl_Hook_Cb) (void *data, E_Client *ec);
115 typedef void (*E_Comp_Wl_Pid_Hook_Cb) (void *data, pid_t pid);
116 typedef Eina_Bool (*E_Comp_Wl_Intercept_Hook_Cb) (void *data, E_Client *ec);
117
118 struct _E_Comp_Wl_Aux_Hint
119 {
120    int           id;
121    const char   *hint;
122    const char   *val;
123    Eina_Bool     changed;
124    Eina_Bool     deleted;
125 };
126
127 struct _E_Comp_Wl_Buffer
128 {
129    E_Comp_Wl_Buffer_Type type;
130    struct wl_resource *resource;
131    struct wl_signal destroy_signal;
132    struct wl_listener destroy_listener;
133    struct wl_shm_buffer *shm_buffer;
134    tbm_surface_h tbm_surface;
135    struct
136    {
137       Eina_Stringshare *owner_name;
138       void *owner_ptr;
139    } debug_info; // deprecated
140    int32_t w, h;
141    int format;
142    int transform; // the value of wl_tbm.set_buffer_transform
143    uint32_t busy;
144
145    E_Explicit_Sync_Buffer_Release *buffer_release;
146 };
147
148 struct _E_Comp_Wl_Buffer_Viewport {
149    struct
150      {
151         uint32_t transform;   /* wl_surface.set_buffer_transform */
152         int32_t scale;        /* wl_surface.set_scaling_factor */
153
154         /* If src_width != wl_fixed_from_int(-1), then and only then src_* are used. */
155         wl_fixed_t src_x, src_y;
156         wl_fixed_t src_width, src_height;
157      } buffer;
158
159    struct
160      {
161         /* If width == -1, the size is inferred from the buffer. */
162         int32_t width, height;
163      } surface;
164
165    int changed;
166
167    /* When screen or window is rotated, a transformed buffer could be
168     * attached after attaching a few buffers. So to detect when the transformed
169     * buffer exactly, we need to know the status of waiting the transformed buffer.
170     */
171    uint32_t wait_for_transform_change;
172 };
173
174 struct _E_Comp_Wl_Surface_State
175 {
176    int sx, sy;
177    int bw, bh;
178    E_Comp_Wl_Buffer *buffer;
179    struct wl_listener buffer_destroy_listener;
180    Eina_List *damages, *buffer_damages, *frames;
181    Eina_Tiler *input, *opaque;
182    E_Comp_Wl_Buffer_Viewport buffer_viewport;
183    Eina_Bool new_attach : 1;
184    Eina_Bool has_data : 1;
185
186    E_Presentation_Time_Container presentation_container;
187 };
188
189 struct _E_Comp_Wl_Subsurf_Data
190 {
191    struct wl_resource *resource;
192
193    E_Client *parent;
194
195    struct
196      {
197         int x, y;
198         Eina_Bool set;
199      } position;
200
201    E_Comp_Wl_Surface_State cached;
202    E_Comp_Wl_Buffer_Ref cached_buffer_ref;
203
204    Eina_Bool synchronized;
205    Eina_Bool stand_alone;
206
207    struct
208      {
209         E_Client *offscreen_parent;
210      } remote_surface;
211 };
212
213 struct _E_Comp_Wl_Data
214 {
215    struct
216      {
217         struct wl_display *disp;
218         struct wl_event_loop *loop;
219      } wl;
220
221    struct
222      {
223         Eina_List *resources;
224         Eina_List *focused;
225         Eina_Bool enabled : 1;
226         xkb_mod_index_t mod_shift, mod_caps;
227         xkb_mod_index_t mod_ctrl, mod_alt;
228         xkb_mod_index_t mod_super;
229         xkb_mod_mask_t mod_depressed, mod_latched, mod_locked;
230         xkb_layout_index_t mod_group;
231         struct wl_array keys;
232         struct wl_array routed_keys;
233         struct wl_resource *focus;
234         int mod_changed;
235         atomic_int repeat_delay;
236         atomic_int repeat_rate;
237         unsigned int num_devices;
238         GMutex resource_mutex; /* for resources variable */
239         GMutex focused_mutex; /* for focused variable */
240         GMutex keys_mutex; /* for keys variable */
241         GMutex repeat_delay_mutex; /* for repeat_delay variable */
242         GMutex repeat_rate_mutex; /* for repeat_rate variable */
243      } kbd;
244
245    struct
246      {
247         Eina_List *resources;
248         wl_fixed_t x, y;
249         wl_fixed_t grab_x, grab_y;
250         uint32_t button;
251         Ecore_Timer *hide_tmr;
252         E_Client *ec;
253         Eina_Bool enabled : 1;
254         unsigned int num_devices;
255      } ptr;
256
257    struct
258      {
259         Eina_List *resources;
260         Eina_List *manager_resources;
261         E_Client *ec;
262         Eina_Bool activated : 1;
263         struct wl_global *global;
264      } relative_ptr;
265
266    struct
267      {
268         Eina_List *resources;
269         E_Client *ec;
270         Eina_Bool activated : 1;
271         struct wl_signal pointer_destroy_signal;
272         struct wl_signal surface_unmap_signal;
273         struct wl_signal surface_commit_signal;
274         struct wl_signal surface_mousein_signal;
275         struct wl_global *global;
276      } ptr_constraints;
277
278    struct
279      {
280         Eina_List *resources;
281         Eina_Bool enabled : 1;
282         unsigned int num_devices;
283         unsigned int pressed;
284         E_Client *faked_ec;
285      } touch;
286
287    struct
288      {
289         struct wl_global *global;
290         Eina_List *resources;
291         uint32_t version;
292         char *name;
293
294         struct
295           {
296              struct wl_global *global;
297              struct wl_resource *resource;
298           } im;
299      } seat;
300
301    struct
302      {
303         struct wl_global *global;
304         struct wl_resource *resource;
305         Eina_Hash *data_resources;
306      } mgr;
307
308    struct
309      {
310         void *data_source;
311         uint32_t serial;
312         struct wl_signal signal;
313         struct wl_listener data_source_listener;
314         E_Client *target;
315
316         struct wl_resource *cbhm;
317         Eina_List *secondary_list;
318         Eina_List *data_only_list;
319         struct wl_resource *secondary_sent;
320      } selection;
321
322    struct
323      {
324         void *source;
325         struct wl_listener listener;
326         E_Client *xwl_owner;
327      } clipboard;
328
329    struct
330      {
331         void *data_source;
332         E_Client *icon;
333         uint32_t serial;
334         struct wl_signal signal;
335         struct wl_listener data_source_listener;
336         struct wl_client *client;
337         struct wl_resource *focus;
338         Eina_Bool enabled : 1;
339      } dnd;
340
341    struct
342      {
343         struct wl_resource *resource;
344         uint32_t edges;
345      } resize;
346
347    struct
348      {
349         struct xkb_keymap *keymap;
350         struct xkb_context *context;
351         struct xkb_state *state;
352         int fd;
353         size_t size;
354         char *area;
355         GMutex keymap_mutex;
356         GMutex state_mutex;
357      } xkb; /* FIXME: will be deprecated after migration */
358
359    struct
360      {
361         Eina_Bool underlay;
362         Eina_Bool scaler;
363      } available_hw_accel;
364
365    struct
366      {
367         void *server;
368      } tbm;
369
370    struct
371      {
372         struct wl_global *global;
373         struct wl_client *client;
374      } screenshooter;
375
376    struct
377      {
378         struct wl_global *global;
379      } video;
380
381    struct
382      {
383         struct wl_global *global;
384      } tizen_hwc;
385
386    Eina_List *outputs;
387
388    Ecore_Fd_Handler *fd_hdlr;
389    Ecore_Idler *idler;
390
391    struct wl_client *xwl_client;
392    Eina_List *xwl_pending;
393
394    E_Drag *drag;
395    E_Client *drag_client;
396    void *drag_source;
397    void *drag_offer;
398    int drag_device_id; // Ecore_Event_Mouse_Move.multi.device
399
400    E_Comp_Wl_Evas_Gl *evas_gl;
401
402    double idle_exiter_timestamp;
403    Ecore_Idle_Exiter *idle_exiter;
404 };
405
406 struct _E_Comp_Wl_Client_Data
407 {
408    struct wl_resource *wl_surface;
409
410    Ecore_Timer *on_focus_timer;
411
412    struct
413      {
414         E_Comp_Wl_Subsurf_Data *data;
415
416         Eina_List *list;
417         Eina_List *list_pending;
418         Eina_Bool list_changed : 1;
419
420         Eina_List *below_list;
421         Eina_List *below_list_pending;
422         Evas_Object *below_obj;
423         E_Map *below_obj_map;
424         E_Client_Hook *below_obj_map_transform_hook;
425         E_Comp_Wl_Hook *comp_wl_del_hook;
426
427         Eina_Bool restacking : 1;
428      } sub;
429
430    /* regular surface resource (wl_compositor_create_surface) */
431    struct wl_resource *surface;
432    struct wl_signal destroy_signal;
433    struct wl_signal apply_viewport_signal;
434
435    struct
436      {
437         /* shell surface resource */
438         struct wl_resource *surface;
439
440         void (*configure_send)(struct wl_resource *resource, uint32_t edges, int32_t width, int32_t height);
441         void (*configure)(struct wl_resource *resource, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
442         void (*ping)(struct wl_resource *resource);
443         void (*map)(struct wl_resource *resource);
444         void (*unmap)(struct wl_resource *resource);
445         Eina_Rectangle window;
446      } shell;
447
448    E_Comp_Wl_Buffer_Ref buffer_ref;
449    E_Comp_Wl_Surface_State pending;
450
451    Eina_List *frames;
452    E_Presentation_Time_Container presentation_container;
453
454    struct
455      {
456         int32_t x, y;
457      } popup;
458
459    struct
460      {
461         struct wl_resource *viewport;
462         E_Comp_Wl_Buffer_Viewport buffer_viewport;
463      } scaler;
464
465    struct
466      {
467         Eina_Bool enabled : 1;
468         Eina_Bool start : 1;
469
470         unsigned int scount, stime;
471         int sx, sy, dx, dy;
472         int prev_degree, cur_degree;
473      } transform;
474
475    struct
476      {
477         Eina_Bool  changed : 1;
478         Eina_List *hints;
479         Eina_Bool  use_msg : 1;
480      } aux_hint;
481
482    /* before applying viewport */
483    int width_from_buffer;
484    int height_from_buffer;
485
486    /* after applying viewport */
487    int width_from_viewport;
488    int height_from_viewport;
489
490    Eina_Bool keep_buffer : 1;
491    Eina_Bool mapped : 1;
492    Eina_Bool has_extern_parent : 1;
493    Eina_Bool change_icon : 1;
494    Eina_Bool need_reparent : 1;
495    Eina_Bool reparented : 1;
496    Eina_Bool evas_init : 1;
497    Eina_Bool first_damage : 1;
498    Eina_Bool set_win_type : 1;
499    Eina_Bool frame_update : 1;
500    Eina_Bool maximize_pre : 1;
501    Eina_Bool focus_update : 1;
502    Eina_Bool opaque_state : 1;
503    Eina_Bool video_client : 1; // Deprecated
504    Eina_Bool has_video_client : 1;
505    Eina_Bool never_hwc : 1;          //  force window not to do hwc
506    Eina_Bool first_commit : 1;       // TRUE : once client committed
507    unsigned char accepts_focus : 1;
508    unsigned char conformant : 1;
509    E_Window_Type win_type;
510    E_Layer layer;
511
512    struct
513    {
514       unsigned char win_type : 1;
515       unsigned char layer : 1;
516    } fetch;
517
518    E_Devicemgr_Input_Device *last_device_ptr;
519    E_Devicemgr_Input_Device *last_device_touch;
520    E_Devicemgr_Input_Device *last_device_kbd;
521
522    E_Util_Transform *viewport_transform;
523
524    struct
525      {
526         E_Client *onscreen_parent;
527         Eina_List *regions;  //list of onscreen region (Eina_Rectangle *)
528      } remote_surface;
529
530    /* xdg shell v6 resource: it should be moved to member of struct shell */
531    struct
532      {
533         E_Comp_Wl_Sh_Surf_Role role;
534         struct wl_resource *res_role; /* zxdg_toplevel_v6 or zxdg_popup_v6 */
535      } sh_v6;
536
537    const char *role_name;
538
539    Eina_Bool wtz_surface_assigned;
540    struct wl_list pointer_constraints;
541    GMutex surface_mutex;
542
543    struct wl_signal state_commit_signal;
544 };
545
546 struct _E_Comp_Wl_Output
547 {
548    struct wl_global *global;
549    Eina_List *resources;
550    const char *id, *make, *model;
551    int x, y, w, h;
552    int phys_width, phys_height;
553    unsigned int refresh;
554    unsigned int subpixel;
555    unsigned int transform;
556    double scale;
557
558    /* added for screenshot ability */
559    struct wl_output *wl_output;
560    struct wl_buffer *buffer;
561    void *data;
562 };
563
564 struct _E_Comp_Wl_Hook
565 {
566    EINA_INLIST;
567    E_Comp_Wl_Hook_Point hookpoint;
568    E_Comp_Wl_Hook_Cb func;
569    void *data;
570    unsigned char delete_me : 1;
571 };
572
573 struct _E_Comp_Wl_Pid_Hook
574 {
575    EINA_INLIST;
576    E_Comp_Wl_Pid_Hook_Point hookpoint;
577    E_Comp_Wl_Pid_Hook_Cb func;
578    void *data;
579    unsigned char delete_me : 1;
580 };
581
582 struct _E_Comp_Wl_Intercept_Hook
583 {
584    EINA_INLIST;
585    E_Comp_Wl_Intercept_Hook_Point hookpoint;
586    E_Comp_Wl_Intercept_Hook_Cb func;
587    void *data;
588    unsigned char delete_me : 1;
589 };
590
591 struct _E_Comp_Wl_Seat
592 {
593    Eina_Bool is_first_resource : 1;
594 };
595
596 E_API void                      e_comp_wl_buffer_reference(E_Comp_Wl_Buffer_Ref *ref, E_Comp_Wl_Buffer *buffer);
597 E_API void                      e_comp_wl_touch_cancel(void);
598 E_API E_Client                 *e_comp_wl_topmost_parent_get(E_Client *ec);
599 E_API enum wl_output_transform  e_comp_wl_output_buffer_transform_get(E_Client *ec);
600 E_API void                      e_comp_wl_map_size_cal_from_buffer(E_Client *ec);
601 E_API void                      e_comp_wl_map_size_cal_from_viewport(E_Client *ec);
602 E_API void                      e_comp_wl_map_apply(E_Client *ec);
603 E_API void                      e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled);
604
605 E_API E_Comp_Wl_Hook           *e_comp_wl_hook_add(E_Comp_Wl_Hook_Point hookpoint, E_Comp_Wl_Hook_Cb func, const void *data);
606 E_API void                      e_comp_wl_hook_del(E_Comp_Wl_Hook *ch);
607 E_API E_Comp_Wl_Pid_Hook       *e_comp_wl_pid_hook_add(E_Comp_Wl_Pid_Hook_Point hookpoint, E_Comp_Wl_Pid_Hook_Cb func, const void *data);
608 E_API void                      e_comp_wl_pid_hook_del(E_Comp_Wl_Pid_Hook *ch);
609 E_API E_Comp_Wl_Intercept_Hook *e_comp_wl_intercept_hook_add(E_Comp_Wl_Intercept_Hook_Point hookpoint, E_Comp_Wl_Intercept_Hook_Cb func, const void *data);
610 E_API void                      e_comp_wl_intercept_hook_del(E_Comp_Wl_Intercept_Hook *ch);
611
612 #endif