Author: tkreuzer
Date: Sat Oct 27 02:08:53 2007
New Revision: 29903
URL: 
http://svn.reactos.org/svn/reactos?rev=29903&view=rev
Log:
UserScrollDC: 2nd try to fix the invalidated region. desk.cpl looks ok now and in my tests
all worked like on XP, also fix the returned invalidated rect (don't use
NtGdiGetClipBox)
NtUserScrollDC: return the region type
NtUserScrollwindowEx: fix the default clip region
Modified:
    trunk/reactos/subsystems/win32/win32k/include/intgdi.h
    trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
    trunk/reactos/subsystems/win32/win32k/objects/region.c
Modified: trunk/reactos/subsystems/win32/win32k/include/intgdi.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/intgdi.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/intgdi.h Sat Oct 27 02:08:53 2007
@@ -141,6 +141,7 @@
 void FASTCALL REGION_UnionRectWithRegion(const RECT *rect, ROSRGNDATA *rgn);
 INT FASTCALL UnsafeIntGetRgnBox(PROSRGNDATA Rgn, LPRECT pRect);
 BOOL FASTCALL UnsafeIntRectInRegion(PROSRGNDATA Rgn, CONST LPRECT rc);
+INT STDCALL IntGdiGetRgnBox(HRGN, LPRECT);
 #define UnsafeIntCreateRectRgnIndirect(prc) \
   NtGdiCreateRectRgn((prc)->left, (prc)->top, (prc)->right, (prc)->bottom)
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/painting.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/painting.c Sat Oct 27 02:08:53 2007
@@ -1131,10 +1131,11 @@
              const RECT *prcClip, HRGN hrgnUpdate, LPRECT prcUpdate)
 {
    PDC pDC;
-   RECT rcClip, rcSrc, rcDst;
+   RECT rcScroll, rcClip, rcSrc, rcDst;
    INT Result;
    IntGdiGetClipBox(hDC, &rcClip);
+   rcScroll = rcClip;
    if (prcClip)
    {
       IntGdiIntersectRect(&rcClip, &rcClip, prcClip);
@@ -1142,6 +1143,7 @@
    if (prcScroll)
    {
+      rcScroll = *prcScroll;
       IntGdiIntersectRect(&rcSrc, &rcClip, prcScroll);
    }
    else
@@ -1174,38 +1176,37 @@
       hrgnVisible = pDC->w.hVisRgn;  // pDC->w.hGCClipRgn?
       DC_UnlockDc(pDC);
-      /* Begin with the source rect */
+      /* Begin with the shifted and then clipped scroll rect */
+      rcDst = rcScroll;
+      IntGdiOffsetRect(&rcDst, dx, dy);
+      IntGdiIntersectRect(&rcDst, &rcDst, &rcClip);
       if (hrgnUpdate)
       {
          hrgnOwn = hrgnUpdate;
-         if (!NtGdiSetRectRgn(hrgnOwn, rcSrc.left, rcSrc.top, rcSrc.right, rcSrc.bottom))
+         if (!NtGdiSetRectRgn(hrgnOwn, rcDst.left, rcDst.top, rcDst.right, rcDst.bottom))
          {
             return ERROR;
          }
       }
       else
       {
-         hrgnOwn = UnsafeIntCreateRectRgnIndirect(&rcSrc);
-      }
-
-      /* Substract the dest rect */
-      hrgnTmp = UnsafeIntCreateRectRgnIndirect(&rcDst);
-      NtGdiCombineRgn(hrgnOwn, hrgnOwn, hrgnTmp, RGN_DIFF);
-
-      /* Add the part of the dest that wasn't visible in source */
-      NtGdiSetRectRgn(hrgnTmp, rcSrc.left, rcSrc.top, rcSrc.right, rcSrc.bottom);
-      Result = NtGdiCombineRgn(hrgnTmp, hrgnTmp, hrgnVisible, RGN_DIFF);
-      if (Result != NULLREGION && Result != ERROR)
-      {
-         NtGdiOffsetRgn(hrgnTmp, dx, dy);
-         NtGdiCombineRgn(hrgnOwn, hrgnOwn, hrgnTmp, RGN_OR);
-      }
+         hrgnOwn = UnsafeIntCreateRectRgnIndirect(&rcDst);
+      }
+
+      /* Add the source rect */
+      hrgnTmp = UnsafeIntCreateRectRgnIndirect(&rcSrc);
+      NtGdiCombineRgn(hrgnOwn, hrgnOwn, hrgnTmp, RGN_OR);
+
+      /* Substract the part of the dest that was visible in source */
+      NtGdiCombineRgn(hrgnTmp, hrgnTmp, hrgnVisible, RGN_AND);
+      NtGdiOffsetRgn(hrgnTmp, dx, dy);
+      Result = NtGdiCombineRgn(hrgnOwn, hrgnOwn, hrgnTmp, RGN_DIFF);
       NtGdiDeleteObject(hrgnTmp);
       if (prcUpdate)
       {
-         NtGdiGetRgnBox(hrgnOwn, prcUpdate);
+         IntGdiGetRgnBox(hrgnOwn, prcUpdate);
       }
       if (!hrgnUpdate)
@@ -1236,6 +1237,7 @@
    DECLARE_RETURN(DWORD);
    RECT rcScroll, rcClip, rcUpdate;
    NTSTATUS Status = STATUS_SUCCESS;
+   DWORD Result;
    DPRINT("Enter NtUserScrollDC\n");
    UserEnterExclusive();
@@ -1268,13 +1270,14 @@
       RETURN(FALSE);
    }
