user32: Update RedrawWindow behavior with explicit desktop window handle.

Newer Windows versions behave differently.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2018-07-06 13:20:56 +02:00
parent 9d3adf687b
commit b73a50a35e
4 changed files with 92 additions and 20 deletions

View File

@ -1227,8 +1227,6 @@ BOOL WINAPI RedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags )
static const RECT empty; static const RECT empty;
BOOL ret; BOOL ret;
if (!hwnd) hwnd = GetDesktopWindow();
if (TRACE_ON(win)) if (TRACE_ON(win))
{ {
if (hrgn) if (hrgn)
@ -1272,6 +1270,8 @@ BOOL WINAPI RedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags )
HeapFree( GetProcessHeap(), 0, data ); HeapFree( GetProcessHeap(), 0, data );
} }
if (!hwnd) hwnd = GetDesktopWindow();
if (flags & RDW_UPDATENOW) update_now( hwnd, flags ); if (flags & RDW_UPDATENOW) update_now( hwnd, flags );
else if (flags & RDW_ERASENOW) erase_now( hwnd, flags ); else if (flags & RDW_ERASENOW) erase_now( hwnd, flags );

View File

@ -2938,8 +2938,7 @@ BOOL WINAPI SetSysColors( INT count, const INT *colors, const COLORREF *values )
/* Repaint affected portions of all visible windows */ /* Repaint affected portions of all visible windows */
RedrawWindow( GetDesktopWindow(), NULL, 0, RedrawWindow( 0, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
return TRUE; return TRUE;
} }

View File

