Add a test for RedrawWindow with an empty region/rectangle, make it pass under Wine

Dmitry Timoshkov dmitry at baikal.ru
Wed Nov 30 09:30:36 CST 2005


Hello,

this is a fix for the problem when InvalidateRect does not return TRUE
for an empty rectangle (10,10,10,15) reported by Andreas Rosenberg.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Add a test for RedrawWindow with an empty region/rectangle, make
    it pass under Wine.

diff -up cvs/hq/wine/dlls/user/painting.c wine/dlls/user/painting.c
--- cvs/hq/wine/dlls/user/painting.c	2005-11-30 23:19:26.000000000 +0800
+++ wine/dlls/user/painting.c	2005-11-30 23:21:02.000000000 +0800
@@ -571,6 +571,7 @@ BOOL WINAPI LockWindowUpdate( HWND hwnd 
  */
 BOOL WINAPI RedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags )
 {
+    static const RECT empty;
     BOOL ret;
 
     if (!hwnd) hwnd = GetDesktopWindow();
@@ -596,6 +597,7 @@ BOOL WINAPI RedrawWindow( HWND hwnd, con
 
     if (rect && !hrgn)
     {
+        if (IsRectEmpty( rect )) rect = &empty;
         ret = redraw_window_rects( hwnd, flags, rect, 1 );
     }
     else if (!hrgn)
@@ -606,7 +608,6 @@ BOOL WINAPI RedrawWindow( HWND hwnd, con
     {
         DWORD size;
         RGNDATA *data = NULL;
-        static const RECT empty;
 
         if (!(size = GetRegionData( hrgn, 0, NULL ))) return FALSE;
         if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE;
diff -up cvs/hq/wine/dlls/user/tests/msg.c wine/dlls/user/tests/msg.c
--- cvs/hq/wine/dlls/user/tests/msg.c	2005-11-30 23:19:27.000000000 +0800
+++ wine/dlls/user/tests/msg.c	2005-11-30 23:21:02.000000000 +0800
@@ -3925,6 +3925,7 @@ static const struct message WmSetParentS
 
 static void test_paint_messages(void)
 {
+    BOOL ret;
     RECT rect;
     POINT pt;
     MSG msg;
@@ -3944,14 +3945,28 @@ static void test_paint_messages(void)
 
     check_update_rgn( hwnd, 0 );
     SetRectRgn( hrgn, 10, 10, 20, 20 );
-    RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
+    ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
+    ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
     check_update_rgn( hwnd, hrgn );
     SetRectRgn( hrgn2, 20, 20, 30, 30 );
-    RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
+    ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
+    ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
     CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
     check_update_rgn( hwnd, hrgn );
     /* validate everything */
-    RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
+    ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
+    ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
+    check_update_rgn( hwnd, 0 );
+
+    /* test empty region */
+    SetRectRgn( hrgn, 10, 10, 10, 15 );
+    ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
+    ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
+    check_update_rgn( hwnd, 0 );
+    /* test empty rect */
+    SetRect( &rect, 10, 10, 10, 15 );
+    ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
+    ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
     check_update_rgn( hwnd, 0 );
 
     /* flush pending messages */






More information about the wine-patches mailing list