- Intersect the paint rectangle in NtUserBeginPaint with the client window rectangle.
- Fix the data returned by co_UserGetUpdateRgn and NtUserGetUpdateRect.
Modified: trunk/reactos/subsys/win32k/ntuser/painting.c

Modified: trunk/reactos/subsys/win32k/ntuser/painting.c
--- trunk/reactos/subsys/win32k/ntuser/painting.c	2005-09-25 11:05:00 UTC (rev 18045)
+++ trunk/reactos/subsys/win32k/ntuser/painting.c	2005-09-25 11:16:54 UTC (rev 18046)
@@ -755,7 +755,7 @@
    Ps.hdc = UserGetDCEx(Window, Window->UpdateRegion, DCX_INTERSECTRGN | DCX_USESTYLE);
    if (!Ps.hdc)
    {
-      RETURN( NULL);
+      RETURN(NULL);
    }
 
    if (Window->UpdateRegion != NULL)
@@ -766,6 +766,7 @@
       {
          UnsafeIntGetRgnBox(Rgn, &Ps.rcPaint);
          RGNDATA_UnlockRgn(Rgn);
+         IntGdiIntersectRect(&Ps.rcPaint, &Ps.rcPaint, &Window->ClientRect);
          IntGdiOffsetRect(&Ps.rcPaint,
                           -Window->ClientRect.left,
                           -Window->ClientRect.top);
@@ -801,10 +802,10 @@
    if (! NT_SUCCESS(Status))
    {
       SetLastNtError(Status);
-      RETURN( NULL);
+      RETURN(NULL);
    }
 
-   RETURN( Ps.hdc);
+   RETURN(Ps.hdc);
 
 CLEANUP:
    if (Window) UserDerefObjectCo(Window);
@@ -855,6 +856,7 @@
 co_UserGetUpdateRgn(PWINDOW_OBJECT Window, HRGN hRgn, BOOL bErase)
 {
    int RegionType;
+   RECT Rect;
 
    ASSERT_REFS_CO(Window);
 
@@ -864,7 +866,10 @@
    }
    else
    {
-      RegionType = NtGdiCombineRgn(hRgn, Window->UpdateRegion, hRgn, RGN_COPY);
+      Rect = Window->ClientRect;
+      IntIntersectWithParents(Window, &Rect);
+      NtGdiSetRectRgn(hRgn, Rect.left, Rect.top, Rect.right, Rect.bottom);
+      RegionType = NtGdiCombineRgn(hRgn, hRgn, Window->UpdateRegion, RGN_AND);
       NtGdiOffsetRgn(hRgn, -Window->ClientRect.left, -Window->ClientRect.top);
    }
 
@@ -875,6 +880,7 @@
 
    return RegionType;
 }
+
 /*
  * NtUserGetUpdateRgn
  *
@@ -923,7 +929,6 @@
    RECT Rect;
    INT RegionType;
    PROSRGNDATA RgnData;
-   BOOL AlwaysPaint;
    NTSTATUS Status;
    DECLARE_RETURN(BOOL);
 
@@ -932,7 +937,7 @@
 
    if (!(Window = UserGetWindowObject(hWnd)))
    {
-      RETURN( ERROR);
+      RETURN(FALSE);
    }
 
    if (Window->UpdateRegion == NULL)
@@ -941,16 +946,34 @@
    }
    else
    {
-      RgnData = RGNDATA_LockRgn(Window->UpdateRegion);
-      ASSERT(RgnData != NULL);
-      RegionType = UnsafeIntGetRgnBox(RgnData, &Rect);
-      ASSERT(RegionType != ERROR);
-      RGNDATA_UnlockRgn(RgnData);
+      /* Get the update region bounding box. */
+      if (Window->UpdateRegion == (HRGN)1)
+      {
+         Rect = Window->ClientRect;
+      }
+      else
+      {
+         RgnData = RGNDATA_LockRgn(Window->UpdateRegion);
+         ASSERT(RgnData != NULL);
+         RegionType = UnsafeIntGetRgnBox(RgnData, &Rect);
+         RGNDATA_UnlockRgn(RgnData);
+
+         if (RegionType != ERROR && RegionType != NULLREGION)
+            IntGdiIntersectRect(&Rect, &Rect, &Window->ClientRect);
+      }
+
+      if (IntIntersectWithParents(Window, &Rect))
+      {
+         IntGdiOffsetRect(&Rect,
+                          -Window->ClientRect.left,
+                          -Window->ClientRect.top);
+      } else
+      {
+         Rect.left = Rect.top = Rect.right = Rect.bottom = 0;
+      }
    }
-   AlwaysPaint = (Window->Flags & WINDOWOBJECT_NEED_NCPAINT) ||
-                 (Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT);
 
-   if (bErase && Rect.left < Rect.right && Rect.top < Rect.bottom)
+   if (bErase && !IntGdiIsEmptyRect(&Rect))
    {
       UserRefObjectCo(Window);
       co_UserRedrawWindow(Window, NULL, NULL, RDW_ERASENOW | RDW_NOCHILDREN);
@@ -963,11 +986,11 @@
       if (!NT_SUCCESS(Status))
       {
          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-         RETURN( FALSE);
+         RETURN(FALSE);
       }
    }
 
-   RETURN( (Rect.left < Rect.right && Rect.top < Rect.bottom) || AlwaysPaint);
+   RETURN(Window->UpdateRegion != NULL);
 
 CLEANUP:
    DPRINT("Leave NtUserGetUpdateRect, ret=%i\n",_ret_);
@@ -1314,7 +1337,7 @@
       UserDerefObjectCo(CaretWnd);
    }
 
-   RETURN( Result);
+   RETURN(Result);
 
 CLEANUP:
    if (Window)