[Win32k]
[reactos.git] / reactos / subsystems / win32 / win32k / ntuser / vis.c
index 4496bf4..f82ed55 100644 (file)
@@ -16,7 +16,6 @@
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * $Id$
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -48,13 +47,15 @@ VIS_ComputeVisibleRegion(
       return NULL;
    }
 
+   VisRgn = NULL;
+
    if (ClientArea)
    {
-      VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->rcClient);
+      VisRgn = IntSysCreateRectRgnIndirect(&Window->Wnd->rcClient);
    }
    else
    {
-      VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->rcWindow);
+      VisRgn = IntSysCreateRectRgnIndirect(&Window->Wnd->rcWindow);
    }
 
    /*
@@ -72,31 +73,34 @@ VIS_ComputeVisibleRegion(
            CurrentWindow->state & WINDOWSTATUS_DESTROYED )
       {
          DPRINT1("ATM the Current Window or Parent is dead!\n");
+         if (VisRgn) REGION_FreeRgnByHandle(VisRgn);
          return NULL;
       }
 
       CurrentWnd = CurrentWindow->Wnd;
       if (!CurrentWnd || !(CurrentWnd->style & WS_VISIBLE))
       {
-         GreDeleteObject(VisRgn);
+         if (VisRgn) REGION_FreeRgnByHandle(VisRgn);
          return NULL;
       }
 
-      ClipRgn = UnsafeIntCreateRectRgnIndirect(&CurrentWnd->rcClient);
+      ClipRgn = IntSysCreateRectRgnIndirect(&CurrentWnd->rcClient);
       NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_AND);
-      GreDeleteObject(ClipRgn);
+      REGION_FreeRgnByHandle(ClipRgn);
 
       if ((PreviousWnd->style & WS_CLIPSIBLINGS) ||
           (PreviousWnd == Wnd && ClipSiblings))
       {
          CurrentSibling = CurrentWindow->spwndChild;
-         while (CurrentSibling != NULL && CurrentSibling != PreviousWindow)
+         while ( CurrentSibling != NULL && 
+                 CurrentSibling != PreviousWindow &&
+                 CurrentSibling->Wnd )
          {
             CurrentSiblingWnd = CurrentSibling->Wnd;
             if ((CurrentSiblingWnd->style & WS_VISIBLE) &&
                 !(CurrentSiblingWnd->ExStyle & WS_EX_TRANSPARENT))
             {
-               ClipRgn = UnsafeIntCreateRectRgnIndirect(&CurrentSiblingWnd->rcWindow);
+               ClipRgn = IntSysCreateRectRgnIndirect(&CurrentSiblingWnd->rcWindow);
                /* Combine it with the window region if available */
                if (CurrentSibling->hrgnClip && !(CurrentSiblingWnd->style & WS_MINIMIZE))
                {
@@ -105,7 +109,7 @@ VIS_ComputeVisibleRegion(
                   NtGdiOffsetRgn(ClipRgn, CurrentSiblingWnd->rcWindow.left, CurrentSiblingWnd->rcWindow.top);
                }
                NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
-               GreDeleteObject(ClipRgn);
+               REGION_FreeRgnByHandle(ClipRgn);
             }
             CurrentSibling = CurrentSibling->spwndNext;
          }
@@ -119,13 +123,13 @@ VIS_ComputeVisibleRegion(
    if (ClipChildren)
    {
       CurrentWindow = Window->spwndChild;
-      while (CurrentWindow)
+      while (CurrentWindow && CurrentWindow->Wnd)
       {
          CurrentWnd = CurrentWindow->Wnd;
          if ((CurrentWnd->style & WS_VISIBLE) &&
              !(CurrentWnd->ExStyle & WS_EX_TRANSPARENT))
          {
-            ClipRgn = UnsafeIntCreateRectRgnIndirect(&CurrentWnd->rcWindow);
+            ClipRgn = IntSysCreateRectRgnIndirect(&CurrentWnd->rcWindow);
             /* Combine it with the window region if available */
             if (CurrentWindow->hrgnClip && !(CurrentWnd->style & WS_MINIMIZE))
             {
@@ -134,7 +138,7 @@ VIS_ComputeVisibleRegion(
                NtGdiOffsetRgn(ClipRgn, CurrentWnd->rcWindow.left, CurrentWnd->rcWindow.top);
             }
             NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
-            GreDeleteObject(ClipRgn);
+            REGION_FreeRgnByHandle(ClipRgn);
          }
          CurrentWindow = CurrentWindow->spwndNext;
       }
@@ -164,7 +168,7 @@ co_VIS_WindowLayoutChanged(
 
    Wnd = Window->Wnd;
 
-   Temp = NtGdiCreateRectRgn(0, 0, 0, 0);
+   Temp = IntSysCreateRectRgn(0, 0, 0, 0);
    NtGdiCombineRgn(Temp, NewlyExposed, NULL, RGN_COPY);
 
    Parent = Window->spwndParent;
@@ -181,7 +185,7 @@ co_VIS_WindowLayoutChanged(
                           RDW_ALLCHILDREN);
       UserDerefObjectCo(Parent);
    }
-   GreDeleteObject(Temp);
+   REGION_FreeRgnByHandle(Temp);
 }
 
 /* EOF */