From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dce.c | 21 ++++++++++++++------- dlls/win32u/win32u_private.h | 2 +- dlls/win32u/window.c | 2 +- dlls/wineandroid.drv/window.c | 12 +++++------- dlls/winemac.drv/macdrv.h | 2 +- dlls/winemac.drv/surface.c | 4 ++-- dlls/winemac.drv/window.c | 4 ++-- dlls/winewayland.drv/window_surface.c | 7 ++----- dlls/winex11.drv/bitblt.c | 4 ++-- dlls/winex11.drv/window.c | 4 ++-- dlls/winex11.drv/x11drv.h | 2 +- include/wine/gdi_driver.h | 3 ++- 12 files changed, 35 insertions(+), 32 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index d8a26b655ef..428b25d3b6e 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -98,7 +98,13 @@ static const struct window_surface_funcs dummy_surface_funcs = dummy_surface_destroy };
-struct window_surface dummy_surface = { &dummy_surface_funcs, { NULL, NULL }, 1, { 0, 0, 1, 1 }, PTHREAD_MUTEX_INITIALIZER }; +struct window_surface dummy_surface = +{ + .funcs = &dummy_surface_funcs, + .ref = 1, + .rect = {.right = 1, .bottom = 1}, + .mutex = PTHREAD_MUTEX_INITIALIZER, +};
/******************************************************************* * Off-screen window surface. @@ -149,13 +155,13 @@ static const struct window_surface_funcs offscreen_window_surface_funcs = offscreen_window_surface_destroy };
-void create_offscreen_window_surface( const RECT *visible_rect, struct window_surface **surface ) +void create_offscreen_window_surface( HWND hwnd, const RECT *visible_rect, struct window_surface **surface ) { struct offscreen_window_surface *impl; SIZE_T size; RECT surface_rect = *visible_rect;
- TRACE( "visible_rect %s, surface %p.\n", wine_dbgstr_rect( visible_rect ), surface ); + TRACE( "hwnd %p, visible_rect %s, surface %p.\n", hwnd, wine_dbgstr_rect( visible_rect ), surface );
OffsetRect( &surface_rect, -surface_rect.left, -surface_rect.top ); surface_rect.right = (surface_rect.right + 0x1f) & ~0x1f; @@ -174,7 +180,7 @@ void create_offscreen_window_surface( const RECT *visible_rect, struct window_su *surface = NULL; size = surface_rect.right * surface_rect.bottom * 4; if (!(impl = calloc(1, offsetof( struct offscreen_window_surface, info.bmiColors[0] ) + size))) return; - window_surface_init( &impl->header, &offscreen_window_surface_funcs, &surface_rect ); + window_surface_init( &impl->header, &offscreen_window_surface_funcs, hwnd, &surface_rect );
impl->bits = (char *)&impl->info.bmiColors[0]; impl->info.bmiHeader.biSize = sizeof( impl->info ); @@ -192,10 +198,11 @@ void create_offscreen_window_surface( const RECT *visible_rect, struct window_su
/* window surface common helpers */
-W32KAPI void window_surface_init( struct window_surface *surface, const struct window_surface_funcs *funcs, const RECT *rect ) +W32KAPI void window_surface_init( struct window_surface *surface, const struct window_surface_funcs *funcs, HWND hwnd, const RECT *rect ) { surface->funcs = funcs; surface->ref = 1; + surface->hwnd = hwnd; surface->rect = *rect; pthread_mutex_init( &surface->mutex, NULL ); reset_bounds( &surface->bounds ); @@ -236,8 +243,8 @@ W32KAPI void window_surface_flush( struct window_surface *surface )
if (intersect_rect( &dirty, &dirty, &surface->bounds )) { - TRACE( "Flushing surface %p %s, bounds %s, dirty %s\n", surface, wine_dbgstr_rect( &surface->rect ), - wine_dbgstr_rect( &surface->bounds ), wine_dbgstr_rect( &dirty ) ); + TRACE( "Flushing hwnd %p, surface %p %s, bounds %s, dirty %s\n", surface->hwnd, surface, + wine_dbgstr_rect( &surface->rect ), wine_dbgstr_rect( &surface->bounds ), wine_dbgstr_rect( &dirty ) ); if (surface->funcs->flush( surface, &surface->rect, &dirty )) reset_bounds( &surface->bounds ); }
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index aecd60bae63..8aed662d2d8 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -45,7 +45,7 @@ extern ULONG_PTR set_icon_param( HICON handle, ULONG_PTR param );
/* dce.c */ extern struct window_surface dummy_surface; -extern void create_offscreen_window_surface( const RECT *visible_rect, +extern void create_offscreen_window_surface( HWND hwnd, const RECT *visible_rect, struct window_surface **surface ); extern void erase_now( HWND hwnd, UINT rdw_flags ); extern void flush_window_surfaces( BOOL idle ); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index b0fe0218da5..bafceb1a22a 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -1814,7 +1814,7 @@ static BOOL apply_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, { window_surface_release( new_surface ); if ((new_surface = win->surface)) window_surface_add_ref( new_surface ); - create_offscreen_window_surface( &visible_rect, &new_surface ); + create_offscreen_window_surface( hwnd, &visible_rect, &new_surface ); }
old_visible_rect = win->visible_rect; diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index ddb46c0d4cd..61ebc097f47 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -571,7 +571,6 @@ static int wait_events( int timeout ) struct android_window_surface { struct window_surface header; - HWND hwnd; ANativeWindow *window; BOOL byteswap; RGNDATA *region_data; @@ -656,7 +655,7 @@ static void android_surface_set_region( struct window_surface *window_surface, H { struct android_window_surface *surface = get_android_surface( window_surface );
- TRACE( "updating surface %p hwnd %p with %p\n", surface, surface->hwnd, region ); + TRACE( "updating surface %p hwnd %p with %p\n", surface, window_surface->hwnd, region );
window_surface_lock( window_surface ); if (!region) @@ -738,7 +737,7 @@ static BOOL android_surface_flush( struct window_surface *window_surface, const surface->window->perform( surface->window, NATIVE_WINDOW_UNLOCK_AND_POST ); } else TRACE( "Unable to lock surface %p window %p buffer %p\n", - surface, surface->hwnd, surface->window ); + surface, window_surface->hwnd, surface->window );
return TRUE; } @@ -806,7 +805,7 @@ static void set_surface_region( struct window_surface *window_surface, HRGN win_
if (window_surface->funcs != &android_surface_funcs) return; /* we may get the null surface */
- if (!(win_data = get_win_data( surface->hwnd ))) return; + if (!(win_data = get_win_data( window_surface->hwnd ))) return; offset_x = win_data->window_rect.left - win_data->whole_rect.left; offset_y = win_data->window_rect.top - win_data->whole_rect.top; release_win_data( win_data ); @@ -815,7 +814,7 @@ static void set_surface_region( struct window_surface *window_surface, HRGN win_ { region = NtGdiCreateRectRgn( 0, 0, win_data->window_rect.right - win_data->window_rect.left, win_data->window_rect.bottom - win_data->window_rect.top ); - if (NtUserGetWindowRgnEx( surface->hwnd, region, 0 ) == ERROR && !surface->region) goto done; + if (NtUserGetWindowRgnEx( window_surface->hwnd, region, 0 ) == ERROR && !surface->region) goto done; }
NtGdiOffsetRgn( region, offset_x, offset_y ); @@ -850,7 +849,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; - window_surface_init( &surface->header, &android_surface_funcs, rect ); + window_surface_init( &surface->header, &android_surface_funcs, hwnd, rect );
set_color_info( &surface->info, src_alpha ); surface->info.bmiHeader.biWidth = width; @@ -858,7 +857,6 @@ static struct window_surface *create_surface( HWND hwnd, const RECT *rect, surface->info.bmiHeader.biPlanes = 1; surface->info.bmiHeader.biSizeImage = get_dib_image_size( &surface->info );
- surface->hwnd = hwnd; surface->window = get_ioctl_window( hwnd ); surface->alpha = alpha; set_color_key( surface, color_key ); diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index d1101a4a228..a7905050f16 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -208,7 +208,7 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p extern macdrv_window macdrv_get_cocoa_window(HWND hwnd, BOOL require_on_screen); extern RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp); extern void activate_on_following_focus(void); -extern struct window_surface *create_surface(macdrv_window window, const RECT *rect, +extern struct window_surface *create_surface(HWND hwnd, macdrv_window window, const RECT *rect, struct window_surface *old_surface, BOOL use_alpha); extern void set_surface_use_alpha(struct window_surface *window_surface, BOOL use_alpha); extern void surface_clip_to_visible_rect(struct window_surface *window_surface, const RECT *visible_rect); diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index 7e296f33a62..a6f61538d16 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -149,7 +149,7 @@ static struct macdrv_window_surface *get_mac_surface(struct window_surface *surf /*********************************************************************** * create_surface */ -struct window_surface *create_surface(macdrv_window window, const RECT *rect, +struct window_surface *create_surface(HWND hwnd, macdrv_window window, const RECT *rect, struct window_surface *old_surface, BOOL use_alpha) { struct macdrv_window_surface *surface; @@ -159,7 +159,7 @@ struct window_surface *create_surface(macdrv_window window, const RECT *rect,
surface = calloc(1, FIELD_OFFSET(struct macdrv_window_surface, info.bmiColors[3])); if (!surface) return NULL; - window_surface_init(&surface->header, &macdrv_surface_funcs, rect); + window_surface_init(&surface->header, &macdrv_surface_funcs, hwnd, rect);
surface->info.bmiHeader.biSize = sizeof(surface->info.bmiHeader); surface->info.bmiHeader.biWidth = width; diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 04eb6d00860..84668b44c51 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1915,7 +1915,7 @@ BOOL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO *info, surface = data->surface; if (!surface || !EqualRect(&surface->rect, &rect)) { - data->surface = create_surface(data->cocoa_window, &rect, NULL, TRUE); + data->surface = create_surface(data->hwnd, data->cocoa_window, &rect, NULL, TRUE); macdrv_set_window_surface(data->cocoa_window, data->surface); if (surface) window_surface_release(surface); surface = data->surface; @@ -2094,7 +2094,7 @@ BOOL macdrv_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags, } else if (!(swp_flags & SWP_SHOWWINDOW) && !(style & WS_VISIBLE)) goto done;
- *surface = create_surface(data->cocoa_window, &surface_rect, data->surface, FALSE); + *surface = create_surface(data->hwnd, data->cocoa_window, &surface_rect, data->surface, FALSE);
done: release_win_data(data); diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index 2605b3c7b3d..2c19c8ffdc4 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -43,7 +43,6 @@ struct wayland_buffer_queue struct wayland_window_surface { struct window_surface header; - HWND hwnd; struct wayland_surface *wayland_surface; struct wayland_buffer_queue *wayland_buffer_queue; void *bits; @@ -463,7 +462,7 @@ struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect
wws = calloc(1, sizeof(*wws)); if (!wws) return NULL; - window_surface_init(&wws->header, &wayland_window_surface_funcs, rect); + window_surface_init(&wws->header, &wayland_window_surface_funcs, hwnd, rect);
wws->info.bmiHeader.biSize = sizeof(wws->info.bmiHeader); wws->info.bmiHeader.biClrUsed = 0; @@ -474,8 +473,6 @@ struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect wws->info.bmiHeader.biPlanes = 1; wws->info.bmiHeader.biSizeImage = width * height * 4;
- wws->hwnd = hwnd; - if (!(wws->bits = malloc(wws->info.bmiHeader.biSizeImage))) goto failed;
@@ -499,7 +496,7 @@ void wayland_window_surface_update_wayland_surface(struct window_surface *window
window_surface_lock(window_surface);
- TRACE("surface=%p hwnd=%p wayland_surface=%p\n", wws, wws->hwnd, wayland_surface); + TRACE("surface=%p hwnd=%p wayland_surface=%p\n", wws, window_surface->hwnd, wayland_surface);
wws->wayland_surface = wayland_surface;
diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index f0d523b6f9c..404beab923d 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1954,7 +1954,7 @@ static const struct window_surface_funcs x11drv_surface_funcs = /*********************************************************************** * create_surface */ -struct window_surface *create_surface( Window window, const XVisualInfo *vis, const RECT *rect, +struct window_surface *create_surface( HWND hwnd, Window window, const XVisualInfo *vis, const RECT *rect, COLORREF color_key, BOOL use_alpha ) { const XPixmapFormatValues *format = pixmap_formats[vis->depth]; @@ -1964,7 +1964,7 @@ struct window_surface *create_surface( Window window, const XVisualInfo *vis, co
surface = calloc( 1, FIELD_OFFSET( struct x11drv_window_surface, info.bmiColors[colors] )); if (!surface) return NULL; - window_surface_init( &surface->header, &x11drv_surface_funcs, rect ); + window_surface_init( &surface->header, &x11drv_surface_funcs, hwnd, rect );
surface->info.bmiHeader.biSize = sizeof(surface->info.bmiHeader); surface->info.bmiHeader.biWidth = width; diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 823a17e3998..f975986a9d9 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2645,7 +2645,7 @@ BOOL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags, if (!layered || !NtUserGetLayeredWindowAttributes( hwnd, &key, NULL, &flags ) || !(flags & LWA_COLORKEY)) key = CLR_INVALID;
- *surface = create_surface( data->whole_window, &data->vis, &surface_rect, key, FALSE ); + *surface = create_surface( data->hwnd, data->whole_window, &data->vis, &surface_rect, key, FALSE );
done: release_win_data( data ); @@ -2991,7 +2991,7 @@ BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info, surface = data->surface; if (!surface || !EqualRect( &surface->rect, &rect )) { - data->surface = create_surface( data->whole_window, &data->vis, &rect, + data->surface = create_surface( data->hwnd, data->whole_window, &data->vis, &rect, color_key, data->use_alpha ); if (surface) window_surface_release( surface ); surface = data->surface; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index d10ade448e2..2a326b07a4c 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -265,7 +265,7 @@ extern Pixmap create_pixmap_from_image( HDC hdc, const XVisualInfo *vis, const B const struct gdi_image_bits *bits, UINT coloruse ); extern DWORD get_pixmap_image( Pixmap pixmap, int width, int height, const XVisualInfo *vis, BITMAPINFO *info, struct gdi_image_bits *bits ); -extern struct window_surface *create_surface( Window window, const XVisualInfo *vis, const RECT *rect, +extern struct window_surface *create_surface( HWND hwnd, Window window, const XVisualInfo *vis, const RECT *rect, COLORREF color_key, BOOL use_alpha ); extern void set_surface_color_key( struct window_surface *window_surface, COLORREF color_key ); extern HRGN expose_surface( struct window_surface *window_surface, const RECT *rect ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 2721083c6ad..f6cfc7778de 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -222,6 +222,7 @@ struct window_surface const struct window_surface_funcs *funcs; /* driver-specific implementations */ struct list entry; /* entry in global list managed by user32 */ LONG ref; /* reference count */ + HWND hwnd; /* window the surface was created for */ RECT rect; /* constant, no locking needed */
pthread_mutex_t mutex; @@ -230,7 +231,7 @@ struct window_surface /* driver-specific fields here */ };
-W32KAPI void window_surface_init( struct window_surface *surface, const struct window_surface_funcs *funcs, const RECT *rect ); +W32KAPI void window_surface_init( struct window_surface *surface, const struct window_surface_funcs *funcs, HWND hwnd, const RECT *rect ); 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 );