From: Alexandros Frantzis alexandros.frantzis@collabora.com
Since the role objects in the wayland_surface struct are part of a union, we first need to check whether the surface has the right role before checking the role objects themselves. Otherwise we risk using a subsurface as a toplevel or vice-versa. --- dlls/winewayland.drv/wayland_surface.c | 10 +++++++--- dlls/winewayland.drv/window.c | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/dlls/winewayland.drv/wayland_surface.c b/dlls/winewayland.drv/wayland_surface.c index 39b6991a5eb..320ce9daa17 100644 --- a/dlls/winewayland.drv/wayland_surface.c +++ b/dlls/winewayland.drv/wayland_surface.c @@ -48,7 +48,9 @@ static void xdg_surface_handle_configure(void *private, struct xdg_surface *xdg_
/* Handle this event only if wayland_surface is still associated with * the target xdg_surface. */ - if ((surface = data->wayland_surface) && surface->xdg_surface == xdg_surface) + if ((surface = data->wayland_surface) && + surface->role == WAYLAND_SURFACE_ROLE_TOPLEVEL && + surface->xdg_surface == xdg_surface) { /* If we have a previously requested config, we have already sent a * WM_WAYLAND_CONFIGURE which hasn't been handled yet. In that case, @@ -116,7 +118,9 @@ static void xdg_toplevel_handle_configure(void *private,
if (!(data = wayland_win_data_get(hwnd))) return;
- if ((surface = data->wayland_surface) && surface->xdg_toplevel == xdg_toplevel) + if ((surface = data->wayland_surface) && + surface->role == WAYLAND_SURFACE_ROLE_TOPLEVEL && + surface->xdg_toplevel == xdg_toplevel) { surface->pending.width = width; surface->pending.height = height; @@ -1172,7 +1176,7 @@ void wayland_surface_set_title(struct wayland_surface *surface, LPCWSTR text) DWORD utf8_count; char *utf8 = NULL;
- assert(surface->xdg_toplevel); + assert(surface->role == WAYLAND_SURFACE_ROLE_TOPLEVEL && surface->xdg_toplevel);
TRACE("surface=%p hwnd=%p text='%s'\n", surface, surface->hwnd, wine_dbgstr_w(text)); diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index 184d09c2ed4..03dff29a4cc 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -537,7 +537,7 @@ static void wayland_configure_window(HWND hwnd) return; }
- if (!surface->xdg_toplevel) + if (surface->role != WAYLAND_SURFACE_ROLE_TOPLEVEL || !surface->xdg_toplevel) { TRACE("missing xdg_toplevel, returning\n"); wayland_win_data_release(data); @@ -721,7 +721,9 @@ void WAYLAND_SetWindowText(HWND hwnd, LPCWSTR text)
if ((data = wayland_win_data_get(hwnd))) { - if ((surface = data->wayland_surface) && surface->xdg_toplevel) + if ((surface = data->wayland_surface) && + surface->role == WAYLAND_SURFACE_ROLE_TOPLEVEL && + surface->xdg_toplevel) wayland_surface_set_title(surface, text); wayland_win_data_release(data); } @@ -755,7 +757,9 @@ LRESULT WAYLAND_SysCommand(HWND hwnd, WPARAM wparam, LPARAM lparam, const POINT { pthread_mutex_lock(&process_wayland.seat.mutex); wl_seat = process_wayland.seat.wl_seat; - if (wl_seat && (surface = data->wayland_surface) && surface->xdg_toplevel && button_serial) + if (wl_seat && (surface = data->wayland_surface) && + surface->role == WAYLAND_SURFACE_ROLE_TOPLEVEL && + surface->xdg_toplevel && button_serial) { if (command == SC_MOVE) {