From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/opengl.c | 5 +++- dlls/winewayland.drv/vulkan.c | 5 +++- dlls/winewayland.drv/waylanddrv.h | 1 + dlls/winewayland.drv/window.c | 41 +++++++++++-------------------- 4 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index a9f0e2d259e..0b7595c3dcf 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -179,7 +179,8 @@ static struct wayland_gl_drawable *wayland_gl_drawable_create(HWND hwnd, HDC hdc /* Get the client surface for the HWND. If don't have a wayland surface * (e.g., HWND_MESSAGE windows) just create a dummy surface to act as the * target render surface. */ - if (!(gl->client = get_client_surface(hwnd))) goto err; + if (!(gl->client = wayland_client_surface_create(hwnd))) goto err; + set_client_surface(hwnd, gl->client);
gl->wl_egl_window = wl_egl_window_create(gl->client->wl_surface, width, height); if (!gl->wl_egl_window) @@ -493,6 +494,8 @@ static BOOL wayland_swap_buffers(void *private, HWND hwnd, HDC hdc, int interval
if (ctx) wayland_context_refresh(ctx); ensure_window_surface_contents(toplevel); + set_client_surface(hwnd, gl->client); + /* Although all the EGL surfaces we create are double-buffered, we want to * use some as single-buffered, so avoid swapping those. */ if (gl->double_buffered) funcs->p_eglSwapBuffers(egl->display, gl->surface); diff --git a/dlls/winewayland.drv/vulkan.c b/dlls/winewayland.drv/vulkan.c index 4774f11771c..e619cfb4fa0 100644 --- a/dlls/winewayland.drv/vulkan.c +++ b/dlls/winewayland.drv/vulkan.c @@ -74,7 +74,7 @@ static VkResult wayland_vulkan_surface_create(HWND hwnd, const struct vulkan_ins
TRACE("%p %p %p %p\n", hwnd, instance, surface, private);
- if (!(client = get_client_surface(hwnd))) + if (!(client = wayland_client_surface_create(hwnd))) { ERR("Failed to create client surface for hwnd=%p\n", hwnd); return VK_ERROR_OUT_OF_HOST_MEMORY; @@ -96,6 +96,7 @@ static VkResult wayland_vulkan_surface_create(HWND hwnd, const struct vulkan_ins return res; }
+ set_client_surface(hwnd, client); *private = client;
TRACE("Created surface=0x%s, private=%p\n", wine_dbgstr_longlong(*surface), *private); @@ -121,8 +122,10 @@ static void wayland_vulkan_surface_update(HWND hwnd, void *private)
static void wayland_vulkan_surface_presented(HWND hwnd, void *private, VkResult result) { + struct wayland_client_surface *client = private; HWND toplevel = NtUserGetAncestor(hwnd, GA_ROOT); ensure_window_surface_contents(toplevel); + set_client_surface(hwnd, client); }
static VkBool32 wayland_vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice phys_dev, diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 001cb29e05e..e0be6970b05 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -377,6 +377,7 @@ struct wayland_win_data *wayland_win_data_get_nolock(HWND hwnd); void wayland_win_data_release(struct wayland_win_data *data);
struct wayland_client_surface *get_client_surface(HWND hwnd); +void set_client_surface(HWND hwnd, struct wayland_client_surface *client); BOOL set_window_surface_contents(HWND hwnd, struct wayland_shm_buffer *shm_buffer, HRGN damage_region); struct wayland_shm_buffer *get_window_surface_contents(HWND hwnd); void ensure_window_surface_contents(HWND hwnd); diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index ce5b6bb5143..dbcbd90be00 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -775,42 +775,29 @@ LRESULT WAYLAND_SysCommand(HWND hwnd, WPARAM wparam, LPARAM lparam, const POINT return ret; }
-/********************************************************************** - * get_client_surface - */ -struct wayland_client_surface *get_client_surface(HWND hwnd) +void set_client_surface(HWND hwnd, struct wayland_client_surface *new_client) { HWND toplevel = NtUserGetAncestor(hwnd, GA_ROOT); - struct wayland_client_surface *client; + struct wayland_client_surface *old_client; struct wayland_win_data *data;
- if ((data = wayland_win_data_get(hwnd))) - { - /* ownership is shared with one of the callers, the last caller to release - * its reference will also destroy it and clear our pointer. */ - if ((client = data->client_surface)) InterlockedIncrement(&client->ref); - } - else - { - client = NULL; - } + /* ownership is shared with the callers, the last caller to release + * its reference will also destroy it and clear our pointer. */
- if (!client && !(client = wayland_client_surface_create(hwnd))) - { - if (data) wayland_win_data_release(data); - return NULL; - } - if (!data) return client; + if (!(data = wayland_win_data_get(hwnd))) return;
- if (toplevel && NtUserIsWindowVisible(hwnd)) - wayland_client_surface_attach(client, toplevel); - else - wayland_client_surface_detach(client); + if ((old_client = data->client_surface)) + wayland_client_surface_detach(old_client);
- if (!data->client_surface) data->client_surface = client; + if ((data->client_surface = new_client)) + { + if (toplevel && NtUserIsWindowVisible(hwnd)) + wayland_client_surface_attach(new_client, toplevel); + else + wayland_client_surface_detach(new_client); + }
wayland_win_data_release(data); - return client; }
BOOL set_window_surface_contents(HWND hwnd, struct wayland_shm_buffer *shm_buffer, HRGN damage_region)