user32: DCX_NORESETATTRS should be applied at DC release time.

This commit is contained in:
Alexandre Julliard 2010-07-22 20:00:35 +02:00
parent e79af2f0d9
commit f1ea06375d
2 changed files with 17 additions and 13 deletions

View File

@ -167,6 +167,16 @@ static void update_visible_region( struct dce *dce )
}
/***********************************************************************
* reset_dce_attrs
*/
static void reset_dce_attrs( struct dce *dce )
{
RestoreDC( dce->hdc, 1 ); /* initial save level is always 1 */
SaveDC( dce->hdc ); /* save the state again for next time */
}
/***********************************************************************
* release_dce
*/
@ -329,6 +339,7 @@ void free_dce( struct dce *dce, HWND hwnd )
if (!--dce->count)
{
/* turn it into a cache entry */
reset_dce_attrs( dce );
release_dce( dce );
dce->flags |= DCX_CACHE;
}
@ -455,6 +466,7 @@ static INT release_dc( HWND hwnd, HDC hdc, BOOL end_paint )
dce = (struct dce *)GetDCHook( hdc, NULL );
if (dce && dce->count)
{
if (!(dce->flags & DCX_NORESETATTRS)) reset_dce_attrs( dce );
if (end_paint || (dce->flags & DCX_CACHE)) delete_clip_rgn( dce );
if (dce->flags & DCX_CACHE) dce->count = 0;
ret = TRUE;
@ -898,6 +910,7 @@ BOOL WINAPI EndPaint( HWND hwnd, const PAINTSTRUCT *lps )
HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
{
static const DWORD clip_flags = DCX_PARENTCLIP | DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_WINDOW;
static const DWORD user_flags = clip_flags | DCX_NORESETATTRS; /* flags that can be set by user */
struct dce *dce;
BOOL bUpdateVisRgn = TRUE;
HWND parent;
@ -1021,18 +1034,12 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
}
dce->hwnd = hwnd;
dce->flags = (dce->flags & ~clip_flags) | (flags & clip_flags);
dce->flags = (dce->flags & ~user_flags) | (flags & user_flags);
if (SetHookFlags( dce->hdc, DCHF_VALIDATEVISRGN )) bUpdateVisRgn = TRUE; /* DC was dirty */
if (bUpdateVisRgn) update_visible_region( dce );
if (!(flags & DCX_NORESETATTRS))
{
RestoreDC( dce->hdc, 1 ); /* initial save level is always 1 */
SaveDC( dce->hdc ); /* save the state again for next time */
}
TRACE("(%p,%p,0x%x): returning %p\n", hwnd, hrgnClip, flags, dce->hdc);
return dce->hdc;
}

View File

@ -66,10 +66,7 @@ static void test_dc_attributes(void)
hdc = hdcs[i] = GetDCEx( hwnd_cache, 0, DCX_USESTYLE | DCX_NORESETATTRS );
if (!hdc) break;
rop = GetROP2( hdc );
if (hdc == old_hdc)
todo_wine ok( rop == def_rop, "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc );
else
ok( rop == def_rop, "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc );
ok( rop == def_rop, "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc );
if (hdc == old_hdc)
{
found_dc = 1;
@ -104,8 +101,8 @@ static void test_dc_attributes(void)
rop = GetROP2( hdc );
if (hdc == old_hdc)
{
todo_wine ok( rop == R2_WHITE || broken( rop == def_rop),
"wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc );
ok( rop == R2_WHITE || broken( rop == def_rop),
"wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc );
SetROP2( old_hdc, def_rop );
}
else