-   if (UserScrollDC(hDC, dx, dy,
-                    prcUnsafeScroll? &rcScroll : 0,
-                    prcUnsafeClip? &rcClip : 0, hrgnUpdate,
-                    prcUnsafeUpdate? &rcUpdate : NULL) == ERROR)
+   Result = UserScrollDC(hDC, dx, dy,
+                         prcUnsafeScroll? &rcScroll : 0,
+                         prcUnsafeClip? &rcClip : 0, hrgnUpdate,
+                         prcUnsafeUpdate? &rcUpdate : NULL);
+   if(Result == ERROR)
    {
       /* FIXME: SetLastError? */
-      RETURN(FALSE);
+      RETURN(Result);
    }
    if (prcUnsafeUpdate)
@@ -1296,7 +1299,7 @@
       }
    }
-   RETURN(TRUE);
+   RETURN(Result);
 CLEANUP:
    DPRINT("Leave NtUserScrollDC, ret=%i\n",_ret_);
@@ -1336,23 +1339,23 @@
    }
    UserRefObjectCo(Window, &Ref);
-   IntGetClientRect(Window, &rcScroll);
+   IntGetClientRect(Window, &rcClip);
    _SEH_TRY
    {
       if (prcUnsafeScroll)
       {
          ProbeForRead(prcUnsafeScroll, sizeof(*prcUnsafeScroll), 1);
-         IntGdiIntersectRect(&rcScroll, &rcScroll, prcUnsafeScroll);
-      }
+         IntGdiIntersectRect(&rcScroll, &rcClip, prcUnsafeScroll);
+      }
+      else
+         rcScroll = rcClip;
       if (prcUnsafeClip)
       {
          ProbeForRead(prcUnsafeClip, sizeof(*prcUnsafeClip), 1);
-         IntGdiIntersectRect(&rcClip, &rcScroll, prcUnsafeClip);
-      }
-      else
-         rcClip = rcScroll;
+         IntGdiIntersectRect(&rcClip, &rcClip, prcUnsafeClip);
+      }
    }
    _SEH_HANDLE
    {
Modified: trunk/reactos/subsystems/win32/win32k/objects/region.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/region.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/region.c Sat Oct 27 02:08:53 2007
@@ -540,7 +540,7 @@
     pReg->rdh.iType = (1 == pReg->rdh.nCount ? SIMPLEREGION : COMPLEXREGION);
 }
-
+// FIXME: This seems to be wrong
 /***********************************************************************
  *           REGION_CropAndOffsetRegion
  */
@@ -2410,6 +2410,25 @@
 }
 INT STDCALL
+IntGdiGetRgnBox(HRGN hRgn,
+                LPRECT pRect)
+{
+  PROSRGNDATA Rgn;
+  DWORD ret;
+
+  if (!(Rgn = RGNDATA_LockRgn(hRgn)))
+  {
+    return ERROR;
+  }
+
+  ret = UnsafeIntGetRgnBox(Rgn, pRect);
+  RGNDATA_UnlockRgn(Rgn);
+
+  return ret;
+}
+
+
+INT STDCALL
 NtGdiGetRgnBox(HRGN  hRgn,
              LPRECT  pRect)
 {