Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wineandroid.drv/window.c | 13 ++++++------- dlls/winex11.drv/bitblt.c | 13 ++++++------- include/wine/gdi_driver.h | 2 ++ 3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 1cb1bbbadc9..902f5980d13 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -587,7 +587,6 @@ struct android_window_surface BYTE alpha; COLORREF color_key; void *bits; - CRITICAL_SECTION crit; BITMAPINFO info; /* variable size, must be last */ };
@@ -660,7 +659,7 @@ static void CDECL android_surface_lock( struct window_surface *window_surface ) { struct android_window_surface *surface = get_android_surface( window_surface );
- EnterCriticalSection( &surface->crit ); + EnterCriticalSection( &surface->header.cs ); }
/*********************************************************************** @@ -670,7 +669,7 @@ static void CDECL android_surface_unlock( struct window_surface *window_surface { struct android_window_surface *surface = get_android_surface( window_surface );
- LeaveCriticalSection( &surface->crit ); + LeaveCriticalSection( &surface->header.cs ); }
/*********************************************************************** @@ -810,8 +809,8 @@ static void CDECL android_surface_destroy( struct window_surface *window_surface
TRACE( "freeing %p bits %p\n", surface, surface->bits );
- surface->crit.DebugInfo->Spare[0] = 0; - DeleteCriticalSection( &surface->crit ); + surface->header.cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection( &surface->header.cs ); HeapFree( GetProcessHeap(), 0, surface->region_data ); if (surface->region) DeleteObject( surface->region ); release_ioctl_window( surface->window ); @@ -920,8 +919,8 @@ 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 );
- InitializeCriticalSection( &surface->crit ); - surface->crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": surface"); + InitializeCriticalSection( &surface->header.cs ); + surface->header.cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": surface");
surface->header.funcs = &android_surface_funcs; surface->header.rect = *rect; diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index fad183b0b01..b931fd88da3 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1573,7 +1573,6 @@ struct x11drv_window_surface #ifdef HAVE_LIBXXSHM XShmSegmentInfo shminfo; #endif - CRITICAL_SECTION crit; BITMAPINFO info; /* variable size, must be last */ };
@@ -1821,7 +1820,7 @@ static void CDECL x11drv_surface_lock( struct window_surface *window_surface ) { struct x11drv_window_surface *surface = get_x11_surface( window_surface );
- EnterCriticalSection( &surface->crit ); + EnterCriticalSection( &surface->header.cs ); }
/*********************************************************************** @@ -1831,7 +1830,7 @@ static void CDECL x11drv_surface_unlock( struct window_surface *window_surface ) { struct x11drv_window_surface *surface = get_x11_surface( window_surface );
- LeaveCriticalSection( &surface->crit ); + LeaveCriticalSection( &surface->header.cs ); }
/*********************************************************************** @@ -1977,8 +1976,8 @@ static void CDECL x11drv_surface_destroy( struct window_surface *window_surface surface->image->data = NULL; XDestroyImage( surface->image ); } - surface->crit.DebugInfo->Spare[0] = 0; - DeleteCriticalSection( &surface->crit ); + surface->header.cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection( &surface->header.cs ); if (surface->region) DeleteObject( surface->region ); HeapFree( GetProcessHeap(), 0, surface ); } @@ -2016,8 +2015,8 @@ struct window_surface *create_surface( Window window, const XVisualInfo *vis, co surface->info.bmiHeader.biSizeImage = get_dib_image_size( &surface->info ); if (format->bits_per_pixel > 8) set_color_info( vis, &surface->info, use_alpha );
- InitializeCriticalSection( &surface->crit ); - surface->crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": surface"); + InitializeCriticalSection( &surface->header.cs ); + surface->header.cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": surface");
surface->header.funcs = &x11drv_surface_funcs; surface->header.rect = *rect; diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 124bb41f7d9..6c700664eb5 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -22,6 +22,7 @@ #define __WINE_WINE_GDI_DRIVER_H
#include "winternl.h" +#include "winbase.h" #include "ddk/d3dkmthk.h" #include "wine/list.h"
@@ -251,6 +252,7 @@ struct window_surface struct list entry; /* entry in global list managed by user32 */ LONG ref; /* reference count */ RECT rect; /* constant, no locking needed */ + CRITICAL_SECTION cs; /* critical section for locking */ /* driver-specific fields here */ };
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/gdi32/dibdrv/dc.c | 6 ++--- dlls/user32/painting.c | 4 +-- dlls/wineandroid.drv/window.c | 48 ++++++++++------------------------- dlls/winemac.drv/surface.c | 12 ++++----- dlls/winemac.drv/window.c | 12 ++++----- dlls/winex11.drv/bitblt.c | 40 ++++++++--------------------- dlls/winex11.drv/window.c | 4 +-- include/wine/gdi_driver.h | 12 +++++++++ 8 files changed, 55 insertions(+), 83 deletions(-)
diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c index 7fd404fc2cb..f8b26dc2b8e 100644 --- a/dlls/gdi32/dibdrv/dc.c +++ b/dlls/gdi32/dibdrv/dc.c @@ -784,20 +784,20 @@ static inline struct windrv_physdev *get_windrv_physdev( PHYSDEV dev ) static inline void lock_surface( struct windrv_physdev *dev ) { GDI_CheckNotLock(); - dev->surface->funcs->lock( dev->surface ); + window_surface_lock( dev->surface ); if (is_rect_empty( dev->dibdrv->bounds )) dev->start_ticks = GetTickCount(); }
static inline void unlock_surface( struct windrv_physdev *dev ) { - dev->surface->funcs->unlock( dev->surface ); + window_surface_unlock( dev->surface ); if (GetTickCount() - dev->start_ticks > FLUSH_PERIOD) dev->surface->funcs->flush( dev->surface ); }
static void CDECL unlock_bits_surface( struct gdi_image_bits *bits ) { struct window_surface *surface = bits->param; - surface->funcs->unlock( surface ); + window_surface_unlock( surface ); }
void dibdrv_set_window_surface( DC *dc, struct window_surface *surface ) diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c index db244ff04a5..47ea45ee86d 100644 --- a/dlls/user32/painting.c +++ b/dlls/user32/painting.c @@ -777,12 +777,12 @@ static void copy_bits_from_surface( HWND hwnd, struct window_surface *surface, HDC hdc = GetDCEx( hwnd, rgn, DCX_CACHE | DCX_WINDOW | DCX_EXCLUDERGN );
bits = surface->funcs->get_info( surface, info ); - surface->funcs->lock( surface ); + window_surface_lock( surface ); SetDIBitsToDevice( hdc, dst->left, dst->top, dst->right - dst->left, dst->bottom - dst->top, src->left - surface->rect.left, surface->rect.bottom - src->bottom, 0, surface->rect.bottom - surface->rect.top, bits, info, DIB_RGB_COLORS ); - surface->funcs->unlock( surface ); + window_surface_unlock( surface ); ReleaseDC( hwnd, hdc ); }
diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 902f5980d13..53b0ef5a11e 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -652,26 +652,6 @@ static void apply_line_region( DWORD *dst, int width, int x, int y, const RECT * if (width > 0) memset( dst, 0, width * sizeof(*dst) ); }
-/*********************************************************************** - * android_surface_lock - */ -static void CDECL android_surface_lock( struct window_surface *window_surface ) -{ - struct android_window_surface *surface = get_android_surface( window_surface ); - - EnterCriticalSection( &surface->header.cs ); -} - -/*********************************************************************** - * android_surface_unlock - */ -static void CDECL android_surface_unlock( struct window_surface *window_surface ) -{ - struct android_window_surface *surface = get_android_surface( window_surface ); - - LeaveCriticalSection( &surface->header.cs ); -} - /*********************************************************************** * android_surface_get_bitmap_info */ @@ -702,7 +682,7 @@ static void CDECL android_surface_set_region( struct window_surface *window_surf
TRACE( "updating surface %p hwnd %p with %p\n", surface, surface->hwnd, region );
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); if (!region) { if (surface->region) DeleteObject( surface->region ); @@ -713,7 +693,7 @@ static void CDECL android_surface_set_region( struct window_surface *window_surf if (!surface->region) surface->region = CreateRectRgn( 0, 0, 0, 0 ); CombineRgn( surface->region, region, 0, RGN_COPY ); } - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); set_surface_region( &surface->header, (HRGN)1 ); }
@@ -728,12 +708,12 @@ static void CDECL android_surface_flush( struct window_surface *window_surface ) RECT rect; BOOL needs_flush;
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); SetRect( &rect, 0, 0, surface->header.rect.right - surface->header.rect.left, surface->header.rect.bottom - surface->header.rect.top ); needs_flush = IntersectRect( &rect, &rect, &surface->bounds ); reset_bounds( &surface->bounds ); - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); if (!needs_flush) return;
TRACE( "flushing %p hwnd %p surface %s rect %s bits %p alpha %02x key %08x region %u rects\n", @@ -820,8 +800,8 @@ static void CDECL android_surface_destroy( struct window_surface *window_surface
static const struct window_surface_funcs android_surface_funcs = { - android_surface_lock, - android_surface_unlock, + NULL, + NULL, android_surface_get_bitmap_info, android_surface_get_bounds, android_surface_set_region, @@ -893,11 +873,11 @@ static void set_surface_region( struct window_surface *window_surface, HRGN win_ }
done: - window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); HeapFree( GetProcessHeap(), 0, surface->region_data ); surface->region_data = data; *window_surface->funcs->get_bounds( window_surface ) = surface->header.rect; - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); if (region != win_region) DeleteObject( region ); }
@@ -956,14 +936,14 @@ static void set_surface_layered( struct window_surface *window_surface, BYTE alp
if (window_surface->funcs != &android_surface_funcs) return; /* we may get the null surface */
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); prev_key = surface->color_key; prev_alpha = surface->alpha; surface->alpha = alpha; set_color_key( surface, color_key ); if (alpha != prev_alpha || surface->color_key != prev_key) /* refresh */ *window_surface->funcs->get_bounds( window_surface ) = surface->header.rect; - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); }
/*********************************************************************** @@ -1582,7 +1562,7 @@ BOOL CDECL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO
SelectObject( hdc, dib );
- surface->funcs->lock( surface ); + window_surface_lock( surface );
if (info->prcDirty) { @@ -1604,7 +1584,7 @@ BOOL CDECL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO add_bounds_rect( surface->funcs->get_bounds( surface ), &rect ); }
- surface->funcs->unlock( surface ); + window_surface_unlock( surface ); surface->funcs->flush( surface );
done: @@ -1634,9 +1614,9 @@ LRESULT CDECL ANDROID_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) struct window_surface *surface = data->surface; if (surface) { - surface->funcs->lock( surface ); + window_surface_lock( surface ); *surface->funcs->get_bounds( surface ) = surface->rect; - surface->funcs->unlock( surface ); + window_surface_unlock( surface ); if (is_argb_surface( surface )) surface->funcs->flush( surface ); } release_win_data( data ); diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index 7be1b6850e0..65bbe31b89d 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -144,7 +144,7 @@ static void CDECL macdrv_surface_set_region(struct window_surface *window_surfac
TRACE("updating surface %p with %p\n", surface, region);
- window_surface->funcs->lock(window_surface); + window_surface_lock(window_surface);
if (region) { @@ -158,7 +158,7 @@ static void CDECL macdrv_surface_set_region(struct window_surface *window_surfac } update_blit_data(surface);
- window_surface->funcs->unlock(window_surface); + window_surface_unlock(window_surface); }
/*********************************************************************** @@ -170,7 +170,7 @@ static void CDECL macdrv_surface_flush(struct window_surface *window_surface) CGRect rect; HRGN region;
- window_surface->funcs->lock(window_surface); + window_surface_lock(window_surface);
TRACE("flushing %p %s bounds %s bits %p\n", surface, wine_dbgstr_rect(&surface->header.rect), wine_dbgstr_rect(&surface->bounds), surface->bits); @@ -191,7 +191,7 @@ static void CDECL macdrv_surface_flush(struct window_surface *window_surface) update_blit_data(surface); reset_bounds(&surface->bounds);
- window_surface->funcs->unlock(window_surface); + window_surface_unlock(window_surface);
if (!CGRectIsEmpty(rect)) macdrv_window_needs_display(surface->window, rect); @@ -428,7 +428,7 @@ void surface_clip_to_visible_rect(struct window_surface *window_surface, const R struct macdrv_window_surface *surface = get_mac_surface(window_surface);
if (!surface) return; - window_surface->funcs->lock(window_surface); + window_surface_lock(window_surface);
if (surface->drawn) { @@ -447,5 +447,5 @@ void surface_clip_to_visible_rect(struct window_surface *window_surface, const R } }
- window_surface->funcs->unlock(window_surface); + window_surface_unlock(window_surface); } diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index e7f5327fcdc..f2f53520e31 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -507,10 +507,10 @@ static void sync_window_opacity(struct macdrv_win_data *data, COLORREF key, BYTE
rect = data->whole_rect; OffsetRect(&rect, -data->whole_rect.left, -data->whole_rect.top); - data->surface->funcs->lock(data->surface); + window_surface_lock(data->surface); bounds = data->surface->funcs->get_bounds(data->surface); add_bounds_rect(bounds, &rect); - data->surface->funcs->unlock(data->surface); + window_surface_unlock(data->surface); } }
@@ -1938,9 +1938,9 @@ BOOL CDECL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO * if (info->prcDirty) { IntersectRect(&rect, &rect, info->prcDirty); - surface->funcs->lock(surface); + window_surface_lock(surface); memcpy(src_bits, dst_bits, bmi->bmiHeader.biSizeImage); - surface->funcs->unlock(surface); + window_surface_unlock(surface); PatBlt(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, BLACKNESS); } src_rect = rect; @@ -1957,10 +1957,10 @@ BOOL CDECL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO * { if (surface == data->surface) { - surface->funcs->lock(surface); + window_surface_lock(surface); memcpy(dst_bits, src_bits, bmi->bmiHeader.biSizeImage); add_bounds_rect(surface->funcs->get_bounds(surface), &rect); - surface->funcs->unlock(surface); + window_surface_unlock(surface); surface->funcs->flush(surface); }
diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index b931fd88da3..731be11a181 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1813,26 +1813,6 @@ failed: } #endif /* HAVE_LIBXXSHM */
-/*********************************************************************** - * x11drv_surface_lock - */ -static void CDECL x11drv_surface_lock( struct window_surface *window_surface ) -{ - struct x11drv_window_surface *surface = get_x11_surface( window_surface ); - - EnterCriticalSection( &surface->header.cs ); -} - -/*********************************************************************** - * x11drv_surface_unlock - */ -static void CDECL x11drv_surface_unlock( struct window_surface *window_surface ) -{ - struct x11drv_window_surface *surface = get_x11_surface( window_surface ); - - LeaveCriticalSection( &surface->header.cs ); -} - /*********************************************************************** * x11drv_surface_get_bitmap_info */ @@ -1864,7 +1844,7 @@ static void CDECL x11drv_surface_set_region( struct window_surface *window_surfa
TRACE( "updating surface %p with %p\n", surface, region );
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); if (!region) { if (surface->region) DeleteObject( surface->region ); @@ -1882,7 +1862,7 @@ static void CDECL x11drv_surface_set_region( struct window_surface *window_surfa HeapFree( GetProcessHeap(), 0, data ); } } - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); }
/*********************************************************************** @@ -1895,7 +1875,7 @@ static void CDECL x11drv_surface_flush( struct window_surface *window_surface ) unsigned char *dst = (unsigned char *)surface->image->data; struct bitblt_coords coords;
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); coords.x = 0; coords.y = 0; coords.width = surface->header.rect.right - surface->header.rect.left; @@ -1949,7 +1929,7 @@ static void CDECL x11drv_surface_flush( struct window_surface *window_surface ) XFlush( gdi_display ); } reset_bounds( &surface->bounds ); - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); }
/*********************************************************************** @@ -1984,8 +1964,8 @@ static void CDECL x11drv_surface_destroy( struct window_surface *window_surface
static const struct window_surface_funcs x11drv_surface_funcs = { - x11drv_surface_lock, - x11drv_surface_unlock, + NULL, + NULL, x11drv_surface_get_bitmap_info, x11drv_surface_get_bounds, x11drv_surface_set_region, @@ -2075,11 +2055,11 @@ void set_surface_color_key( struct window_surface *window_surface, COLORREF colo
if (window_surface->funcs != &x11drv_surface_funcs) return; /* we may get the null surface */
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); prev = surface->color_key; set_color_key( surface, color_key ); if (surface->color_key != prev) update_surface_region( surface ); - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); }
/*********************************************************************** @@ -2093,7 +2073,7 @@ HRGN expose_surface( struct window_surface *window_surface, const RECT *rect )
if (window_surface->funcs != &x11drv_surface_funcs) return 0; /* we may get the null surface */
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); OffsetRect( &rc, -window_surface->rect.left, -window_surface->rect.top ); add_bounds_rect( &surface->bounds, &rc ); if (surface->region) @@ -2105,6 +2085,6 @@ HRGN expose_surface( struct window_surface *window_surface, const RECT *rect ) region = 0; } } - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); return region; } diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index b3ae5c54408..c79305963b9 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2742,7 +2742,7 @@ BOOL CDECL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO
SelectObject( hdc, dib );
- surface->funcs->lock( surface ); + window_surface_lock( surface );
if (info->prcDirty) { @@ -2764,7 +2764,7 @@ BOOL CDECL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO add_bounds_rect( surface->funcs->get_bounds( surface ), &rect ); }
- surface->funcs->unlock( surface ); + window_surface_unlock( surface ); surface->funcs->flush( surface );
done: diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 6c700664eb5..0667b3758a3 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -268,6 +268,18 @@ static inline ULONG window_surface_release( struct window_surface *surface ) return ret; }
+static inline void window_surface_lock( struct window_surface *surface ) +{ + if (surface->funcs->lock) surface->funcs->lock( surface ); + else EnterCriticalSection( &surface->cs ); +} + +static inline void window_surface_unlock( struct window_surface *surface ) +{ + if (surface->funcs->unlock) surface->funcs->unlock( surface ); + else LeaveCriticalSection( &surface->cs ); +} + /* the DC hook support is only exported on Win16, the 32-bit version is a Wine extension */
#define DCHC_INVALIDVISRGN 0x0001
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=90111
Your paranoid android.
=== debiant2 (64 bit WoW report) ===
gdi32: clipping.c:474: Test failed: expected (-640,0)-(640,480), got (0,0)-(1280,480) clipping.c:493: Test failed: expected (-640,0)-(640,480), got (0,0)-(1280,480) dc.c:1598: Test failed: expected (-640,0)-(640,480), got (0,0)-(1280,480) dc.c:1606: Test failed: expected (-640,0)-(640,480), got (0,0)-(1280,480) dc.c:1612: Test failed: expected (-640,0)-(640,480), got (0,0)-(1280,480)
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/gdi.exe16/gdi.c | 3 +-- dlls/wineandroid.drv/window.c | 9 ++++----- dlls/winemac.drv/surface.c | 13 ++++++------- dlls/winex11.drv/bitblt.c | 13 ++++++------- include/wine/gdi_driver.h | 1 + 5 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/dlls/gdi.exe16/gdi.c b/dlls/gdi.exe16/gdi.c index 9afa4532fde..2a0b245e190 100644 --- a/dlls/gdi.exe16/gdi.c +++ b/dlls/gdi.exe16/gdi.c @@ -435,7 +435,6 @@ static void free_segptr_bits( HBITMAP16 bmp ) struct dib_window_surface { struct window_surface header; - RECT bounds; void *bits; UINT info_size; BITMAPINFO info; /* variable size, must be last */ @@ -480,7 +479,7 @@ static RECT *CDECL dib_surface_get_bounds( struct window_surface *window_surface { struct dib_window_surface *surface = get_dib_surface( window_surface );
- return &surface->bounds; + return &surface->header.bounds; }
/*********************************************************************** diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 53b0ef5a11e..0f84a186d5d 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -580,7 +580,6 @@ struct android_window_surface struct window_surface header; HWND hwnd; ANativeWindow *window; - RECT bounds; BOOL byteswap; RGNDATA *region_data; HRGN region; @@ -670,7 +669,7 @@ static RECT *CDECL android_surface_get_bounds( struct window_surface *window_sur { struct android_window_surface *surface = get_android_surface( window_surface );
- return &surface->bounds; + return &surface->header.bounds; }
/*********************************************************************** @@ -711,8 +710,8 @@ static void CDECL android_surface_flush( struct window_surface *window_surface ) window_surface_lock( window_surface ); SetRect( &rect, 0, 0, surface->header.rect.right - surface->header.rect.left, surface->header.rect.bottom - surface->header.rect.top ); - needs_flush = IntersectRect( &rect, &rect, &surface->bounds ); - reset_bounds( &surface->bounds ); + needs_flush = IntersectRect( &rect, &rect, &surface->header.bounds ); + reset_bounds( &surface->header.bounds ); window_surface_unlock( window_surface ); if (!needs_flush) return;
@@ -910,7 +909,7 @@ static struct window_surface *create_surface( HWND hwnd, const RECT *rect, surface->alpha = alpha; set_color_key( surface, color_key ); set_surface_region( &surface->header, (HRGN)1 ); - reset_bounds( &surface->bounds ); + reset_bounds( &surface->header.bounds );
if (!(surface->bits = HeapAlloc( GetProcessHeap(), 0, surface->info.bmiHeader.biSizeImage ))) goto failed; diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index 65bbe31b89d..757a0b16cca 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -60,7 +60,6 @@ struct macdrv_window_surface { struct window_surface header; macdrv_window window; - RECT bounds; HRGN region; HRGN drawn; BOOL use_alpha; @@ -132,7 +131,7 @@ static RECT *CDECL macdrv_surface_get_bounds(struct window_surface *window_surfa { struct macdrv_window_surface *surface = get_mac_surface(window_surface);
- return &surface->bounds; + return &surface->header.bounds; }
/*********************************************************************** @@ -173,12 +172,12 @@ static void CDECL macdrv_surface_flush(struct window_surface *window_surface) window_surface_lock(window_surface);
TRACE("flushing %p %s bounds %s bits %p\n", surface, wine_dbgstr_rect(&surface->header.rect), - wine_dbgstr_rect(&surface->bounds), surface->bits); + wine_dbgstr_rect(&surface->header.bounds), surface->bits);
- rect = cgrect_from_rect(surface->bounds); + rect = cgrect_from_rect(surface->header.bounds); rect = CGRectOffset(rect, surface->header.rect.left, surface->header.rect.top);
- if (!IsRectEmpty(&surface->bounds) && (region = CreateRectRgnIndirect(&surface->bounds))) + if (!IsRectEmpty(&surface->header.bounds) && (region = CreateRectRgnIndirect(&surface->header.bounds))) { if (surface->drawn) { @@ -189,7 +188,7 @@ static void CDECL macdrv_surface_flush(struct window_surface *window_surface) surface->drawn = region; } update_blit_data(surface); - reset_bounds(&surface->bounds); + reset_bounds(&surface->header.bounds);
window_surface_unlock(window_surface);
@@ -280,7 +279,7 @@ struct window_surface *create_surface(macdrv_window window, const RECT *rect, surface->header.rect = *rect; surface->header.ref = 1; surface->window = window; - reset_bounds(&surface->bounds); + reset_bounds(&surface->header.bounds); if (old_mac_surface && old_mac_surface->drawn) { surface->drawn = CreateRectRgnIndirect(rect); diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 731be11a181..44bdb02deb6 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1563,7 +1563,6 @@ struct x11drv_window_surface Window window; GC gc; XImage *image; - RECT bounds; BOOL byteswap; BOOL is_argb; DWORD alpha_bits; @@ -1831,7 +1830,7 @@ static RECT *CDECL x11drv_surface_get_bounds( struct window_surface *window_surf { struct x11drv_window_surface *surface = get_x11_surface( window_surface );
- return &surface->bounds; + return &surface->header.bounds; }
/*********************************************************************** @@ -1881,11 +1880,11 @@ static void CDECL x11drv_surface_flush( struct window_surface *window_surface ) coords.width = surface->header.rect.right - surface->header.rect.left; coords.height = surface->header.rect.bottom - surface->header.rect.top; SetRect( &coords.visrect, 0, 0, coords.width, coords.height ); - if (IntersectRect( &coords.visrect, &coords.visrect, &surface->bounds )) + if (IntersectRect( &coords.visrect, &coords.visrect, &surface->header.bounds )) { TRACE( "flushing %p %dx%d bounds %s bits %p\n", surface, coords.width, coords.height, - wine_dbgstr_rect( &surface->bounds ), surface->bits ); + wine_dbgstr_rect( &surface->header.bounds ), surface->bits );
if (surface->is_argb || surface->color_key != CLR_INVALID) update_surface_region( surface );
@@ -1928,7 +1927,7 @@ static void CDECL x11drv_surface_flush( struct window_surface *window_surface ) coords.visrect.bottom - coords.visrect.top ); XFlush( gdi_display ); } - reset_bounds( &surface->bounds ); + reset_bounds( &surface->header.bounds ); window_surface_unlock( window_surface ); }
@@ -2004,7 +2003,7 @@ struct window_surface *create_surface( Window window, const XVisualInfo *vis, co surface->window = window; surface->is_argb = (use_alpha && vis->depth == 32 && surface->info.bmiHeader.biCompression == BI_RGB); set_color_key( surface, color_key ); - reset_bounds( &surface->bounds ); + reset_bounds( &surface->header.bounds );
#ifdef HAVE_LIBXXSHM surface->image = create_shm_image( vis, width, height, &surface->shminfo ); @@ -2075,7 +2074,7 @@ HRGN expose_surface( struct window_surface *window_surface, const RECT *rect )
window_surface_lock( window_surface ); OffsetRect( &rc, -window_surface->rect.left, -window_surface->rect.top ); - add_bounds_rect( &surface->bounds, &rc ); + add_bounds_rect( &surface->header.bounds, &rc ); if (surface->region) { region = CreateRectRgnIndirect( rect ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 0667b3758a3..8cc69521505 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -253,6 +253,7 @@ struct window_surface LONG ref; /* reference count */ RECT rect; /* constant, no locking needed */ CRITICAL_SECTION cs; /* critical section for locking */ + RECT bounds; /* access requires locking */ /* driver-specific fields here */ };
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/gdi.exe16/gdi.c | 11 ----------- dlls/gdi32/dibdrv/dc.c | 2 +- dlls/user32/win.c | 7 ------- dlls/wineandroid.drv/window.c | 19 ++++--------------- dlls/winemac.drv/surface.c | 11 ----------- dlls/winemac.drv/window.c | 6 ++---- dlls/winex11.drv/bitblt.c | 11 ----------- dlls/winex11.drv/window.c | 2 +- include/wine/gdi_driver.h | 1 - 9 files changed, 8 insertions(+), 62 deletions(-)
diff --git a/dlls/gdi.exe16/gdi.c b/dlls/gdi.exe16/gdi.c index 2a0b245e190..f03c8c6fad0 100644 --- a/dlls/gdi.exe16/gdi.c +++ b/dlls/gdi.exe16/gdi.c @@ -472,16 +472,6 @@ static void *CDECL dib_surface_get_bitmap_info( struct window_surface *window_su return surface->bits; }
-/*********************************************************************** - * dib_surface_get_bounds - */ -static RECT *CDECL dib_surface_get_bounds( struct window_surface *window_surface ) -{ - struct dib_window_surface *surface = get_dib_surface( window_surface ); - - return &surface->header.bounds; -} - /*********************************************************************** * dib_surface_set_region */ @@ -514,7 +504,6 @@ static const struct window_surface_funcs dib_surface_funcs = dib_surface_lock, dib_surface_unlock, dib_surface_get_bitmap_info, - dib_surface_get_bounds, dib_surface_set_region, dib_surface_flush, dib_surface_destroy diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c index f8b26dc2b8e..1efd4228729 100644 --- a/dlls/gdi32/dibdrv/dc.c +++ b/dlls/gdi32/dibdrv/dc.c @@ -832,7 +832,7 @@ void dibdrv_set_window_surface( DC *dc, struct window_surface *surface ) init_dib_info_from_bitmapinfo( &dibdrv->dib, info, bits ); dibdrv->dib.rect = dc->vis_rect; offset_rect( &dibdrv->dib.rect, -dc->device_rect.left, -dc->device_rect.top ); - dibdrv->bounds = surface->funcs->get_bounds( surface ); + dibdrv->bounds = &surface->bounds; DC_InitDC( dc ); } else if (windev) diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 680defc2071..279d389f67c 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -556,12 +556,6 @@ static void *CDECL dummy_surface_get_bitmap_info( struct window_surface *window_ return &dummy_data; }
-static RECT *CDECL dummy_surface_get_bounds( struct window_surface *window_surface ) -{ - static RECT dummy_bounds; - return &dummy_bounds; -} - static void CDECL dummy_surface_set_region( struct window_surface *window_surface, HRGN region ) { /* nothing to do */ @@ -582,7 +576,6 @@ static const struct window_surface_funcs dummy_surface_funcs = dummy_surface_lock, dummy_surface_unlock, dummy_surface_get_bitmap_info, - dummy_surface_get_bounds, dummy_surface_set_region, dummy_surface_flush, dummy_surface_destroy diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 0f84a186d5d..f7373740c92 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -662,16 +662,6 @@ static void *CDECL android_surface_get_bitmap_info( struct window_surface *windo return surface->bits; }
-/*********************************************************************** - * android_surface_get_bounds - */ -static RECT *CDECL android_surface_get_bounds( struct window_surface *window_surface ) -{ - struct android_window_surface *surface = get_android_surface( window_surface ); - - return &surface->header.bounds; -} - /*********************************************************************** * android_surface_set_region */ @@ -802,7 +792,6 @@ static const struct window_surface_funcs android_surface_funcs = NULL, NULL, android_surface_get_bitmap_info, - android_surface_get_bounds, android_surface_set_region, android_surface_flush, android_surface_destroy @@ -875,7 +864,7 @@ done: window_surface_lock( window_surface ); HeapFree( GetProcessHeap(), 0, surface->region_data ); surface->region_data = data; - *window_surface->funcs->get_bounds( window_surface ) = surface->header.rect; + window_surface->bounds = surface->header.rect; window_surface_unlock( window_surface ); if (region != win_region) DeleteObject( region ); } @@ -941,7 +930,7 @@ static void set_surface_layered( struct window_surface *window_surface, BYTE alp surface->alpha = alpha; set_color_key( surface, color_key ); if (alpha != prev_alpha || surface->color_key != prev_key) /* refresh */ - *window_surface->funcs->get_bounds( window_surface ) = surface->header.rect; + window_surface->bounds = surface->header.rect; window_surface_unlock( window_surface ); }
@@ -1580,7 +1569,7 @@ BOOL CDECL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO if (ret) { memcpy( dst_bits, src_bits, bmi->bmiHeader.biSizeImage ); - add_bounds_rect( surface->funcs->get_bounds( surface ), &rect ); + add_bounds_rect( &surface->funcs->bounds, &rect ); }
window_surface_unlock( surface ); @@ -1614,7 +1603,7 @@ LRESULT CDECL ANDROID_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) if (surface) { window_surface_lock( surface ); - *surface->funcs->get_bounds( surface ) = surface->rect; + surface->bounds = surface->rect; window_surface_unlock( surface ); if (is_argb_surface( surface )) surface->funcs->flush( surface ); } diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index 757a0b16cca..abbddd04770 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -124,16 +124,6 @@ static void *CDECL macdrv_surface_get_bitmap_info(struct window_surface *window_ return surface->bits; }
-/*********************************************************************** - * macdrv_surface_get_bounds - */ -static RECT *CDECL macdrv_surface_get_bounds(struct window_surface *window_surface) -{ - struct macdrv_window_surface *surface = get_mac_surface(window_surface); - - return &surface->header.bounds; -} - /*********************************************************************** * macdrv_surface_set_region */ @@ -217,7 +207,6 @@ static const struct window_surface_funcs macdrv_surface_funcs = macdrv_surface_lock, macdrv_surface_unlock, macdrv_surface_get_bitmap_info, - macdrv_surface_get_bounds, macdrv_surface_set_region, macdrv_surface_flush, macdrv_surface_destroy, diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index f2f53520e31..f23ac161244 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -502,14 +502,12 @@ static void sync_window_opacity(struct macdrv_win_data *data, COLORREF key, BYTE
if (needs_flush && data->surface) { - RECT *bounds; RECT rect;
rect = data->whole_rect; OffsetRect(&rect, -data->whole_rect.left, -data->whole_rect.top); window_surface_lock(data->surface); - bounds = data->surface->funcs->get_bounds(data->surface); - add_bounds_rect(bounds, &rect); + add_bounds_rect(&data->surface->bounds, &rect); window_surface_unlock(data->surface); } } @@ -1959,7 +1957,7 @@ BOOL CDECL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO * { window_surface_lock(surface); memcpy(dst_bits, src_bits, bmi->bmiHeader.biSizeImage); - add_bounds_rect(surface->funcs->get_bounds(surface), &rect); + add_bounds_rect(&surface->bounds, &rect); window_surface_unlock(surface); surface->funcs->flush(surface); } diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 44bdb02deb6..c5eec646159 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1823,16 +1823,6 @@ static void *CDECL x11drv_surface_get_bitmap_info( struct window_surface *window return surface->bits; }
-/*********************************************************************** - * x11drv_surface_get_bounds - */ -static RECT *CDECL x11drv_surface_get_bounds( struct window_surface *window_surface ) -{ - struct x11drv_window_surface *surface = get_x11_surface( window_surface ); - - return &surface->header.bounds; -} - /*********************************************************************** * x11drv_surface_set_region */ @@ -1966,7 +1956,6 @@ static const struct window_surface_funcs x11drv_surface_funcs = NULL, NULL, x11drv_surface_get_bitmap_info, - x11drv_surface_get_bounds, x11drv_surface_set_region, x11drv_surface_flush, x11drv_surface_destroy diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index c79305963b9..51078020c2f 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2761,7 +2761,7 @@ BOOL CDECL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO if (ret) { memcpy( dst_bits, src_bits, bmi->bmiHeader.biSizeImage ); - add_bounds_rect( surface->funcs->get_bounds( surface ), &rect ); + add_bounds_rect( &surface->bounds, &rect ); }
window_surface_unlock( surface ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 8cc69521505..c8837c874bf 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -240,7 +240,6 @@ struct window_surface_funcs void (CDECL *lock)( struct window_surface *surface ); void (CDECL *unlock)( struct window_surface *surface ); void* (CDECL *get_info)( struct window_surface *surface, BITMAPINFO *info ); - RECT* (CDECL *get_bounds)( struct window_surface *surface ); void (CDECL *set_region)( struct window_surface *surface, HRGN region ); void (CDECL *flush)( struct window_surface *surface ); void (CDECL *destroy)( struct window_surface *surface );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=90113
Your paranoid android.
=== debiant2 (32 bit Chinese:China report) ===
gdi32: clipping.c:474: Test failed: expected (-640,0)-(640,720), got (0,0)-(1280,720) clipping.c:493: Test failed: expected (-640,0)-(640,720), got (0,0)-(1280,720) dc.c:1598: Test failed: expected (-640,0)-(640,720), got (0,0)-(1280,720) dc.c:1606: Test failed: expected (-640,0)-(640,720), got (0,0)-(1280,720) dc.c:1612: Test failed: expected (-640,0)-(640,720), got (0,0)-(1280,720)
=== debiant2 (64 bit WoW report) ===
gdi32: clipping.c:474: Test failed: expected (-640,0)-(640,480), got (0,0)-(1280,480) clipping.c:493: Test failed: expected (-640,0)-(640,480), got (0,0)-(1280,480) dc.c:1598: Test failed: expected (-640,0)-(640,480), got (0,0)-(1280,480) dc.c:1606: Test failed: expected (-640,0)-(640,480), got (0,0)-(1280,480) dc.c:1612: Test failed: expected (-640,0)-(640,480), got (0,0)-(1280,480)
user32: win.c:10155: Test failed: Expected foreground window 0, got 0000000001030050 win.c:10161: Test failed: Expected foreground window 00000000000E0120, got 0000000001030050 win.c:10178: Test failed: Expected foreground window 00000000000E0120, got 0000000000000000
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/driver.c | 3 +- dlls/user32/user_private.h | 3 +- dlls/user32/win.c | 107 ++++++++++++++++++++++++++++++++++ dlls/user32/winpos.c | 13 ++++- dlls/wineandroid.drv/window.c | 9 +-- dlls/winemac.drv/window.c | 5 +- dlls/winex11.drv/window.c | 7 ++- 7 files changed, 134 insertions(+), 13 deletions(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index 1c3b62eff2b..5f66ea6218e 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -375,10 +375,11 @@ static LRESULT CDECL nulldrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, return 0; }
-static void CDECL nulldrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags, +static BOOL CDECL nulldrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags, const RECT *window_rect, const RECT *client_rect, RECT *visible_rect, struct window_surface **surface ) { + return FALSE; }
static void CDECL nulldrv_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags, diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index db082462f1b..3afb2111957 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -105,7 +105,7 @@ typedef struct tagUSER_DRIVER { LRESULT (CDECL *pSysCommand)(HWND,WPARAM,LPARAM); BOOL (CDECL *pUpdateLayeredWindow)(HWND,const UPDATELAYEREDWINDOWINFO *,const RECT *); LRESULT (CDECL *pWindowMessage)(HWND,UINT,WPARAM,LPARAM); - void (CDECL *pWindowPosChanging)(HWND,HWND,UINT,const RECT *,const RECT *,RECT *,struct window_surface**); + BOOL (CDECL *pWindowPosChanging)(HWND,HWND,UINT,const RECT *,const RECT *,RECT *,struct window_surface**); void (CDECL *pWindowPosChanged)(HWND,HWND,UINT,const RECT *,const RECT *,const RECT *,const RECT *,struct window_surface*); /* system parameters */ BOOL (CDECL *pSystemParametersInfo)(UINT,UINT,void*,UINT); @@ -242,6 +242,7 @@ extern BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hard extern struct rawinput_thread_data *rawinput_thread_data(void);
extern void keyboard_init(void) DECLSPEC_HIDDEN; +extern void create_default_window_surface( const RECT *visible_rect, struct window_surface **surface ) DECLSPEC_HIDDEN;
extern void CLIPBOARD_ReleaseOwner( HWND hwnd ) DECLSPEC_HIDDEN; extern BOOL FOCUS_MouseActivate( HWND hwnd ) DECLSPEC_HIDDEN; diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 279d389f67c..6c2233c6e8b 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -22,6 +22,7 @@ #include <stdarg.h> #include <stdlib.h> #include <string.h> +#include <limits.h>
#include "windef.h" #include "winbase.h" @@ -583,6 +584,112 @@ static const struct window_surface_funcs dummy_surface_funcs =
struct window_surface dummy_surface = { &dummy_surface_funcs, { NULL, NULL }, 1, { 0, 0, 1, 1 } };
+/******************************************************************* + * Off-screen default window surface. + */ + +struct default_window_surface +{ + struct window_surface header; + char *bits; + BITMAPINFO info; +}; + +static const struct window_surface_funcs default_window_surface_funcs; + +static inline void reset_bounds( RECT *bounds ) +{ + bounds->left = bounds->top = INT_MAX; + bounds->right = bounds->bottom = INT_MIN; +} + +static struct default_window_surface *impl_from_window_surface( struct window_surface *base ) +{ + if (base->funcs != &default_window_surface_funcs) return NULL; + return CONTAINING_RECORD( base, struct default_window_surface, header ); +} + +static void *CDECL default_window_surface_get_bitmap_info( struct window_surface *base, BITMAPINFO *info ) +{ + struct default_window_surface *impl = impl_from_window_surface( base ); + memcpy( info, &impl->info, offsetof( BITMAPINFO, bmiColors[0] ) ); + return impl->bits; +} + +static void CDECL default_window_surface_set_region( struct window_surface *base, HRGN region ) +{ +} + +static void CDECL default_window_surface_flush( struct window_surface *base ) +{ + struct default_window_surface *impl = impl_from_window_surface( base ); + window_surface_lock( base ); + reset_bounds( &impl->header.bounds ); + window_surface_unlock( base ); +} + +static void CDECL default_window_surface_destroy( struct window_surface *base ) +{ + struct default_window_surface *impl = impl_from_window_surface( base ); + impl->header.cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection( &impl->header.cs ); + free( impl ); +} + +static const struct window_surface_funcs default_window_surface_funcs = +{ + NULL, + NULL, + default_window_surface_get_bitmap_info, + default_window_surface_set_region, + default_window_surface_flush, + default_window_surface_destroy +}; + +void create_default_window_surface( const RECT *visible_rect, struct window_surface **surface ) +{ + struct default_window_surface *impl = NULL; + struct window_surface *base; + SIZE_T size; + RECT surface_rect = *visible_rect; + + TRACE( "visible_rect %s, surface %p.\n", wine_dbgstr_rect( visible_rect ), surface ); + + OffsetRect( &surface_rect, -surface_rect.left, -surface_rect.top ); + size = surface_rect.right * surface_rect.bottom * 4; + + /* check that old surface is an default_window_surface, or release it */ + if ((base = *surface) && !(impl = impl_from_window_surface( base ))) window_surface_release( base ); + + /* if the rect didn't change, keep the same surface */ + if (impl && EqualRect( &surface_rect, &impl->header.rect )) return; + + /* create a new window surface */ + *surface = NULL; + if (impl) window_surface_release( &impl->header ); + if (!(impl = calloc(1, offsetof( struct default_window_surface, info.bmiColors[0] ) + size))) return; + + impl->header.funcs = &default_window_surface_funcs; + impl->header.ref = 1; + impl->header.rect = surface_rect; + + InitializeCriticalSection( &impl->header.cs ); + impl->header.cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": surface"); + reset_bounds( &impl->header.bounds ); + + impl->bits = (char *)&impl->info.bmiColors[0]; + impl->info.bmiHeader.biSize = sizeof( impl->info ); + impl->info.bmiHeader.biWidth = surface_rect.right; + impl->info.bmiHeader.biHeight = surface_rect.bottom; + impl->info.bmiHeader.biPlanes = 1; + impl->info.bmiHeader.biBitCount = 32; + impl->info.bmiHeader.biCompression = BI_RGB; + impl->info.bmiHeader.biSizeImage = size; + + TRACE( "created window surface %p\n", &impl->header ); + + *surface = &impl->header; +}
/******************************************************************* * register_window_surface diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index c6f806f7beb..f3f7bffbf97 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -2103,8 +2103,8 @@ BOOL set_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, window_surface_add_ref( new_surface ); } visible_rect = *window_rect; - USER_Driver->pWindowPosChanging( hwnd, insert_after, swp_flags, - window_rect, client_rect, &visible_rect, &new_surface ); + ret = USER_Driver->pWindowPosChanging( hwnd, insert_after, swp_flags, + window_rect, client_rect, &visible_rect, &new_surface );
WIN_GetRectangles( hwnd, COORDS_SCREEN, &old_window_rect, NULL ); if (IsRectEmpty( &valid_rects[0] )) valid_rects = NULL; @@ -2114,6 +2114,15 @@ BOOL set_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, if (new_surface) window_surface_release( new_surface ); return FALSE; } + + /* create or update window surface if driver didn't */ + if (!ret && new_surface && (!(GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED) || GetLayeredWindowAttributes( hwnd, NULL, NULL, NULL ))) + { + window_surface_release(new_surface); + if ((new_surface = win->surface)) window_surface_add_ref( new_surface ); + create_default_window_surface( &visible_rect, &new_surface ); + } + old_visible_rect = win->visible_rect; old_client_rect = win->client_rect; old_surface = win->surface; diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index f7373740c92..4c3d2553b08 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -1258,9 +1258,9 @@ static inline BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rec /*********************************************************************** * ANDROID_WindowPosChanging */ -void CDECL ANDROID_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags, - const RECT *window_rect, const RECT *client_rect, RECT *visible_rect, - struct window_surface **surface ) +BOOL CDECL ANDROID_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags, + const RECT *window_rect, const RECT *client_rect, RECT *visible_rect, + struct window_surface **surface ) { struct android_win_data *data = get_win_data( hwnd ); RECT surface_rect; @@ -1273,7 +1273,7 @@ void CDECL ANDROID_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_fla hwnd, wine_dbgstr_rect(window_rect), wine_dbgstr_rect(client_rect), GetWindowLongW( hwnd, GWL_STYLE ), swp_flags );
- if (!data && !(data = create_win_data( hwnd, window_rect, client_rect ))) return; + if (!data && !(data = create_win_data( hwnd, window_rect, client_rect ))) return TRUE;
*visible_rect = *window_rect;
@@ -1306,6 +1306,7 @@ void CDECL ANDROID_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_fla
done: release_win_data( data ); + return TRUE; }
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index f23ac161244..7dfae0ddb23 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -2051,7 +2051,7 @@ static inline RECT get_surface_rect(const RECT *visible_rect) /*********************************************************************** * WindowPosChanging (MACDRV.@) */ -void CDECL macdrv_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags, +BOOL CDECL macdrv_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags, const RECT *window_rect, const RECT *client_rect, RECT *visible_rect, struct window_surface **surface) { @@ -2063,7 +2063,7 @@ void CDECL macdrv_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags swp_flags, wine_dbgstr_rect(window_rect), wine_dbgstr_rect(client_rect), wine_dbgstr_rect(visible_rect), surface);
- if (!data && !(data = macdrv_create_win_data(hwnd, window_rect, client_rect))) return; + if (!data && !(data = macdrv_create_win_data(hwnd, window_rect, client_rect))) return TRUE;
*visible_rect = *window_rect; macdrv_window_to_mac_rect(data, style, visible_rect, window_rect, client_rect); @@ -2096,6 +2096,7 @@ void CDECL macdrv_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags
done: release_win_data(data); + return TRUE; }
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 51078020c2f..31a84bd8567 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2318,7 +2318,7 @@ static inline BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rec /*********************************************************************** * WindowPosChanging (X11DRV.@) */ -void CDECL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags, +BOOL CDECL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags, const RECT *window_rect, const RECT *client_rect, RECT *visible_rect, struct window_surface **surface ) { @@ -2328,7 +2328,7 @@ void CDECL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flag COLORREF key; BOOL layered = GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED;
- if (!data && !(data = X11DRV_create_win_data( hwnd, window_rect, client_rect ))) return; + if (!data && !(data = X11DRV_create_win_data( hwnd, window_rect, client_rect ))) return TRUE;
/* check if we need to switch the window to managed */ if (!data->managed && data->whole_window && is_window_managed( hwnd, swp_flags, window_rect )) @@ -2336,7 +2336,7 @@ void CDECL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flag TRACE( "making win %p/%lx managed\n", hwnd, data->whole_window ); release_win_data( data ); unmap_window( hwnd ); - if (!(data = get_win_data( hwnd ))) return; + if (!(data = get_win_data( hwnd ))) return TRUE; data->managed = TRUE; }
@@ -2377,6 +2377,7 @@ void CDECL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flag
done: release_win_data( data ); + return TRUE; }