scroll window fix

Aric Stewart aric at codeweavers.com
Thu Jan 25 11:56:41 CST 2007


finds the case where the scrolling amount exceeds the window but still falls
within the clipping rect. This generates an additional update region 
that needs
to be invalidated.
includes a test
---
  dlls/user32/painting.c  |   21 +++++++++++++++++++++
  dlls/user32/tests/win.c |    9 +++++++++
  2 files changed, 30 insertions(+), 0 deletions(-)
-------------- next part --------------
diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c
index dbc8cfe..8a613cf 100644
--- a/dlls/user32/painting.c
+++ b/dlls/user32/painting.c
@@ -870,6 +870,27 @@ INT WINAPI ScrollWindowEx( HWND hwnd, IN
                 CombineRgn( hrgnWinupd, hrgnWinupd, hrgnTemp, RGN_OR );
             RedrawWindow( hwnd, NULL, hrgnTemp, rdw_flags);
             DeleteObject( hrgnClip );
+
+	    /* Catch the case where the scolling amount exceeds the size of the
+	     * original window. This generated a second update area that is the
+	     * location where the original scrolled content would end up.
+	     * This second region is not returned by the ScrollDC and sets
+	     * ScrollWindowEx apart from just a ScrollDC.
+	     * 
+	     * This has been verified with testing on windows. 
+	     */
+	    if (abs(dx) > abs(rc.right - rc.left) ||
+			    abs(dy) > abs(rc.bottom - rc.top))
+	    {
+        	DeleteObject( hrgnTemp );
+		hrgnTemp = CreateRectRgn(rc.left + dx,  rc.top + dy, rc.right+dx, rc.bottom + dy);
+		CombineRgn( hrgnTemp, hrgnTemp, hrgnClip, RGN_AND );
+		CombineRgn( hrgnUpdate, hrgnUpdate, hrgnTemp, RGN_OR );
+
+		if( !bOwnRgn)
+			CombineRgn( hrgnWinupd, hrgnWinupd, hrgnTemp, RGN_OR );
+	    }
+
         }
         DeleteObject( hrgnTemp );
     } else {
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 951c6aa..cade032 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -2991,6 +2991,15 @@ static void test_scrollvalidate( HWND pa
     CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
     ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
 
+    SetRect( &rc, 0,40, 100,60);
+    SetRect( &cliprc, 0,0, 100,100);
+    ScrollWindowEx( hwnd1, 0, -25, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE);
+    SetRectRgn( tmprgn, 0,15,98,35);
+    CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
+    SetRectRgn( tmprgn, 0, 40, 98, 60);
+    CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
+    ok( EqualRgn( exprgn, hrgn), "wrong update region in excessive scroll\n");
+    
     /* now test ScrollWindowEx with a combination of
      * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
     /* make hwnd2 the child of hwnd1 */


More information about the wine-patches mailing list