Module: wine Branch: master Commit: 09b9c1b5fe002c0d55f53f68b474acb02310018f URL: https://gitlab.winehq.org/wine/wine/-/commit/09b9c1b5fe002c0d55f53f68b474acb...
Author: Rémi Bernon rbernon@codeweavers.com Date: Tue Jun 4 10:22:40 2024 +0200
win32u: Restore surface rect, which may offsetted from the window rect.
Some drivers only create surfaces over the visible part of the window, and the surface rect has an offset.
Fixes a regression from 5d0efbcc6e88e2b7886f2a0cfb58c9100b452160, which causes XSHM errors with partially offscreen windows.
---
dlls/win32u/dce.c | 7 ++++--- dlls/wineandroid.drv/window.c | 2 +- dlls/winemac.drv/surface.c | 2 +- dlls/winewayland.drv/window_surface.c | 2 +- dlls/winex11.drv/bitblt.c | 2 +- include/wine/gdi_driver.h | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index f6726b49aa1..34acb1d10f6 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -188,7 +188,7 @@ void create_offscreen_window_surface( HWND hwnd, const RECT *visible_rect, struc /* create a new window surface */ *surface = NULL; if (!(impl = calloc(1, sizeof(*impl)))) return; - window_surface_init( &impl->header, &offscreen_window_surface_funcs, hwnd, info, 0 ); + window_surface_init( &impl->header, &offscreen_window_surface_funcs, hwnd, &surface_rect, info, 0 ); impl->info = *info;
TRACE( "created window surface %p\n", &impl->header ); @@ -199,7 +199,7 @@ void create_offscreen_window_surface( HWND hwnd, const RECT *visible_rect, struc /* window surface common helpers */
W32KAPI BOOL window_surface_init( struct window_surface *surface, const struct window_surface_funcs *funcs, - HWND hwnd, BITMAPINFO *info, HBITMAP bitmap ) + HWND hwnd, const RECT *rect, BITMAPINFO *info, HBITMAP bitmap ) { struct bitblt_coords coords = {0}; struct gdi_image_bits bits; @@ -208,7 +208,7 @@ W32KAPI BOOL window_surface_init( struct window_surface *surface, const struct w surface->funcs = funcs; surface->ref = 1; surface->hwnd = hwnd; - SetRect( &surface->rect, 0, 0, info->bmiHeader.biWidth, abs( info->bmiHeader.biHeight ) ); + surface->rect = *rect; pthread_mutex_init( &surface->mutex, NULL ); reset_bounds( &surface->bounds );
@@ -256,6 +256,7 @@ W32KAPI void window_surface_flush( struct window_surface *surface )
window_surface_lock( surface );
+ OffsetRect( &dirty, -dirty.left, -dirty.top ); if (intersect_rect( &dirty, &dirty, &surface->bounds )) { TRACE( "Flushing hwnd %p, surface %p %s, bounds %s, dirty %s\n", surface->hwnd, surface, diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index fa7b87522c5..7b7d680fe2e 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -792,7 +792,7 @@ static struct window_surface *create_surface( HWND hwnd, const RECT *rect,
surface = calloc( 1, FIELD_OFFSET( struct android_window_surface, info.bmiColors[3] )); if (!surface) return NULL; - if (!window_surface_init( &surface->header, &android_surface_funcs, hwnd, info, 0 )) goto failed; + if (!window_surface_init( &surface->header, &android_surface_funcs, hwnd, rect, info, 0 )) goto failed; memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) );
surface->window = get_ioctl_window( hwnd ); diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index 82b7a382ec4..37e2c466926 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -147,7 +147,7 @@ struct window_surface *create_surface(HWND hwnd, macdrv_window window, const REC
surface = calloc(1, FIELD_OFFSET(struct macdrv_window_surface, info.bmiColors[3])); if (!surface) return NULL; - if (!window_surface_init(&surface->header, &macdrv_surface_funcs, hwnd, info, 0)) goto failed; + if (!window_surface_init(&surface->header, &macdrv_surface_funcs, hwnd, rect, info, 0)) goto failed; memcpy(&surface->info, info, offsetof(BITMAPINFO, bmiColors[3]));
surface->window = window; diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index c0b516c9288..fb3b8750001 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -470,7 +470,7 @@ struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect
wws = calloc(1, sizeof(*wws)); if (!wws) return NULL; - if (!window_surface_init(&wws->header, &wayland_window_surface_funcs, hwnd, info, 0)) goto failed; + if (!window_surface_init(&wws->header, &wayland_window_surface_funcs, hwnd, rect, info, 0)) goto failed; wws->info = *info;
TRACE("created %p hwnd %p %s bits [%p,%p)\n", wws, hwnd, wine_dbgstr_rect(rect), diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index ec6250048cf..8a001606420 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -2098,7 +2098,7 @@ struct window_surface *create_surface( HWND hwnd, Window window, const XVisualIn surface->image = image; surface->byteswap = byteswap;
- if (!window_surface_init( &surface->header, &x11drv_surface_funcs, hwnd, info, bitmap )) goto failed; + if (!window_surface_init( &surface->header, &x11drv_surface_funcs, hwnd, rect, info, bitmap )) goto failed; memcpy( &surface->info, info, get_dib_info_size( info, DIB_RGB_COLORS ) );
surface->window = window; diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index ce954a7f4d8..701e3031dc3 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -235,7 +235,7 @@ struct window_surface };
W32KAPI BOOL window_surface_init( struct window_surface *surface, const struct window_surface_funcs *funcs, - HWND hwnd, BITMAPINFO *info, HBITMAP bitmap ); + HWND hwnd, const RECT *rect, BITMAPINFO *info, HBITMAP bitmap ); W32KAPI void window_surface_add_ref( struct window_surface *surface ); W32KAPI void window_surface_release( struct window_surface *surface ); W32KAPI void window_surface_lock( struct window_surface *surface );