1 #ifndef _ECORE_WAYLAND_H_
2 # define _ECORE_WAYLAND_H_
5 * Wayland supoprt is considered experimental as wayland itself is still
6 * unstable and liable to change core protocol. If you use this api, it is
7 * possible it will break in future, until this notice is removed.
11 # include <wayland-client.h>
12 # include <wayland-cursor.h>
13 # include <xkbcommon/xkbcommon.h>
21 # define EAPI __attribute__ ((visibility("default")))
29 typedef enum _Ecore_Wl_Window_Type Ecore_Wl_Window_Type;
30 typedef enum _Ecore_Wl_Window_Buffer_Type Ecore_Wl_Window_Buffer_Type;
32 typedef struct _Ecore_Wl_Display Ecore_Wl_Display;
33 typedef struct _Ecore_Wl_Output Ecore_Wl_Output;
34 typedef struct _Ecore_Wl_Input Ecore_Wl_Input;
35 # ifndef _ECORE_WAYLAND_WINDOW_PREDEF
36 typedef struct _Ecore_Wl_Window Ecore_Wl_Window;
38 typedef struct _Ecore_Wl_Dnd Ecore_Wl_Dnd; /** @since 1.7 */
39 typedef struct _Ecore_Wl_Dnd_Source Ecore_Wl_Dnd_Source;
40 typedef struct _Ecore_Wl_Dnd_Target Ecore_Wl_Dnd_Target;
42 typedef struct _Ecore_Wl_Event_Mouse_In Ecore_Wl_Event_Mouse_In;
43 typedef struct _Ecore_Wl_Event_Mouse_Out Ecore_Wl_Event_Mouse_Out;
44 typedef struct _Ecore_Wl_Event_Focus_In Ecore_Wl_Event_Focus_In;
45 typedef struct _Ecore_Wl_Event_Focus_Out Ecore_Wl_Event_Focus_Out;
46 typedef struct _Ecore_Wl_Event_Window_Configure Ecore_Wl_Event_Window_Configure;
47 typedef struct _Ecore_Wl_Event_Dnd_Enter Ecore_Wl_Event_Dnd_Enter;
48 typedef struct _Ecore_Wl_Event_Dnd_Position Ecore_Wl_Event_Dnd_Position;
49 typedef struct _Ecore_Wl_Event_Dnd_Leave Ecore_Wl_Event_Dnd_Leave;
50 typedef struct _Ecore_Wl_Event_Dnd_Drop Ecore_Wl_Event_Dnd_Drop;
51 typedef struct _Ecore_Wl_Event_Data_Source_Send Ecore_Wl_Event_Data_Source_Send; /** @since 1.7 */
52 typedef struct _Ecore_Wl_Event_Selection_Data_Ready Ecore_Wl_Event_Selection_Data_Ready; /** @since 1.7 */
53 typedef struct _Ecore_Wl_Event_Interfaces_Bound Ecore_Wl_Event_Interfaces_Bound;
55 enum _Ecore_Wl_Window_Type
57 ECORE_WL_WINDOW_TYPE_NONE,
58 ECORE_WL_WINDOW_TYPE_TOPLEVEL,
59 ECORE_WL_WINDOW_TYPE_FULLSCREEN,
60 ECORE_WL_WINDOW_TYPE_MAXIMIZED,
61 ECORE_WL_WINDOW_TYPE_TRANSIENT,
62 ECORE_WL_WINDOW_TYPE_MENU,
63 ECORE_WL_WINDOW_TYPE_CUSTOM
66 enum _Ecore_Wl_Window_Buffer_Type
68 ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW,
69 ECORE_WL_WINDOW_BUFFER_TYPE_EGL_IMAGE,
70 ECORE_WL_WINDOW_BUFFER_TYPE_SHM
73 struct _Ecore_Wl_Display
77 struct wl_display *display;
78 struct wl_compositor *compositor;
79 struct wl_shell *shell;
80 struct wl_shell *desktop_shell;
82 struct wl_data_device_manager *data_device_manager;
88 Ecore_Fd_Handler *fd_hdl;
90 struct wl_list inputs;
91 struct wl_list outputs;
95 struct xkb_context *context;
98 struct wl_cursor_theme *cursor_theme;
100 Ecore_Wl_Output *output;
101 Ecore_Wl_Input *input;
103 void (*output_configure)(Ecore_Wl_Output *output, void *data);
107 struct _Ecore_Wl_Output
109 Ecore_Wl_Display *display;
110 struct wl_output *output;
111 Eina_Rectangle allocation;
115 void (*destroy) (Ecore_Wl_Output *output, void *data);
119 struct _Ecore_Wl_Input
121 Ecore_Wl_Display *display;
122 struct wl_seat *seat;
123 struct wl_pointer *pointer;
124 struct wl_keyboard *keyboard;
125 struct wl_touch *touch;
127 const char *cursor_name;
128 struct wl_surface *cursor_surface;
129 struct wl_callback *cursor_frame_cb;
131 struct wl_data_device *data_device;
133 Ecore_Wl_Window *pointer_focus;
134 Ecore_Wl_Window *keyboard_focus;
137 unsigned int timestamp;
138 unsigned int modifiers;
139 unsigned int pointer_enter_serial;
144 Ecore_Wl_Window *grab;
145 unsigned int grab_button;
147 Ecore_Wl_Dnd_Source *drag_source;
148 Ecore_Wl_Dnd_Source *selection_source;
149 Ecore_Wl_Dnd *dnd; /** @since 1.7 */
153 struct xkb_keymap *keymap;
154 struct xkb_state *state;
155 xkb_mod_mask_t control_mask;
156 xkb_mod_mask_t alt_mask;
157 xkb_mod_mask_t shift_mask;
162 Ecore_Fd_Handler *hdlr;
164 unsigned int sym, key, time;
168 struct _Ecore_Wl_Window
170 Ecore_Wl_Display *display;
171 Ecore_Wl_Window *parent;
173 struct wl_surface *surface;
174 struct wl_shell_surface *shell_surface;
178 struct wl_region *input, *opaque;
185 Eina_Rectangle allocation, pending_allocation;
186 Eina_Rectangle saved_allocation, server_allocation;
188 /* Eina_Bool redraw_scheduled : 1; */
189 /* Eina_Bool resize_scheduled : 1; */
191 Eina_Bool transparent : 1;
192 Eina_Bool moving : 1;
193 Eina_Bool resizing : 1;
195 Ecore_Wl_Window_Type type;
196 Ecore_Wl_Window_Buffer_Type buffer_type;
198 Ecore_Wl_Input *pointer_device;
199 Ecore_Wl_Input *keyboard_device;
201 Eina_Bool frame_pending;
202 struct wl_callback *frame_callback;
203 /* FIXME: Ideally we should record the cursor name for this window
204 * so we can compare and avoid unnecessary cursor set calls to wayland */
209 struct _Ecore_Wl_Event_Mouse_In
218 unsigned int event_window;
219 unsigned int root_window;
220 unsigned int timestamp;
223 struct _Ecore_Wl_Event_Mouse_Out
232 unsigned int event_window;
233 unsigned int root_window;
234 unsigned int timestamp;
237 struct _Ecore_Wl_Event_Focus_In
240 unsigned int timestamp;
243 struct _Ecore_Wl_Event_Focus_Out
246 unsigned int timestamp;
249 struct _Ecore_Wl_Event_Window_Configure
252 unsigned int event_win;
256 struct _Ecore_Wl_Event_Dnd_Enter
258 unsigned int win, source;
267 struct _Ecore_Wl_Event_Dnd_Position
269 unsigned int win, source;
276 struct _Ecore_Wl_Event_Dnd_Leave
278 unsigned int win, source;
281 struct _Ecore_Wl_Event_Dnd_Drop
283 unsigned int win, source;
291 struct _Ecore_Wl_Event_Data_Source_Send
298 struct _Ecore_Wl_Event_Selection_Data_Ready
305 struct _Ecore_Wl_Event_Interfaces_Bound
307 Eina_Bool compositor : 1;
314 * @brief Ecore functions for dealing with the Wayland window system
316 * Ecore_Wl provides a wrapper and convenience functions for using the
317 * Wayland window system. Function groups for this part of the library
318 * include the following:
320 * @li @ref Ecore_Wl_Init_Group
321 * @li @ref Ecore_Wl_Display_Group
322 * @li @ref Ecore_Wl_Flush_Group
323 * @li @ref Ecore_Wl_Window_Group
326 EAPI extern int ECORE_WL_EVENT_MOUSE_IN;
327 EAPI extern int ECORE_WL_EVENT_MOUSE_OUT;
328 EAPI extern int ECORE_WL_EVENT_FOCUS_IN;
329 EAPI extern int ECORE_WL_EVENT_FOCUS_OUT;
330 EAPI extern int ECORE_WL_EVENT_WINDOW_CONFIGURE;
331 EAPI extern int ECORE_WL_EVENT_DND_ENTER;
332 EAPI extern int ECORE_WL_EVENT_DND_POSITION;
333 EAPI extern int ECORE_WL_EVENT_DND_LEAVE;
334 EAPI extern int ECORE_WL_EVENT_DND_DROP;
335 EAPI extern int ECORE_WL_EVENT_DATA_SOURCE_TARGET; /** @since 1.7 */
336 EAPI extern int ECORE_WL_EVENT_DATA_SOURCE_SEND; /** @since 1.7 */
337 EAPI extern int ECORE_WL_EVENT_DATA_SOURCE_CANCELLED; /** @since 1.7 */
338 EAPI extern int ECORE_WL_EVENT_SELECTION_DATA_READY; /** @since 1.7 */
339 EAPI extern int ECORE_WL_EVENT_INTERFACES_BOUND;
341 EAPI int ecore_wl_init(const char *name);
342 EAPI int ecore_wl_shutdown(void);
343 EAPI void ecore_wl_flush(void);
344 EAPI void ecore_wl_sync(void);
345 EAPI struct wl_shm *ecore_wl_shm_get(void);
346 EAPI struct wl_display *ecore_wl_display_get(void);
347 EAPI void ecore_wl_screen_size_get(int *w, int *h);
348 EAPI void ecore_wl_pointer_xy_get(int *x, int *y);
349 EAPI int ecore_wl_dpi_get(void);
350 EAPI void ecore_wl_display_iterate(void);
351 EAPI struct wl_cursor *ecore_wl_cursor_get(const char *cursor_name);
353 EAPI void ecore_wl_input_grab(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int button);
354 EAPI void ecore_wl_input_ungrab(Ecore_Wl_Input *input);
355 EAPI void ecore_wl_input_pointer_set(Ecore_Wl_Input *input, struct wl_surface *surface, int hot_x, int hot_y);
356 EAPI void ecore_wl_input_cursor_from_name_set(Ecore_Wl_Input *input, const char *cursor_name);
357 EAPI void ecore_wl_input_cursor_default_restore(Ecore_Wl_Input *input);
359 EAPI struct wl_list ecore_wl_outputs_get(void);
361 EAPI Ecore_Wl_Window *ecore_wl_window_new(Ecore_Wl_Window *parent, int x, int y, int w, int h, int buffer_type);
362 EAPI void ecore_wl_window_free(Ecore_Wl_Window *win);
363 EAPI void ecore_wl_window_move(Ecore_Wl_Window *win, int x, int y);
364 EAPI void ecore_wl_window_resize(Ecore_Wl_Window *win, int w, int h, int location);
365 EAPI void ecore_wl_window_damage(Ecore_Wl_Window *win, int x, int y, int w, int h);
366 EAPI void ecore_wl_window_buffer_attach(Ecore_Wl_Window *win, struct wl_buffer *buffer, int x, int y);
367 EAPI void ecore_wl_window_show(Ecore_Wl_Window *win);
368 EAPI void ecore_wl_window_hide(Ecore_Wl_Window *win);
369 EAPI void ecore_wl_window_raise(Ecore_Wl_Window *win);
370 EAPI void ecore_wl_window_maximized_set(Ecore_Wl_Window *win, Eina_Bool maximized);
371 EAPI void ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen);
372 EAPI void ecore_wl_window_transparent_set(Ecore_Wl_Window *win, Eina_Bool transparent);
373 EAPI void ecore_wl_window_update_size(Ecore_Wl_Window *win, int w, int h);
374 EAPI void ecore_wl_window_update_location(Ecore_Wl_Window *win, int x, int y);
375 EAPI struct wl_surface *ecore_wl_window_surface_get(Ecore_Wl_Window *win);
376 EAPI struct wl_shell_surface *ecore_wl_window_shell_surface_get(Ecore_Wl_Window *win);
377 EAPI Ecore_Wl_Window *ecore_wl_window_find(unsigned int id);
378 EAPI void ecore_wl_window_type_set(Ecore_Wl_Window *win, Ecore_Wl_Window_Type type);
379 EAPI void ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_surface *surface, int hot_x, int hot_y);
380 EAPI void ecore_wl_window_cursor_from_name_set(Ecore_Wl_Window *win, const char *cursor_name);
381 EAPI void ecore_wl_window_cursor_default_restore(Ecore_Wl_Window *win);
382 EAPI void ecore_wl_window_parent_set(Ecore_Wl_Window *win, Ecore_Wl_Window *parent);
385 EAPI Eina_Bool ecore_wl_dnd_set_selection(Ecore_Wl_Dnd *dnd, const char **types_offered);
386 EAPI Eina_Bool ecore_wl_dnd_get_selection(Ecore_Wl_Dnd *dnd, const char *type);
387 EAPI Ecore_Wl_Dnd *ecore_wl_dnd_get();
388 EAPI Eina_Bool ecore_wl_dnd_start_drag();
389 EAPI Eina_Bool ecore_wl_dnd_selection_has_owner(Ecore_Wl_Dnd *dnd);