[3.0] Add key grab/ungrab interfaces for Tizen (X11/Wayland)
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / ecore_wl_private.h
1 #ifndef _ECORE_WAYLAND_PRIVATE_H
2 # define _ECORE_WAYLAND_PRIVATE_H
3
4 # include <limits.h>
5 # include <unistd.h>
6
7 # include "Ecore.h"
8 # include "Ecore_Input.h"
9 # include "Ecore_Wayland.h"
10 # ifdef USE_IVI_SHELL
11 # include "ivi-application-client-protocol.h"
12 # define IVI_SURFACE_ID 6000
13 # endif
14
15 # include "tizen-policy-client-protocol.h"
16 # include "tizen-extension-client-protocol.h"
17
18 # include "keyrouter-client-protocol.h"
19
20 //# define LOGFNS 1
21
22 # ifdef LOGFNS
23 #  include <stdio.h>
24 #  define LOGFN(fl, ln, fn) printf("-ECORE-WL: %25s: %5i - %s\n", fl, ln, fn);
25 # else
26 #  define LOGFN(fl, ln, fn)
27 # endif
28
29 extern int _ecore_wl_log_dom;
30
31 # ifdef ECORE_WL_DEFAULT_LOG_COLOR
32 #  undef ECORE_WL_DEFAULT_LOG_COLOR
33 # endif
34 # define ECORE_WL_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
35
36 # ifdef ERR
37 #  undef ERR
38 # endif
39 # define ERR(...) EINA_LOG_DOM_ERR(_ecore_wl_log_dom, __VA_ARGS__)
40
41 # ifdef DBG
42 #  undef DBG
43 # endif
44 # define DBG(...) EINA_LOG_DOM_DBG(_ecore_wl_log_dom, __VA_ARGS__)
45
46 # ifdef INF
47 #  undef INF
48 # endif
49 # define INF(...) EINA_LOG_DOM_INFO(_ecore_wl_log_dom, __VA_ARGS__)
50
51 # ifdef WRN
52 #  undef WRN
53 # endif
54 # define WRN(...) EINA_LOG_DOM_WARN(_ecore_wl_log_dom, __VA_ARGS__)
55
56 # ifdef CRI
57 #  undef CRI
58 # endif
59 # define CRI(...) EINA_LOG_DOM_CRIT(_ecore_wl_log_dom, __VA_ARGS__)
60
61 # ifdef ECORE_WL_DEFAULT_CURSOR_SIZE
62 #  undef ECORE_WL_DEFAULT_CURSOR_SIZE
63 # endif
64 # define ECORE_WL_DEFAULT_CURSOR_SIZE 32
65
66 typedef struct _Ecore_Wl_Display Ecore_Wl_Display;
67
68 struct _Ecore_Wl_Display
69 {
70    struct
71      {
72         struct wl_display *display;
73         struct wl_registry *registry;
74         struct wl_compositor *compositor;
75         struct wl_subcompositor *subcompositor;
76         struct wl_shell *shell;
77         struct xdg_shell *xdg_shell;
78         struct wl_shell *desktop_shell;
79 # ifdef USE_IVI_SHELL
80         struct ivi_application *ivi_application;
81 # endif
82         struct wl_shm *shm;
83         struct wl_data_device_manager *data_device_manager;
84         struct tizen_policy *tz_policy;
85         struct tizen_surface_extension *tz_surf_ext;
86         struct wl_keyrouter *keyrouter;
87      } wl;
88
89    int fd;
90    unsigned int mask;
91    unsigned int serial;
92    int sync_ref_count;
93    Ecore_Fd_Handler *fd_hdl;
94    Ecore_Idle_Enterer *idle_enterer;
95
96    Eina_Inlist *inputs;
97    Eina_Inlist *outputs;
98    Eina_Inlist *globals; /** @since 1.7.6 */
99
100    Eina_Bool init_done;
101
102    struct
103      {
104         struct xkb_context *context;
105      } xkb;
106
107    struct wl_cursor_theme *cursor_theme;
108
109    Ecore_Wl_Output *output;
110    Ecore_Wl_Input *input;
111
112    void (*output_configure)(Ecore_Wl_Output *output, void *data);
113    void *data;
114 };
115
116 struct _Ecore_Wl_Window
117 {
118    Ecore_Wl_Display *display;
119    Ecore_Wl_Window *parent;
120
121    struct wl_surface *surface;
122    struct wl_shell_surface *shell_surface;
123 # ifdef USE_IVI_SHELL
124    struct ivi_surface *ivi_surface;
125    int ivi_surface_id;
126 # endif
127    struct tizen_visibility *tz_visibility;
128    struct tizen_resource *tz_resource;
129    unsigned int resource_id;
130
131    struct wl_region *opaque_region;
132    struct wl_region *input_region;
133
134    struct xdg_surface *xdg_surface;
135    struct xdg_popup *xdg_popup;
136    Eina_Bool visible : 1;
137    Eina_Bool focused : 1;
138    Eina_Bool resizing : 1;
139
140    Eina_Bool fullscreen : 1;
141    Eina_Bool maximized : 1;
142    Eina_Bool minimized : 1;
143
144    struct
145      {
146         struct wl_surface *surface;
147         int hot_x, hot_y;
148         Eina_Bool set : 1;
149      } pointer;
150
151    int id, surface_id;
152    int rotation;
153
154    const char *title;
155    const char *class_name;
156
157    Eina_Rectangle allocation;
158
159    struct
160      {
161         int w, h;
162      } saved;
163
164    struct
165      {
166         int x, y, w, h;
167      } opaque, input;
168
169    /* Eina_Bool redraw_scheduled : 1; */
170    /* Eina_Bool resize_scheduled : 1; */
171    Eina_Bool alpha : 1;
172    Eina_Bool transparent : 1;
173    Eina_Bool has_buffer : 1;
174
175    Ecore_Wl_Window_Type type;
176    Ecore_Wl_Window_Buffer_Type buffer_type;
177
178    Ecore_Wl_Input *pointer_device;
179    Ecore_Wl_Input *keyboard_device;
180
181    Eina_Bool anim_pending : 1;
182    struct wl_callback *anim_callback;
183
184    const char *cursor_name;
185
186    Ecore_Wl_Subsurf *subsurfs;
187
188    void *data;
189 };
190
191 struct _Ecore_Wl_Input
192 {
193    EINA_INLIST;
194    Ecore_Wl_Display *display;
195    struct wl_seat *seat;
196    struct wl_pointer *pointer;
197    struct wl_keyboard *keyboard;
198
199    struct wl_touch *touch;
200
201    const char *cursor_name;
202    struct wl_cursor *cursor;
203    struct wl_surface *cursor_surface;
204    struct wl_callback *cursor_frame_cb;
205    Ecore_Timer *cursor_timer;
206    unsigned int cursor_current_index;
207    unsigned int cursor_size;
208    const char *cursor_theme_name;
209
210    struct wl_data_device *data_device;
211    struct wl_data_source *data_source;
212    struct wl_array data_types;
213
214    Ecore_Wl_Window *pointer_focus;
215    Ecore_Wl_Window *keyboard_focus;
216    Ecore_Wl_Window *touch_focus;
217
218    unsigned int button;
219    unsigned int timestamp;
220    unsigned int modifiers;
221    unsigned int pointer_enter_serial;
222    int sx, sy;
223
224    Ecore_Wl_Window *grab;
225    unsigned int grab_button;
226    unsigned int grab_timestamp;
227    unsigned int grab_count;
228
229    Ecore_Wl_Dnd_Source *drag_source;
230    Ecore_Wl_Dnd_Source *selection_source;
231
232    struct
233      {
234         struct xkb_keymap *keymap;
235         struct xkb_state *state;
236         xkb_mod_mask_t control_mask;
237         xkb_mod_mask_t alt_mask;
238         xkb_mod_mask_t shift_mask;
239         xkb_mod_mask_t win_mask;
240         xkb_mod_mask_t scroll_mask;
241         xkb_mod_mask_t num_mask;
242         xkb_mod_mask_t caps_mask;
243         xkb_mod_mask_t altgr_mask;
244         unsigned int mods_depressed;
245         unsigned int mods_latched;
246         unsigned int mods_locked;
247         unsigned int mods_group;
248      } xkb;
249
250    struct
251      {
252         Ecore_Timer *tmr;
253         unsigned int sym, key, time;
254      } repeat;
255 };
256
257 struct _Ecore_Wl_Output
258 {
259    EINA_INLIST;
260    Ecore_Wl_Display *display;
261    struct wl_output *output;
262    Eina_Rectangle allocation;
263    int mw, mh;
264    int transform;
265
266    void (*destroy) (Ecore_Wl_Output *output, void *data);
267    void *data;
268 };
269
270 struct _Ecore_Wl_Dnd
271 {
272    Ecore_Wl_Display *ewd;
273    Ecore_Wl_Input *input;
274 };
275
276 struct _Ecore_Wl_Dnd_Source
277 {
278    Ecore_Wl_Input *input;
279
280    struct wl_data_offer *data_offer;
281    struct wl_array types;
282
283    int refcount;
284    int fd;
285    int x, y;
286 };
287
288 struct _Ecore_Wl_Dnd_Target
289 {
290    Ecore_Wl_Dnd_Source *source;
291 };
292
293 extern Ecore_Wl_Display *_ecore_wl_disp;
294
295 void _ecore_wl_window_init(void);
296 void _ecore_wl_window_shutdown(void);
297 Eina_Hash *_ecore_wl_window_hash_get(void);
298
299 void _ecore_wl_output_add(Ecore_Wl_Display *ewd, unsigned int id);
300 void _ecore_wl_output_del(Ecore_Wl_Output *output);
301
302 void _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id);
303 void _ecore_wl_input_del(Ecore_Wl_Input *input);
304 void _ecore_wl_input_pointer_xy_get(int *x, int *y);
305 void _ecore_wl_input_grab_release(Ecore_Wl_Input *input, Ecore_Wl_Window *win);
306
307 void _ecore_wl_dnd_add(Ecore_Wl_Input *input, struct wl_data_device *data_device, struct wl_data_offer *offer);
308 void _ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer);
309 void _ecore_wl_dnd_leave(void *data, struct wl_data_device *data_device);
310 void _ecore_wl_dnd_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, int x, int y);
311 void _ecore_wl_dnd_drop(void *data, struct wl_data_device *data_device);
312 void _ecore_wl_dnd_selection(void *data, struct wl_data_device *data_device, struct wl_data_offer *offer);
313 void _ecore_wl_dnd_del(Ecore_Wl_Dnd_Source *source);
314
315 void _ecore_wl_events_init(void);
316 void _ecore_wl_events_shutdown(void);
317
318 void _ecore_wl_subsurfs_del_all(Ecore_Wl_Window *win);
319
320 struct wl_compositor *_ecore_wl_compositor_get(void);
321 struct wl_subcompositor *_ecore_wl_subcompositor_get(void);
322
323 #endif