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
29 #include <wayland-client.h>
30 #include <xkbcommon/xkbcommon.h>
31 #include "xdg-output-unstable-v1-client-protocol.h"
32 #include "xdg-shell-client-protocol.h"
37 #include "wine/gdi_driver.h"
38 #include "wine/rbtree.h"
42 /* We only use 4 byte formats. */
43 #define WINEWAYLAND_BYTES_PER_PIXEL 4
45 /**********************************************************************
49 extern struct wayland process_wayland DECLSPEC_HIDDEN
;
51 /**********************************************************************
52 * Definitions for wayland types
55 enum wayland_window_message
57 WM_WAYLAND_INIT_DISPLAY_DEVICES
= 0x80001000,
58 WM_WAYLAND_CONFIGURE
= 0x80001001
61 enum wayland_surface_config_state
63 WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED
= (1 << 0),
64 WAYLAND_SURFACE_CONFIG_STATE_RESIZING
= (1 << 1),
65 WAYLAND_SURFACE_CONFIG_STATE_TILED
= (1 << 2),
66 WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN
= (1 << 3)
69 struct wayland_keyboard
71 struct wl_keyboard
*wl_keyboard
;
72 struct xkb_context
*xkb_context
;
74 pthread_mutex_t mutex
;
79 struct wayland_shm_buffer
*shm_buffer
;
80 struct wl_surface
*wl_surface
;
81 int hotspot_x
, hotspot_y
;
84 struct wayland_pointer
86 struct wl_pointer
*wl_pointer
;
88 uint32_t enter_serial
;
89 uint32_t button_serial
;
90 struct wayland_cursor cursor
;
91 pthread_mutex_t mutex
;
96 struct wl_seat
*wl_seat
;
98 pthread_mutex_t mutex
;
104 struct wl_display
*wl_display
;
105 struct wl_event_queue
*wl_event_queue
;
106 struct wl_registry
*wl_registry
;
107 struct zxdg_output_manager_v1
*zxdg_output_manager_v1
;
108 struct wl_compositor
*wl_compositor
;
109 struct xdg_wm_base
*xdg_wm_base
;
110 struct wl_shm
*wl_shm
;
111 struct wayland_seat seat
;
112 struct wayland_keyboard keyboard
;
113 struct wayland_pointer pointer
;
114 struct wl_list output_list
;
115 /* Protects the output_list and the wayland_output.current states. */
116 pthread_mutex_t output_mutex
;
119 struct wayland_output_mode
121 struct rb_entry entry
;
127 struct wayland_output_state
129 struct rb_tree modes
;
130 struct wayland_output_mode
*current_mode
;
132 int logical_x
, logical_y
;
133 int logical_w
, logical_h
;
136 struct wayland_output
139 struct wl_output
*wl_output
;
140 struct zxdg_output_v1
*zxdg_output_v1
;
142 unsigned int pending_flags
;
143 struct wayland_output_state pending
;
144 struct wayland_output_state current
;
147 struct wayland_surface_config
149 int32_t width
, height
;
150 enum wayland_surface_config_state state
;
155 struct wayland_window_config
158 enum wayland_surface_config_state state
;
161 struct wayland_surface
164 struct wl_surface
*wl_surface
;
165 struct xdg_surface
*xdg_surface
;
166 struct xdg_toplevel
*xdg_toplevel
;
167 pthread_mutex_t mutex
;
168 struct wayland_surface_config pending
, requested
, processing
, current
;
169 struct wayland_shm_buffer
*latest_window_buffer
;
171 struct wayland_window_config window
;
174 struct wayland_shm_buffer
177 struct wl_buffer
*wl_buffer
;
186 /**********************************************************************
187 * Wayland initialization
190 BOOL
wayland_process_init(void) DECLSPEC_HIDDEN
;
191 void wayland_init_display_devices(BOOL force
) DECLSPEC_HIDDEN
;
193 /**********************************************************************
197 BOOL
wayland_output_create(uint32_t id
, uint32_t version
) DECLSPEC_HIDDEN
;
198 void wayland_output_destroy(struct wayland_output
*output
) DECLSPEC_HIDDEN
;
199 void wayland_output_use_xdg_extension(struct wayland_output
*output
) DECLSPEC_HIDDEN
;
201 /**********************************************************************
205 struct wayland_surface
*wayland_surface_create(HWND hwnd
) DECLSPEC_HIDDEN
;
206 void wayland_surface_destroy(struct wayland_surface
*surface
) DECLSPEC_HIDDEN
;
207 void wayland_surface_make_toplevel(struct wayland_surface
*surface
) DECLSPEC_HIDDEN
;
208 void wayland_surface_clear_role(struct wayland_surface
*surface
) DECLSPEC_HIDDEN
;
209 void wayland_surface_attach_shm(struct wayland_surface
*surface
,
210 struct wayland_shm_buffer
*shm_buffer
,
211 HRGN surface_damage_region
) DECLSPEC_HIDDEN
;
212 struct wayland_surface
*wayland_surface_lock_hwnd(HWND hwnd
) DECLSPEC_HIDDEN
;
213 BOOL
wayland_surface_reconfigure(struct wayland_surface
*surface
) DECLSPEC_HIDDEN
;
214 BOOL
wayland_surface_config_is_compatible(struct wayland_surface_config
*conf
,
215 int width
, int height
,
216 enum wayland_surface_config_state state
) DECLSPEC_HIDDEN
;
217 void wayland_surface_coords_from_window(struct wayland_surface
*surface
,
218 int window_x
, int window_y
,
219 int *surface_x
, int *surface_y
) DECLSPEC_HIDDEN
;
220 void wayland_surface_coords_to_window(struct wayland_surface
*surface
,
221 double surface_x
, double surface_y
,
222 int *window_x
, int *window_y
) DECLSPEC_HIDDEN
;
224 /**********************************************************************
228 struct wayland_shm_buffer
*wayland_shm_buffer_create(int width
, int height
,
229 enum wl_shm_format format
) DECLSPEC_HIDDEN
;
230 void wayland_shm_buffer_ref(struct wayland_shm_buffer
*shm_buffer
) DECLSPEC_HIDDEN
;
231 void wayland_shm_buffer_unref(struct wayland_shm_buffer
*shm_buffer
) DECLSPEC_HIDDEN
;
233 /**********************************************************************
234 * Wayland window surface
237 struct window_surface
*wayland_window_surface_create(HWND hwnd
, const RECT
*rect
) DECLSPEC_HIDDEN
;
238 void wayland_window_surface_update_wayland_surface(struct window_surface
*surface
,
239 struct wayland_surface
*wayland_surface
) DECLSPEC_HIDDEN
;
240 void wayland_window_flush(HWND hwnd
) DECLSPEC_HIDDEN
;
242 /**********************************************************************
246 void wayland_keyboard_init(struct wl_keyboard
*wl_keyboard
) DECLSPEC_HIDDEN
;
247 void wayland_keyboard_deinit(void) DECLSPEC_HIDDEN
;
249 /**********************************************************************
253 void wayland_pointer_init(struct wl_pointer
*wl_pointer
) DECLSPEC_HIDDEN
;
254 void wayland_pointer_deinit(void) DECLSPEC_HIDDEN
;
256 /**********************************************************************
260 static inline BOOL
intersect_rect(RECT
*dst
, const RECT
*src1
, const RECT
*src2
)
262 dst
->left
= max(src1
->left
, src2
->left
);
263 dst
->top
= max(src1
->top
, src2
->top
);
264 dst
->right
= min(src1
->right
, src2
->right
);
265 dst
->bottom
= min(src1
->bottom
, src2
->bottom
);
266 return !IsRectEmpty(dst
);
269 static inline LRESULT
send_message(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
271 return NtUserMessageCall(hwnd
, msg
, wparam
, lparam
, NULL
, NtUserSendMessage
, FALSE
);
274 RGNDATA
*get_region_data(HRGN region
) DECLSPEC_HIDDEN
;
276 /**********************************************************************
277 * USER driver functions
280 LRESULT
WAYLAND_DesktopWindowProc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
) DECLSPEC_HIDDEN
;
281 void WAYLAND_DestroyWindow(HWND hwnd
) DECLSPEC_HIDDEN
;
282 void WAYLAND_SetCursor(HWND hwnd
, HCURSOR hcursor
) DECLSPEC_HIDDEN
;
283 LRESULT
WAYLAND_SysCommand(HWND hwnd
, WPARAM wparam
, LPARAM lparam
) DECLSPEC_HIDDEN
;
284 BOOL
WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager
*device_manager
,
285 BOOL force
, void *param
) DECLSPEC_HIDDEN
;
286 LRESULT
WAYLAND_WindowMessage(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
) DECLSPEC_HIDDEN
;
287 void WAYLAND_WindowPosChanged(HWND hwnd
, HWND insert_after
, UINT swp_flags
,
288 const RECT
*window_rect
, const RECT
*client_rect
,
289 const RECT
*visible_rect
, const RECT
*valid_rects
,
290 struct window_surface
*surface
) DECLSPEC_HIDDEN
;
291 BOOL
WAYLAND_WindowPosChanging(HWND hwnd
, HWND insert_after
, UINT swp_flags
,
292 const RECT
*window_rect
, const RECT
*client_rect
,
293 RECT
*visible_rect
, struct window_surface
**surface
) DECLSPEC_HIDDEN
;
295 #endif /* __WINE_WAYLANDDRV_H */