widl: Add support for function parameter flags to SLTG typelib generator.
[wine.git] / dlls / winewayland.drv / waylanddrv.h
blob6811b34ab1aa9c5f1cf174b5c5663aec52130e59
1 /*
2 * Wayland driver
4 * Copyright 2020 Alexandros Frantzis for Collabora Ltd
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_WAYLANDDRV_H
22 #define __WINE_WAYLANDDRV_H
24 #ifndef __WINE_CONFIG_H
25 # error You must include config.h to use this header
26 #endif
28 #include <pthread.h>
29 #include <wayland-client.h>
30 #include <xkbcommon/xkbcommon.h>
31 #include <xkbcommon/xkbregistry.h>
32 #include "pointer-constraints-unstable-v1-client-protocol.h"
33 #include "relative-pointer-unstable-v1-client-protocol.h"
34 #include "viewporter-client-protocol.h"
35 #include "xdg-output-unstable-v1-client-protocol.h"
36 #include "xdg-shell-client-protocol.h"
38 #include "windef.h"
39 #include "winbase.h"
40 #include "ntgdi.h"
41 #include "wine/gdi_driver.h"
42 #include "wine/list.h"
43 #include "wine/rbtree.h"
45 #include "unixlib.h"
47 /* We only use 4 byte formats. */
48 #define WINEWAYLAND_BYTES_PER_PIXEL 4
50 /**********************************************************************
51 * Globals
54 extern struct wayland process_wayland;
56 /**********************************************************************
57 * Definitions for wayland types
60 enum wayland_window_message
62 WM_WAYLAND_INIT_DISPLAY_DEVICES = WM_WINE_FIRST_DRIVER_MSG,
63 WM_WAYLAND_CONFIGURE,
64 WM_WAYLAND_SET_FOREGROUND,
67 enum wayland_surface_config_state
69 WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED = (1 << 0),
70 WAYLAND_SURFACE_CONFIG_STATE_RESIZING = (1 << 1),
71 WAYLAND_SURFACE_CONFIG_STATE_TILED = (1 << 2),
72 WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN = (1 << 3)
75 struct wayland_keyboard
77 struct wl_keyboard *wl_keyboard;
78 struct xkb_context *xkb_context;
79 struct xkb_state *xkb_state;
80 HWND focused_hwnd;
81 pthread_mutex_t mutex;
84 struct wayland_cursor
86 struct wayland_shm_buffer *shm_buffer;
87 struct wl_surface *wl_surface;
88 struct wp_viewport *wp_viewport;
89 int hotspot_x, hotspot_y;
92 struct wayland_pointer
94 struct wl_pointer *wl_pointer;
95 struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1;
96 struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1;
97 struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1;
98 HWND focused_hwnd;
99 HWND constraint_hwnd;
100 uint32_t enter_serial;
101 uint32_t button_serial;
102 struct wayland_cursor cursor;
103 pthread_mutex_t mutex;
106 struct wayland_seat
108 struct wl_seat *wl_seat;
109 uint32_t global_id;
110 pthread_mutex_t mutex;
113 struct wayland
115 BOOL initialized;
116 struct wl_display *wl_display;
117 struct wl_event_queue *wl_event_queue;
118 struct wl_registry *wl_registry;
119 struct zxdg_output_manager_v1 *zxdg_output_manager_v1;
120 struct wl_compositor *wl_compositor;
121 struct xdg_wm_base *xdg_wm_base;
122 struct wl_shm *wl_shm;
123 struct wp_viewporter *wp_viewporter;
124 struct wl_subcompositor *wl_subcompositor;
125 struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1;
126 struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1;
127 struct wayland_seat seat;
128 struct wayland_keyboard keyboard;
129 struct wayland_pointer pointer;
130 struct wl_list output_list;
131 /* Protects the output_list and the wayland_output.current states. */
132 pthread_mutex_t output_mutex;
135 struct wayland_output_mode
137 struct rb_entry entry;
138 int32_t width;
139 int32_t height;
140 int32_t refresh;
143 struct wayland_output_state
145 int modes_count;
146 struct rb_tree modes;
147 struct wayland_output_mode *current_mode;
148 char *name;
149 int logical_x, logical_y;
150 int logical_w, logical_h;
153 struct wayland_output
155 struct wl_list link;
156 struct wl_output *wl_output;
157 struct zxdg_output_v1 *zxdg_output_v1;
158 uint32_t global_id;
159 unsigned int pending_flags;
160 struct wayland_output_state pending;
161 struct wayland_output_state current;
164 struct wayland_surface_config
166 int32_t width, height;
167 enum wayland_surface_config_state state;
168 uint32_t serial;
169 BOOL processed;
172 struct wayland_window_config
174 RECT rect;
175 RECT client_rect;
176 enum wayland_surface_config_state state;
177 /* The scale (i.e., normalized dpi) the window is rendering at. */
178 double scale;
179 BOOL visible;
180 BOOL managed;
183 struct wayland_client_surface
185 LONG ref;
186 struct wl_surface *wl_surface;
187 struct wl_subsurface *wl_subsurface;
188 struct wp_viewport *wp_viewport;
191 struct wayland_surface
193 HWND hwnd;
194 struct wl_surface *wl_surface;
195 struct xdg_surface *xdg_surface;
196 struct xdg_toplevel *xdg_toplevel;
197 struct wp_viewport *wp_viewport;
198 pthread_mutex_t mutex;
199 struct wayland_surface_config pending, requested, processing, current;
200 struct wayland_shm_buffer *latest_window_buffer;
201 BOOL resizing;
202 struct wayland_window_config window;
203 struct wayland_client_surface *client;
204 int buffer_width, buffer_height;
205 HCURSOR hcursor;
208 struct wayland_shm_buffer
210 struct wl_list link;
211 struct wl_buffer *wl_buffer;
212 int width, height;
213 void *map_data;
214 size_t map_size;
215 BOOL busy;
216 LONG ref;
217 HRGN damage_region;
220 /**********************************************************************
221 * Wayland initialization
224 BOOL wayland_process_init(void);
225 void wayland_init_display_devices(BOOL force);
227 /**********************************************************************
228 * Wayland output
231 BOOL wayland_output_create(uint32_t id, uint32_t version);
232 void wayland_output_destroy(struct wayland_output *output);
233 void wayland_output_use_xdg_extension(struct wayland_output *output);
235 /**********************************************************************
236 * Wayland surface
239 struct wayland_surface *wayland_surface_create(HWND hwnd);
240 void wayland_surface_destroy(struct wayland_surface *surface);
241 void wayland_surface_make_toplevel(struct wayland_surface *surface);
242 void wayland_surface_clear_role(struct wayland_surface *surface);
243 void wayland_surface_attach_shm(struct wayland_surface *surface,
244 struct wayland_shm_buffer *shm_buffer,
245 HRGN surface_damage_region);
246 struct wayland_surface *wayland_surface_lock_hwnd(HWND hwnd);
247 BOOL wayland_surface_reconfigure(struct wayland_surface *surface);
248 BOOL wayland_surface_config_is_compatible(struct wayland_surface_config *conf,
249 int width, int height,
250 enum wayland_surface_config_state state);
251 void wayland_surface_coords_from_window(struct wayland_surface *surface,
252 int window_x, int window_y,
253 int *surface_x, int *surface_y);
254 void wayland_surface_coords_to_window(struct wayland_surface *surface,
255 double surface_x, double surface_y,
256 int *window_x, int *window_y);
257 struct wayland_client_surface *wayland_surface_get_client(struct wayland_surface *surface);
258 BOOL wayland_client_surface_release(struct wayland_client_surface *client);
259 void wayland_surface_ensure_contents(struct wayland_surface *surface);
261 /**********************************************************************
262 * Wayland SHM buffer
265 struct wayland_shm_buffer *wayland_shm_buffer_create(int width, int height,
266 enum wl_shm_format format);
267 void wayland_shm_buffer_ref(struct wayland_shm_buffer *shm_buffer);
268 void wayland_shm_buffer_unref(struct wayland_shm_buffer *shm_buffer);
270 /**********************************************************************
271 * Wayland window surface
274 struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect);
275 void wayland_window_surface_update_wayland_surface(struct window_surface *surface,
276 struct wayland_surface *wayland_surface);
277 void wayland_window_flush(HWND hwnd);
279 /**********************************************************************
280 * Wayland Keyboard
283 void wayland_keyboard_init(struct wl_keyboard *wl_keyboard);
284 void wayland_keyboard_deinit(void);
285 const KBDTABLES *WAYLAND_KbdLayerDescriptor(HKL hkl);
286 void WAYLAND_ReleaseKbdTables(const KBDTABLES *);
288 /**********************************************************************
289 * Wayland pointer
292 void wayland_pointer_init(struct wl_pointer *wl_pointer);
293 void wayland_pointer_deinit(void);
294 void wayland_pointer_clear_constraint(void);
296 /**********************************************************************
297 * OpenGL
300 void wayland_destroy_gl_drawable(HWND hwnd);
301 void wayland_resize_gl_drawable(HWND hwnd);
303 /**********************************************************************
304 * Helpers
307 static inline BOOL intersect_rect(RECT *dst, const RECT *src1, const RECT *src2)
309 dst->left = max(src1->left, src2->left);
310 dst->top = max(src1->top, src2->top);
311 dst->right = min(src1->right, src2->right);
312 dst->bottom = min(src1->bottom, src2->bottom);
313 return !IsRectEmpty(dst);
316 static inline LRESULT send_message(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
318 return NtUserMessageCall(hwnd, msg, wparam, lparam, NULL, NtUserSendMessage, FALSE);
321 RGNDATA *get_region_data(HRGN region);
323 /**********************************************************************
324 * USER driver functions
327 BOOL WAYLAND_ClipCursor(const RECT *clip, BOOL reset);
328 LRESULT WAYLAND_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
329 void WAYLAND_DestroyWindow(HWND hwnd);
330 void WAYLAND_SetCursor(HWND hwnd, HCURSOR hcursor);
331 LRESULT WAYLAND_SysCommand(HWND hwnd, WPARAM wparam, LPARAM lparam);
332 BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager,
333 BOOL force, void *param);
334 LRESULT WAYLAND_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
335 void WAYLAND_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags,
336 const RECT *window_rect, const RECT *client_rect,
337 const RECT *visible_rect, const RECT *valid_rects,
338 struct window_surface *surface);
339 BOOL WAYLAND_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags,
340 const RECT *window_rect, const RECT *client_rect,
341 RECT *visible_rect, struct window_surface **surface);
342 UINT WAYLAND_VulkanInit(UINT version, void *vulkan_handle, struct vulkan_funcs *driver_funcs);
343 struct opengl_funcs *WAYLAND_wine_get_wgl_driver(UINT version);
345 #endif /* __WINE_WAYLANDDRV_H */