{Validate|Invalidate}{Rgn|Rect} fix
Rein Klazes
wijn at wanadoo.nl
Wed Mar 9 06:13:46 CST 2005
Hi,
Changelog:
dlls/user : painting.c
dlls/user/tests : win.c
{Validate|Invalidate}{Rgn|Rect} should not (in)validate children if the
window has a WS_CLIPCHILDREN style. With tests.
Rein.
-------------- next part --------------
--- wine/dlls/user/painting.c 2005-03-09 09:25:20.000000000 +0100
+++ mywine/dlls/user/painting.c 2005-03-09 12:45:19.000000000 +0100
@@ -490,7 +490,10 @@ BOOL WINAPI UpdateWindow( HWND hwnd )
*/
BOOL WINAPI InvalidateRgn( HWND hwnd, HRGN hrgn, BOOL erase )
{
- return RedrawWindow(hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
+ return RedrawWindow(hwnd, NULL, hrgn, RDW_INVALIDATE |
+ (( GetWindowLongW( hwnd, GWL_STYLE) & WS_CLIPCHILDREN) ?
+ RDW_NOCHILDREN : 0) |
+ (erase ? RDW_ERASE : 0) );
}
@@ -499,7 +502,10 @@ BOOL WINAPI InvalidateRgn( HWND hwnd, HR
*/
BOOL WINAPI InvalidateRect( HWND hwnd, const RECT *rect, BOOL erase )
{
- return RedrawWindow( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
+ return RedrawWindow( hwnd, rect, 0, RDW_INVALIDATE |
+ (( GetWindowLongW( hwnd, GWL_STYLE) & WS_CLIPCHILDREN) ?
+ RDW_NOCHILDREN : 0) |
+ (erase ? RDW_ERASE : 0) );
}
@@ -508,7 +514,9 @@ BOOL WINAPI InvalidateRect( HWND hwnd, c
*/
BOOL WINAPI ValidateRgn( HWND hwnd, HRGN hrgn )
{
- return RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
+ return RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | (
+ ( GetWindowLongW( hwnd, GWL_STYLE) & WS_CLIPCHILDREN) ?
+ RDW_NOCHILDREN : 0));
}
@@ -517,7 +525,9 @@ BOOL WINAPI ValidateRgn( HWND hwnd, HRGN
*/
BOOL WINAPI ValidateRect( HWND hwnd, const RECT *rect )
{
- return RedrawWindow( hwnd, rect, 0, RDW_VALIDATE );
+ return RedrawWindow( hwnd, rect, 0, RDW_VALIDATE | (
+ ( GetWindowLongW( hwnd, GWL_STYLE) & WS_CLIPCHILDREN) ?
+ RDW_NOCHILDREN : 0));
}
--- wine/dlls/user/tests/win.c 2005-03-09 09:25:23.000000000 +0100
+++ mywine/dlls/user/tests/win.c 2005-03-09 13:01:36.000000000 +0100
@@ -2296,16 +2296,21 @@ static void test_mouse_input(HWND hwnd)
DestroyWindow(popup);
}
+/* tests how {Validate|Invalidate}{Rect|Rgn} work out on the window's
+ * children */
static void test_validatergn(HWND hwnd)
{
HWND child;
RECT rc, rc2;
HRGN rgn;
int ret;
+ LONG style = GetWindowLongA( hwnd, GWL_STYLE);
+
+ SetWindowLongA( hwnd, GWL_STYLE, style & ~WS_CLIPCHILDREN);
child = CreateWindowExA(0, "static", NULL, WS_CHILD| WS_VISIBLE, 10, 10, 10, 10, hwnd, 0, 0, NULL);
ShowWindow(hwnd, SW_SHOW);
UpdateWindow( hwnd);
- /* test that ValidateRect validates children*/
+ /* test that ValidateRect validates children */
InvalidateRect( child, NULL, 1);
GetWindowRect( child, &rc);
MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
@@ -2317,6 +2322,13 @@ static void test_validatergn(HWND hwnd)
ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
"Update rectangle %ld,%ld-%ld,%ld is not empty!\n", rc2.left, rc2.top,
rc2.right, rc2.bottom);
+ /* now test InvalidateRect */
+ ValidateRect( child, NULL);
+ InvalidateRect( hwnd, NULL, 1);
+ ret = GetUpdateRect( child, &rc2, 0);
+ ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 10 && rc2.bottom == 10,
+ "Update rectangle %ld,%ld-%ld,%ld is not expected (0,0-10,10) !\n", rc2.left, rc2.top,
+ rc2.right, rc2.bottom);
/* now test ValidateRgn */
InvalidateRect( child, NULL, 1);
@@ -2328,9 +2340,66 @@ static void test_validatergn(HWND hwnd)
ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
"Update rectangle %ld,%ld-%ld,%ld is not empty!\n", rc2.left, rc2.top,
rc2.right, rc2.bottom);
+ DeleteObject( rgn);
+ /* now test Inva1idateRgn */
+ ValidateRect( child, NULL);
+ GetWindowRect( child, &rc);
+ MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
+ rgn = CreateRectRgnIndirect( &rc);
+ InvalidateRgn( hwnd, rgn, 1);
+ ret = GetUpdateRect( child, &rc2, 0);
+ ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 10 && rc2.bottom == 10,
+ "Update rectangle %ld,%ld-%ld,%ld is not expected (0,0-10,10) !\n", rc2.left, rc2.top,
+ rc2.right, rc2.bottom);
+ DeleteObject( rgn);
+ /* now tests with parent and WS_CLIPCHILDREN style */
+ SetWindowLongA( hwnd, GWL_STYLE, style | WS_CLIPCHILDREN);
+ /* test whether ValidateRect validates children*/
+ InvalidateRect( child, NULL, 1);
+ GetWindowRect( child, &rc);
+ MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
+ ret = GetUpdateRect( child, &rc2, 0);
+ ok( rc2.right > rc2.left && rc2.bottom > rc2.top,
+ "Update rectangle is empty!\n");
+ ValidateRect( hwnd, &rc);
+ ret = GetUpdateRect( child, &rc2, 0);
+ ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 10 && rc2.bottom == 10,
+ "Update rectangle %ld,%ld-%ld,%ld is not expected (0,0-10,10) !\n", rc2.left, rc2.top,
+ rc2.right, rc2.bottom);
+ /* now test InvalidateRect */
+ ValidateRect( child, NULL);
+ InvalidateRect( hwnd, NULL, 1);
+ ret = GetUpdateRect( child, &rc2, 0);
+ ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
+ "Update rectangle %ld,%ld-%ld,%ld is not empty!\n", rc2.left, rc2.top,
+ rc2.right, rc2.bottom);
+ /* now test ValidateRgn */
+ InvalidateRect( child, NULL, 1);
+ GetWindowRect( child, &rc);
+ MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
+ rgn = CreateRectRgnIndirect( &rc);
+ ValidateRgn( hwnd, rgn);
+ ret = GetUpdateRect( child, &rc2, 0);
+ ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 10 && rc2.bottom == 10,
+ "Update rectangle %ld,%ld-%ld,%ld is not expected (0,0-10,10) !\n", rc2.left, rc2.top,
+ rc2.right, rc2.bottom);
DeleteObject( rgn);
- DestroyWindow( child );
+ /* now test Inva1idateRgn */
+ ValidateRect( child, NULL);
+ GetWindowRect( child, &rc);
+ MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
+ rgn = CreateRectRgnIndirect( &rc);
+ InvalidateRgn( hwnd, rgn, 1);
+ ret = GetUpdateRect( child, &rc2, 0);
+ ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
+ "Update rectangle %ld,%ld-%ld,%ld is not empty!\n", rc2.left, rc2.top,
+ rc2.right, rc2.bottom);
+ DeleteObject( rgn);
+
+ /* clean-up */
+ SetWindowLongA( hwnd, GWL_STYLE, style);
+ DestroyWindow( child);
}
static void nccalchelper(HWND hwnd, INT x, INT y, RECT *prc)
More information about the wine-patches
mailing list