1
0
mirror of https://github.com/wine-mirror/wine synced 2024-06-29 06:14:34 +00:00

winewayland: Move window surface creation functions to window_surface.c.

This commit is contained in:
Rémi Bernon 2024-06-11 11:44:25 +02:00 committed by Alexandre Julliard
parent 834da273c1
commit ef7f9fed60
3 changed files with 64 additions and 57 deletions

View File

@ -272,11 +272,34 @@ void wayland_shm_buffer_unref(struct wayland_shm_buffer *shm_buffer);
* Wayland window surface
*/
struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect);
void wayland_window_surface_update_wayland_surface(struct window_surface *surface,
struct wayland_surface *wayland_surface);
void wayland_window_flush(HWND hwnd);
/**********************************************************************
* Wayland Window
*/
/* private window data */
struct wayland_win_data
{
struct rb_entry entry;
/* hwnd that this private data belongs to */
HWND hwnd;
/* wayland surface (if any) for this window */
struct wayland_surface *wayland_surface;
/* wine window_surface backing this window */
struct window_surface *window_surface;
/* USER window rectangle relative to win32 parent window client area */
RECT window_rect;
/* USER client rectangle relative to win32 parent window client area */
RECT client_rect;
BOOL managed;
};
struct wayland_win_data *wayland_win_data_get(HWND hwnd);
void wayland_win_data_release(struct wayland_win_data *data);
/**********************************************************************
* Wayland Keyboard
*/

View File

@ -56,23 +56,6 @@ static BOOL set_window_pos(HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy,
}
/* private window data */
struct wayland_win_data
{
struct rb_entry entry;
/* hwnd that this private data belongs to */
HWND hwnd;
/* wayland surface (if any) for this window */
struct wayland_surface *wayland_surface;
/* wine window_surface backing this window */
struct window_surface *window_surface;
/* USER window rectangle relative to win32 parent window client area */
RECT window_rect;
/* USER client rectangle relative to win32 parent window client area */
RECT client_rect;
BOOL managed;
};
static int wayland_win_data_cmp_rb(const void *key,
const struct rb_entry *entry)
{
@ -153,7 +136,7 @@ static void wayland_win_data_destroy(struct wayland_win_data *data)
*
* Lock and return the data structure associated with a window.
*/
static struct wayland_win_data *wayland_win_data_get(HWND hwnd)
struct wayland_win_data *wayland_win_data_get(HWND hwnd)
{
struct rb_entry *rb_entry;
@ -172,7 +155,7 @@ static struct wayland_win_data *wayland_win_data_get(HWND hwnd)
*
* Release the data returned by wayland_win_data_get.
*/
static void wayland_win_data_release(struct wayland_win_data *data)
void wayland_win_data_release(struct wayland_win_data *data)
{
assert(data);
pthread_mutex_unlock(&win_data_mutex);
@ -471,42 +454,6 @@ done:
}
/***********************************************************************
* WAYLAND_CreateWindowSurface
*/
BOOL WAYLAND_CreateWindowSurface(HWND hwnd, UINT swp_flags, const RECT *visible_rect, struct window_surface **surface)
{
struct wayland_win_data *data;
RECT surface_rect;
TRACE("hwnd %p, swp_flags %08x, visible %s, surface %p\n", hwnd, swp_flags, wine_dbgstr_rect(visible_rect), surface);
if (!(data = wayland_win_data_get(hwnd))) return TRUE; /* use default surface */
/* Release the dummy surface wine provides for toplevels. */
if (*surface) window_surface_release(*surface);
*surface = NULL;
surface_rect = *visible_rect;
OffsetRect(&surface_rect, -surface_rect.left, -surface_rect.top);
/* Check if we can reuse our current window surface. */
if (data->window_surface &&
EqualRect(&data->window_surface->rect, &surface_rect))
{
window_surface_add_ref(data->window_surface);
*surface = data->window_surface;
TRACE("reusing surface %p\n", *surface);
goto done;
}
*surface = wayland_window_surface_create(data->hwnd, &surface_rect);
done:
wayland_win_data_release(data);
return TRUE;
}
/***********************************************************************
* WAYLAND_WindowPosChanged
*/

View File

@ -449,7 +449,7 @@ static const struct window_surface_funcs wayland_window_surface_funcs =
/***********************************************************************
* wayland_window_surface_create
*/
struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect)
static struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect)
{
char buffer[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
BITMAPINFO *info = (BITMAPINFO *)buffer;
@ -516,3 +516,40 @@ void wayland_window_surface_update_wayland_surface(struct window_surface *window
window_surface_unlock(window_surface);
}
/***********************************************************************
* WAYLAND_CreateWindowSurface
*/
BOOL WAYLAND_CreateWindowSurface(HWND hwnd, UINT swp_flags, const RECT *visible_rect, struct window_surface **surface)
{
struct wayland_win_data *data;
RECT surface_rect;
TRACE("hwnd %p, swp_flags %08x, visible %s, surface %p\n", hwnd, swp_flags, wine_dbgstr_rect(visible_rect), surface);
if (!(data = wayland_win_data_get(hwnd))) return TRUE; /* use default surface */
/* Release the dummy surface wine provides for toplevels. */
if (*surface) window_surface_release(*surface);
*surface = NULL;
surface_rect = *visible_rect;
OffsetRect(&surface_rect, -surface_rect.left, -surface_rect.top);
/* Check if we can reuse our current window surface. */
if (data->window_surface &&
EqualRect(&data->window_surface->rect, &surface_rect))
{
window_surface_add_ref(data->window_surface);
*surface = data->window_surface;
TRACE("reusing surface %p\n", *surface);
goto done;
}
*surface = wayland_window_surface_create(data->hwnd, &surface_rect);
done:
wayland_win_data_release(data);
return TRUE;
}