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 "xdg-output-unstable-v1-client-protocol.h"
31 #include "xdg-shell-client-protocol.h"
36 #include "wine/gdi_driver.h"
37 #include "wine/rbtree.h"
41 /* We only use 4 byte formats. */
42 #define WINEWAYLAND_BYTES_PER_PIXEL 4
44 /**********************************************************************
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
62 struct wl_display
*wl_display
;
63 struct wl_event_queue
*wl_event_queue
;
64 struct wl_registry
*wl_registry
;
65 struct zxdg_output_manager_v1
*zxdg_output_manager_v1
;
66 struct wl_compositor
*wl_compositor
;
67 struct xdg_wm_base
*xdg_wm_base
;
68 struct wl_shm
*wl_shm
;
69 struct wl_list output_list
;
70 /* Protects the output_list and the wayland_output.current states. */
71 pthread_mutex_t output_mutex
;
74 struct wayland_output_mode
76 struct rb_entry entry
;
82 struct wayland_output_state
85 struct wayland_output_mode
*current_mode
;
87 int logical_x
, logical_y
;
88 int logical_w
, logical_h
;
94 struct wl_output
*wl_output
;
95 struct zxdg_output_v1
*zxdg_output_v1
;
97 unsigned int pending_flags
;
98 struct wayland_output_state pending
;
99 struct wayland_output_state current
;
102 struct wayland_surface
105 struct wl_surface
*wl_surface
;
106 struct xdg_surface
*xdg_surface
;
107 struct xdg_toplevel
*xdg_toplevel
;
108 pthread_mutex_t mutex
;
109 uint32_t current_serial
;
112 struct wayland_shm_buffer
115 struct wl_buffer
*wl_buffer
;
124 /**********************************************************************
125 * Wayland initialization
128 BOOL
wayland_process_init(void) DECLSPEC_HIDDEN
;
129 void wayland_init_display_devices(BOOL force
) DECLSPEC_HIDDEN
;
131 /**********************************************************************
135 BOOL
wayland_output_create(uint32_t id
, uint32_t version
) DECLSPEC_HIDDEN
;
136 void wayland_output_destroy(struct wayland_output
*output
) DECLSPEC_HIDDEN
;
137 void wayland_output_use_xdg_extension(struct wayland_output
*output
) DECLSPEC_HIDDEN
;
139 /**********************************************************************
143 struct wayland_surface
*wayland_surface_create(HWND hwnd
) DECLSPEC_HIDDEN
;
144 void wayland_surface_destroy(struct wayland_surface
*surface
) DECLSPEC_HIDDEN
;
145 void wayland_surface_make_toplevel(struct wayland_surface
*surface
) DECLSPEC_HIDDEN
;
146 void wayland_surface_clear_role(struct wayland_surface
*surface
) DECLSPEC_HIDDEN
;
147 void wayland_surface_attach_shm(struct wayland_surface
*surface
,
148 struct wayland_shm_buffer
*shm_buffer
) DECLSPEC_HIDDEN
;
150 /**********************************************************************
154 struct wayland_shm_buffer
*wayland_shm_buffer_create(int width
, int height
,
155 enum wl_shm_format format
) DECLSPEC_HIDDEN
;
156 void wayland_shm_buffer_ref(struct wayland_shm_buffer
*shm_buffer
) DECLSPEC_HIDDEN
;
157 void wayland_shm_buffer_unref(struct wayland_shm_buffer
*shm_buffer
) DECLSPEC_HIDDEN
;
159 /**********************************************************************
160 * Wayland window surface
163 struct window_surface
*wayland_window_surface_create(HWND hwnd
, const RECT
*rect
) DECLSPEC_HIDDEN
;
164 void wayland_window_surface_update_wayland_surface(struct window_surface
*surface
,
165 struct wayland_surface
*wayland_surface
) DECLSPEC_HIDDEN
;
166 void wayland_window_flush(HWND hwnd
) DECLSPEC_HIDDEN
;
168 /**********************************************************************
172 static inline BOOL
intersect_rect(RECT
*dst
, const RECT
*src1
, const RECT
*src2
)
174 dst
->left
= max(src1
->left
, src2
->left
);
175 dst
->top
= max(src1
->top
, src2
->top
);
176 dst
->right
= min(src1
->right
, src2
->right
);
177 dst
->bottom
= min(src1
->bottom
, src2
->bottom
);
178 return !IsRectEmpty(dst
);
181 /**********************************************************************
182 * USER driver functions
185 LRESULT
WAYLAND_DesktopWindowProc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
) DECLSPEC_HIDDEN
;
186 void WAYLAND_DestroyWindow(HWND hwnd
) DECLSPEC_HIDDEN
;
187 BOOL
WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager
*device_manager
,
188 BOOL force
, void *param
) DECLSPEC_HIDDEN
;
189 LRESULT
WAYLAND_WindowMessage(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
) DECLSPEC_HIDDEN
;
190 void WAYLAND_WindowPosChanged(HWND hwnd
, HWND insert_after
, UINT swp_flags
,
191 const RECT
*window_rect
, const RECT
*client_rect
,
192 const RECT
*visible_rect
, const RECT
*valid_rects
,
193 struct window_surface
*surface
) DECLSPEC_HIDDEN
;
194 BOOL
WAYLAND_WindowPosChanging(HWND hwnd
, HWND insert_after
, UINT swp_flags
,
195 const RECT
*window_rect
, const RECT
*client_rect
,
196 RECT
*visible_rect
, struct window_surface
**surface
) DECLSPEC_HIDDEN
;
198 #endif /* __WINE_WAYLANDDRV_H */