@ -7229,7 +7229,8 @@ void dump_region(HRGN hrgn)
HeapFree( GetProcessHeap(), 0, data ); HeapFree( GetProcessHeap(), 0, data );
} }
static void check_update_rgn( HWND hwnd, HRGN hrgn ) #define check_update_rgn( hwnd, hrgn ) check_update_rgn_( __LINE__, hwnd, hrgn )
static void check_update_rgn_( int line, HWND hwnd, HRGN hrgn )
{ {
INT ret; INT ret;
RECT r1, r2; RECT r1, r2;
@ -7240,13 +7241,13 @@ static void check_update_rgn( HWND hwnd, HRGN hrgn )
ok( ret != ERROR, "GetUpdateRgn failed\n" ); ok( ret != ERROR, "GetUpdateRgn failed\n" );
if (ret == NULLREGION) if (ret == NULLREGION)
{ {
ok( !hrgn, "Update region shouldn't be empty\n" ); ok_(__FILE__,line)( !hrgn, "Update region shouldn't be empty\n" );
} }
else else
{ {
if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION) if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
{ {
ok( 0, "Regions are different\n" ); ok_(__FILE__,line)( 0, "Regions are different\n" );
if (winetest_debug > 0) if (winetest_debug > 0)
{ {
printf( "Update region: " ); printf( "Update region: " );
@ -7258,8 +7259,8 @@ static void check_update_rgn( HWND hwnd, HRGN hrgn )
} }
GetRgnBox( update, &r1 ); GetRgnBox( update, &r1 );
GetUpdateRect( hwnd, &r2, FALSE ); GetUpdateRect( hwnd, &r2, FALSE );
ok( EqualRect( &r1, &r2 ), "Rectangles are different: %s / %s\n", wine_dbgstr_rect( &r1 ), ok_(__FILE__,line)( EqualRect( &r1, &r2 ), "Rectangles are different: %s / %s\n",
wine_dbgstr_rect( &r2 )); wine_dbgstr_rect( &r1 ), wine_dbgstr_rect( &r2 ));
DeleteObject( tmp ); DeleteObject( tmp );
DeleteObject( update ); DeleteObject( update );
@ -7455,9 +7456,76 @@ static void test_paint_messages(void)
/* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
* all windows and sends WM_ERASEBKGND and WM_NCPAINT. * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
*/ */
trace("testing InvalidateRect(0, NULL, FALSE)\n");
SetRectEmpty( &rect ); SetRectEmpty( &rect );
ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n"); ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) failed\n");
check_update_rgn( hwnd, hrgn );
ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
flush_events();
ok_sequence( WmPaint, "Paint", FALSE );
RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
check_update_rgn( hwnd, 0 );
SetRectEmpty( &rect );
ok(RedrawWindow(0, &rect, 0, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ),
"RedrawWindow failed\n");
check_update_rgn( hwnd, 0 );
SetRectEmpty( &rect );
ok(RedrawWindow(0, &rect, 0, RDW_ALLCHILDREN | RDW_VALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ),
"RedrawWindow failed\n");
check_update_rgn( hwnd, 0 );
GetWindowRect( hwnd, &rect );
ok(RedrawWindow(0, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ),
"RedrawWindow failed\n");
check_update_rgn( hwnd, 0 );
flush_events();
ok(RedrawWindow(0, &rect, 0, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ),
"RedrawWindow failed\n");
check_update_rgn( hwnd, hrgn );
ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
flush_events();
ok_sequence( WmPaint, "Paint", FALSE );
RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
check_update_rgn( hwnd, 0 );
ok(RedrawWindow(GetDesktopWindow(), &rect, 0,
RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ),
"RedrawWindow failed\n");
ret = GetUpdateRgn( hwnd, hrgn2, FALSE );
ok( ret == NULLREGION || broken(ret == SIMPLEREGION), /* <= win7 */
"region should be null (%d)\n", ret );
if (ret == SIMPLEREGION) ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
flush_events();
ok(RedrawWindow(GetDesktopWindow(), NULL, 0,
RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ),
"RedrawWindow failed\n");
ret = GetUpdateRgn( hwnd, hrgn2, FALSE );
ok( ret == NULLREGION || broken(ret == SIMPLEREGION), /* <= win7 */
"region should be null (%d)\n", ret );
if (ret == SIMPLEREGION) ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
flush_events();
SetRectRgn( hrgn2, rect.left, rect.top, rect.right, rect.bottom );
ok(RedrawWindow(0, NULL, hrgn2, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW ),
"RedrawWindow failed\n");
check_update_rgn( hwnd, hrgn );
ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
flush_events();
ok_sequence( WmPaint, "Paint", FALSE );
RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
check_update_rgn( hwnd, 0 );
ok(RedrawWindow(0, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW ),
"RedrawWindow failed\n");
check_update_rgn( hwnd, 0 );
ok(RedrawWindow(0, NULL, 0, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW ),
"RedrawWindow failed\n");
check_update_rgn( hwnd, hrgn ); check_update_rgn( hwnd, hrgn );
ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE ); ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
flush_events(); flush_events();
@ -7468,7 +7536,6 @@ static void test_paint_messages(void)
/* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
* all windows and sends WM_ERASEBKGND and WM_NCPAINT. * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
*/ */
trace("testing ValidateRect(0, NULL)\n");
SetRectEmpty( &rect ); SetRectEmpty( &rect );
if (ValidateRect(0, &rect) && /* not supported on Win9x */ if (ValidateRect(0, &rect) && /* not supported on Win9x */
GetUpdateRect(hwnd, NULL, FALSE)) /* or >= Win 8 */ GetUpdateRect(hwnd, NULL, FALSE)) /* or >= Win 8 */
@ -7481,7 +7548,6 @@ static void test_paint_messages(void)
check_update_rgn( hwnd, 0 ); check_update_rgn( hwnd, 0 );
} }
trace("testing InvalidateRgn(0, NULL, FALSE)\n");
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n"); ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || GetLastError() == 0xdeadbeef, ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || GetLastError() == 0xdeadbeef,
@ -7490,7 +7556,6 @@ static void test_paint_messages(void)
flush_events(); flush_events();
ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE ); ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
trace("testing ValidateRgn(0, NULL)\n");
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n"); ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE ||
@ -7500,7 +7565,6 @@ static void test_paint_messages(void)
flush_events(); flush_events();
ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE ); ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
trace("testing UpdateWindow(NULL)\n");
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ok(!UpdateWindow(NULL), "UpdateWindow(NULL) should fail\n"); ok(!UpdateWindow(NULL), "UpdateWindow(NULL) should fail\n");
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE ||

View File

@ -2634,13 +2634,23 @@ DECL_HANDLER(update_window_zorder)
/* mark parts of a window as needing a redraw */ /* mark parts of a window as needing a redraw */
DECL_HANDLER(redraw_window) DECL_HANDLER(redraw_window)
{ {
unsigned int flags = req->flags;
struct region *region = NULL; struct region *region = NULL;
struct window *win = get_window( req->window ); struct window *win;
if (!req->window)
{
if (!(win = get_desktop_window( current ))) return;
}
else
{
if (!(win = get_window( req->window ))) return;
if (is_desktop_window( win )) flags &= ~RDW_ALLCHILDREN;
}
if (!win) return;
if (!is_visible( win )) return; /* nothing to do */ if (!is_visible( win )) return; /* nothing to do */
if (req->flags & (RDW_VALIDATE|RDW_INVALIDATE)) if (flags & (RDW_VALIDATE|RDW_INVALIDATE))
{ {
if (get_req_data_size()) /* no data means whole rectangle */ if (get_req_data_size()) /* no data means whole rectangle */
{ {
@ -2650,8 +2660,7 @@ DECL_HANDLER(redraw_window)
} }
} }
redraw_window( win, region, (req->flags & RDW_INVALIDATE) && (req->flags & RDW_FRAME), redraw_window( win, region, (flags & RDW_INVALIDATE) && (flags & RDW_FRAME), flags );
req->flags );
if (region) free_region( region ); if (region) free_region( region );
} }