winewayland.drv: Avoid resizing fullscreen windows.
[wine.git] / dlls / winewayland.drv / waylanddrv.h
blob4bcd9e6706e3c8af51b148557274967a9878770e
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 "xdg-output-unstable-v1-client-protocol.h"
31 #include "xdg-shell-client-protocol.h"
33 #include "windef.h"
34 #include "winbase.h"
35 #include "ntgdi.h"
36 #include "wine/gdi_driver.h"
37 #include "wine/rbtree.h"
39 #include "unixlib.h"
41 /* We only use 4 byte formats. */
42 #define WINEWAYLAND_BYTES_PER_PIXEL 4
44 /**********************************************************************
45 * Globals
48 extern struct wayland process_wayland DECLSPEC_HIDDEN;
50 /**********************************************************************
51 * Definitions for wayland types
54 enum wayland_window_message
56 WM_WAYLAND_INIT_DISPLAY_DEVICES = 0x80001000,
57 WM_WAYLAND_CONFIGURE = 0x80001001
60 enum wayland_surface_config_state
62 WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED = (1 << 0),
63 WAYLAND_SURFACE_CONFIG_STATE_RESIZING = (1 << 1),
64 WAYLAND_SURFACE_CONFIG_STATE_TILED = (1 << 2),
65 WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN = (1 << 3)
68 struct wayland_cursor
70 struct wayland_shm_buffer *shm_buffer;
71 struct wl_surface *wl_surface;
72 int hotspot_x, hotspot_y;
75 struct wayland_pointer
77 struct wl_pointer *wl_pointer;
78 HWND focused_hwnd;
79 uint32_t enter_serial;
80 uint32_t button_serial;
81 struct wayland_cursor cursor;
82 pthread_mutex_t mutex;
85 struct wayland_seat
87 struct wl_seat *wl_seat;
88 uint32_t global_id;
89 pthread_mutex_t mutex;
92 struct wayland
94 BOOL initialized;
95 struct wl_display *wl_display;
96 struct wl_event_queue *wl_event_queue;
97 struct wl_registry *wl_registry;
98 struct zxdg_output_manager_v1 *zxdg_output_manager_v1;
99 struct wl_compositor *wl_compositor;
100 struct xdg_wm_base *xdg_wm_base;
101 struct wl_shm *wl_shm;
102 struct wayland_seat seat;
103 struct wayland_pointer pointer;
104 struct wl_list output_list;
105 /* Protects the output_list and the wayland_output.current states. */
106 pthread_mutex_t output_mutex;
109 struct wayland_output_mode
111 struct rb_entry entry;
112 int32_t width;
113 int32_t height;
114 int32_t refresh;
117 struct wayland_output_state
119 struct rb_tree modes;
120 struct wayland_output_mode *current_mode;
121 char *name;
122 int logical_x, logical_y;
123 int logical_w, logical_h;
126 struct wayland_output
128 struct wl_list link;
129 struct wl_output *wl_output;
130 struct zxdg_output_v1 *zxdg_output_v1;
131 uint32_t global_id;
132 unsigned int pending_flags;
133 struct wayland_output_state pending;
134 struct wayland_output_state current;
137 struct wayland_surface_config
139 int32_t width, height;
140 enum wayland_surface_config_state state;
141 uint32_t serial;
142 BOOL processed;
145 struct wayland_window_config
147 RECT rect;
148 enum wayland_surface_config_state state;
151 struct wayland_surface
153 HWND hwnd;
154 struct wl_surface *wl_surface;
155 struct xdg_surface *xdg_surface;
156 struct xdg_toplevel *xdg_toplevel;
157 pthread_mutex_t mutex;
158 struct wayland_surface_config pending, requested, processing, current;
159 struct wayland_shm_buffer *latest_window_buffer;
160 BOOL resizing;
161 struct wayland_window_config window;
164 struct wayland_shm_buffer
166 struct wl_list link;
167 struct wl_buffer *wl_buffer;
168 int width, height;
169 void *map_data;
170 size_t map_size;
171 BOOL busy;
172 LONG ref;
173 HRGN damage_region;
176 /**********************************************************************
177 * Wayland initialization
180 BOOL wayland_process_init(void) DECLSPEC_HIDDEN;
181 void wayland_init_display_devices(BOOL force) DECLSPEC_HIDDEN;
183 /**********************************************************************
184 * Wayland output
187 BOOL wayland_output_create(uint32_t id, uint32_t version) DECLSPEC_HIDDEN;
188 void wayland_output_destroy(struct wayland_output *output) DECLSPEC_HIDDEN;
189 void wayland_output_use_xdg_extension(struct wayland_output *output) DECLSPEC_HIDDEN;
191 /**********************************************************************
192 * Wayland surface
195 struct wayland_surface *wayland_surface_create(HWND hwnd) DECLSPEC_HIDDEN;
196 void wayland_surface_destroy(struct wayland_surface *surface) DECLSPEC_HIDDEN;
197 void wayland_surface_make_toplevel(struct wayland_surface *surface) DECLSPEC_HIDDEN;
198 void wayland_surface_clear_role(struct wayland_surface *surface) DECLSPEC_HIDDEN;
199 void wayland_surface_attach_shm(struct wayland_surface *surface,
200 struct wayland_shm_buffer *shm_buffer,
201 HRGN surface_damage_region) DECLSPEC_HIDDEN;
202 struct wayland_surface *wayland_surface_lock_hwnd(HWND hwnd) DECLSPEC_HIDDEN;
203 BOOL wayland_surface_reconfigure(struct wayland_surface *surface) DECLSPEC_HIDDEN;
204 BOOL wayland_surface_config_is_compatible(struct wayland_surface_config *conf,
205 int width, int height,
206 enum wayland_surface_config_state state) DECLSPEC_HIDDEN;
208 /**********************************************************************
209 * Wayland SHM buffer
212 struct wayland_shm_buffer *wayland_shm_buffer_create(int width, int height,
213 enum wl_shm_format format) DECLSPEC_HIDDEN;
214 void wayland_shm_buffer_ref(struct wayland_shm_buffer *shm_buffer) DECLSPEC_HIDDEN;
215 void wayland_shm_buffer_unref(struct wayland_shm_buffer *shm_buffer) DECLSPEC_HIDDEN;
217 /**********************************************************************
218 * Wayland window surface
221 struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect) DECLSPEC_HIDDEN;
222 void wayland_window_surface_update_wayland_surface(struct window_surface *surface,
223 struct wayland_surface *wayland_surface) DECLSPEC_HIDDEN;
224 void wayland_window_flush(HWND hwnd) DECLSPEC_HIDDEN;
226 /**********************************************************************
227 * Wayland pointer
230 void wayland_pointer_init(struct wl_pointer *wl_pointer) DECLSPEC_HIDDEN;
231 void wayland_pointer_deinit(void) DECLSPEC_HIDDEN;
233 /**********************************************************************
234 * Helpers
237 static inline BOOL intersect_rect(RECT *dst, const RECT *src1, const RECT *src2)
239 dst->left = max(src1->left, src2->left);
240 dst->top = max(src1->top, src2->top);
241 dst->right = min(src1->right, src2->right);
242 dst->bottom = min(src1->bottom, src2->bottom);
243 return !IsRectEmpty(dst);
246 static inline LRESULT send_message(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
248 return NtUserMessageCall(hwnd, msg, wparam, lparam, NULL, NtUserSendMessage, FALSE);
251 RGNDATA *get_region_data(HRGN region) DECLSPEC_HIDDEN;
253 /**********************************************************************
254 * USER driver functions
257 LRESULT WAYLAND_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) DECLSPEC_HIDDEN;
258 void WAYLAND_DestroyWindow(HWND hwnd) DECLSPEC_HIDDEN;
259 void WAYLAND_SetCursor(HWND hwnd, HCURSOR hcursor) DECLSPEC_HIDDEN;
260 LRESULT WAYLAND_SysCommand(HWND hwnd, WPARAM wparam, LPARAM lparam) DECLSPEC_HIDDEN;
261 BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager,
262 BOOL force, void *param) DECLSPEC_HIDDEN;
263 LRESULT WAYLAND_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) DECLSPEC_HIDDEN;
264 void WAYLAND_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags,
265 const RECT *window_rect, const RECT *client_rect,
266 const RECT *visible_rect, const RECT *valid_rects,
267 struct window_surface *surface) DECLSPEC_HIDDEN;
268 BOOL WAYLAND_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags,
269 const RECT *window_rect, const RECT *client_rect,
270 RECT *visible_rect, struct window_surface **surface) DECLSPEC_HIDDEN;
272 #endif /* __WINE_WAYLANDDRV_H */