7 #include <e_explicit_sync.h>
8 #include <e_presentation_time.h>
10 #include <e_devicemgr.h>
11 #include <e_util_transform.h>
17 #include <stdatomic.h>
19 #include <tbm_surface.h>
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
30 #include <xkbcommon/xkbcommon.h>
33 #include <linux/input.h>
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
44 #define container_of(ptr, type, member) \
46 const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
47 (type *)( (char *)__mptr - offsetof(type,member) ); \
50 typedef struct _E_Comp_Wl_Hook E_Comp_Wl_Hook;
51 typedef struct _E_Comp_Wl_Pid_Hook E_Comp_Wl_Pid_Hook;
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;
64 typedef enum _E_Comp_Wl_Buffer_Type
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;
74 typedef enum _E_Comp_Wl_Hook_Point
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,
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,
88 } E_Comp_Wl_Hook_Point;
90 typedef enum _E_Comp_Wl_Pid_Hook_Point
92 E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE,
93 E_COMP_WL_PID_HOOK_LAST,
94 } E_Comp_Wl_Pid_Hook_Point;
96 typedef enum _E_Comp_Wl_Sh_Surf_Role
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;
103 typedef enum _E_Comp_Wl_Intercept_Hook_Point
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;
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);
118 struct _E_Comp_Wl_Aux_Hint
127 struct _E_Comp_Wl_Buffer
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;
137 Eina_Stringshare *owner_name;
139 } debug_info; // deprecated
142 int transform; // the value of wl_tbm.set_buffer_transform
145 E_Explicit_Sync_Buffer_Release *buffer_release;
148 struct _E_Comp_Wl_Buffer_Viewport {
151 uint32_t transform; /* wl_surface.set_buffer_transform */
152 int32_t scale; /* wl_surface.set_scaling_factor */
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;
161 /* If width == -1, the size is inferred from the buffer. */
162 int32_t width, height;
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.
171 uint32_t wait_for_transform_change;
174 struct _E_Comp_Wl_Surface_State
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;
186 E_Presentation_Time_Container presentation_container;
189 struct _E_Comp_Wl_Subsurf_Data
191 struct wl_resource *resource;
201 E_Comp_Wl_Surface_State cached;
202 E_Comp_Wl_Buffer_Ref cached_buffer_ref;
204 Eina_Bool synchronized;
205 Eina_Bool stand_alone;
209 E_Client *offscreen_parent;
213 struct _E_Comp_Wl_Data
217 struct wl_display *disp;
218 struct wl_event_loop *loop;
223 Eina_List *resources;
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;
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 */
247 Eina_List *resources;
249 wl_fixed_t grab_x, grab_y;
251 Ecore_Timer *hide_tmr;
253 Eina_Bool enabled : 1;
254 unsigned int num_devices;
259 Eina_List *resources;
260 Eina_List *manager_resources;
262 Eina_Bool activated : 1;
263 struct wl_global *global;
268 Eina_List *resources;
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;
280 Eina_List *resources;
281 Eina_Bool enabled : 1;
282 unsigned int num_devices;
283 unsigned int pressed;
289 struct wl_global *global;
290 Eina_List *resources;
296 struct wl_global *global;
297 struct wl_resource *resource;
303 struct wl_global *global;
304 struct wl_resource *resource;
305 Eina_Hash *data_resources;
312 struct wl_signal signal;
313 struct wl_listener data_source_listener;
316 struct wl_resource *cbhm;
317 Eina_List *secondary_list;
318 Eina_List *data_only_list;
319 struct wl_resource *secondary_sent;
325 struct wl_listener listener;
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;
343 struct wl_resource *resource;
349 struct xkb_keymap *keymap;
350 struct xkb_context *context;
351 struct xkb_state *state;
357 } xkb; /* FIXME: will be deprecated after migration */
363 } available_hw_accel;
372 struct wl_global *global;
373 struct wl_client *client;
378 struct wl_global *global;
383 struct wl_global *global;
388 Ecore_Fd_Handler *fd_hdlr;
391 struct wl_client *xwl_client;
392 Eina_List *xwl_pending;
395 E_Client *drag_client;
398 int drag_device_id; // Ecore_Event_Mouse_Move.multi.device
400 E_Comp_Wl_Evas_Gl *evas_gl;
402 double idle_exiter_timestamp;
403 Ecore_Idle_Exiter *idle_exiter;
406 struct _E_Comp_Wl_Client_Data
408 struct wl_resource *wl_surface;
410 Ecore_Timer *on_focus_timer;
414 E_Comp_Wl_Subsurf_Data *data;
417 Eina_List *list_pending;
418 Eina_Bool list_changed : 1;
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;
427 Eina_Bool restacking : 1;
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;
437 /* shell surface resource */
438 struct wl_resource *surface;
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;
448 E_Comp_Wl_Buffer_Ref buffer_ref;
449 E_Comp_Wl_Surface_State pending;
452 E_Presentation_Time_Container presentation_container;
461 struct wl_resource *viewport;
462 E_Comp_Wl_Buffer_Viewport buffer_viewport;
467 Eina_Bool enabled : 1;
470 unsigned int scount, stime;
472 int prev_degree, cur_degree;
477 Eina_Bool changed : 1;
479 Eina_Bool use_msg : 1;
482 /* before applying viewport */
483 int width_from_buffer;
484 int height_from_buffer;
486 /* after applying viewport */
487 int width_from_viewport;
488 int height_from_viewport;
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;
514 unsigned char win_type : 1;
515 unsigned char layer : 1;
518 E_Devicemgr_Input_Device *last_device_ptr;
519 E_Devicemgr_Input_Device *last_device_touch;
520 E_Devicemgr_Input_Device *last_device_kbd;
522 E_Util_Transform *viewport_transform;
526 E_Client *onscreen_parent;
527 Eina_List *regions; //list of onscreen region (Eina_Rectangle *)
530 /* xdg shell v6 resource: it should be moved to member of struct shell */
533 E_Comp_Wl_Sh_Surf_Role role;
534 struct wl_resource *res_role; /* zxdg_toplevel_v6 or zxdg_popup_v6 */
537 const char *role_name;
539 Eina_Bool wtz_surface_assigned;
540 struct wl_list pointer_constraints;
541 GMutex surface_mutex;
543 struct wl_signal state_commit_signal;
546 struct _E_Comp_Wl_Output
548 struct wl_global *global;
549 Eina_List *resources;
550 const char *id, *make, *model;
552 int phys_width, phys_height;
553 unsigned int refresh;
554 unsigned int subpixel;
555 unsigned int transform;
558 /* added for screenshot ability */
559 struct wl_output *wl_output;
560 struct wl_buffer *buffer;
564 struct _E_Comp_Wl_Hook
567 E_Comp_Wl_Hook_Point hookpoint;
568 E_Comp_Wl_Hook_Cb func;
570 unsigned char delete_me : 1;
573 struct _E_Comp_Wl_Pid_Hook
576 E_Comp_Wl_Pid_Hook_Point hookpoint;
577 E_Comp_Wl_Pid_Hook_Cb func;
579 unsigned char delete_me : 1;
582 struct _E_Comp_Wl_Intercept_Hook
585 E_Comp_Wl_Intercept_Hook_Point hookpoint;
586 E_Comp_Wl_Intercept_Hook_Cb func;
588 unsigned char delete_me : 1;
591 struct _E_Comp_Wl_Seat
593 Eina_Bool is_first_resource : 1;
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);
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);