From ef7f9fed607f0d8e922deeb6aaa1cc6289e63f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Tue, 11 Jun 2024 11:44:25 +0200 Subject: [PATCH] winewayland: Move window surface creation functions to window_surface.c. --- dlls/winewayland.drv/waylanddrv.h | 25 +++++++++++- dlls/winewayland.drv/window.c | 57 +-------------------------- dlls/winewayland.drv/window_surface.c | 39 +++++++++++++++++- 3 files changed, 64 insertions(+), 57 deletions(-) diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 4b92c9bf1ba..d0a8977f887 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -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 */ diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index c006505bc90..060a25d50c6 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -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 */ diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index 888fa74c085..9377b05b4ce 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -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; +}