[PATCH 0/1] MR11220: winewayland: Remove wayland_surface_ensure_contents.
I never really understood the point of this function (beyond just ensuring the toplevel is mapped), and it also has bugs. For example, ``` width = surface->window.rect.right - surface->window.rect.left; height = surface->window.rect.bottom - surface->window.rect.top; needs_contents = surface->window.visible && (surface->content_width != width || surface->content_height != height); ``` This condition is incorrect (see wayland_surface_attach_shm), which causes the window buttons to become transparent in some apps. In addition, is commiting a transparent buffer even a good idea if for example the app is an WGL app which is always opaque. Regardless, we can just use NtUserExposeWindowSurface in the unlikely event that there are no contents on the window. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11220
From: Etaash Mathamsetty <etaash.mathamsetty@gmail.com> --- dlls/winewayland.drv/wayland_surface.c | 62 -------------------------- dlls/winewayland.drv/window.c | 5 ++- 2 files changed, 4 insertions(+), 63 deletions(-) diff --git a/dlls/winewayland.drv/wayland_surface.c b/dlls/winewayland.drv/wayland_surface.c index b28072331d6..d06f3b6002c 100644 --- a/dlls/winewayland.drv/wayland_surface.c +++ b/dlls/winewayland.drv/wayland_surface.c @@ -1308,68 +1308,6 @@ void wayland_client_surface_attach(struct wayland_client_surface *client, HWND t wl_surface_commit(surface->wl_surface); } -static void dummy_buffer_release(void *data, struct wl_buffer *buffer) -{ - struct wayland_shm_buffer *shm_buffer = data; - TRACE("shm_buffer=%p\n", shm_buffer); - wayland_shm_buffer_unref(shm_buffer); -} - -static const struct wl_buffer_listener dummy_buffer_listener = -{ - dummy_buffer_release -}; - -/********************************************************************** - * wayland_surface_ensure_contents - * - * Ensure that the wayland surface has up-to-date contents, by committing - * a dummy buffer if necessary. - */ -void wayland_surface_ensure_contents(struct wayland_surface *surface) -{ - struct wayland_shm_buffer *dummy_shm_buffer; - HRGN damage; - int width, height; - BOOL needs_contents; - - width = surface->window.rect.right - surface->window.rect.left; - height = surface->window.rect.bottom - surface->window.rect.top; - needs_contents = surface->window.visible && - (surface->content_width != width || - surface->content_height != height); - - TRACE("surface=%p hwnd=%p needs_contents=%d\n", - surface, surface->hwnd, needs_contents); - - if (!needs_contents) return; - - /* Create a transparent dummy buffer. */ - dummy_shm_buffer = wayland_shm_buffer_create(width, height, WL_SHM_FORMAT_ARGB8888); - if (!dummy_shm_buffer) - { - ERR("Failed to create dummy buffer\n"); - return; - } - wl_buffer_add_listener(dummy_shm_buffer->wl_buffer, &dummy_buffer_listener, - dummy_shm_buffer); - - if (!(damage = NtGdiCreateRectRgn(0, 0, width, height))) - WARN("Failed to create damage region for dummy buffer\n"); - - if (wayland_surface_reconfigure(surface)) - { - wayland_surface_attach_shm(surface, dummy_shm_buffer, damage); - wl_surface_commit(surface->wl_surface); - } - else - { - wayland_shm_buffer_unref(dummy_shm_buffer); - } - - if (damage) NtGdiDeleteObjectApp(damage); -} - /********************************************************************** * wayland_surface_set_title */ diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index 8e05292cb62..b1436b8299a 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -914,12 +914,13 @@ void ensure_window_surface_contents(HWND hwnd) { struct wayland_surface *wayland_surface; struct wayland_win_data *data; + BOOL expose = FALSE; if (!(data = wayland_win_data_get(hwnd))) return; if ((wayland_surface = data->wayland_surface)) { - wayland_surface_ensure_contents(wayland_surface); + expose = wayland_surface->window.visible && !data->window_contents; /* Handle any processed configure request, to ensure the related * surface state is applied by the compositor. */ @@ -932,4 +933,6 @@ void ensure_window_surface_contents(HWND hwnd) } wayland_win_data_release(data); + + if (expose) NtUserExposeWindowSurface(hwnd, 0, NULL, 0); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11220
This merge request was closed by Etaash Mathamsetty. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11220
looks like Rémi had the same idea in !11225 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11220#note_143813
participants (2)
-
Etaash Mathamsetty -
Etaash Mathamsetty (@etaash.mathamsetty)