[CMAKE]
[reactos.git] / subsystems / win32 / win32k / ntuser / windc.c
index 6765212..5265ba2 100644 (file)
@@ -50,6 +50,7 @@ DceCreateDisplayDC(VOID)
   if (hDC && !defaultDCstate) // Ultra HAX! Dedicated to GvG!
   { // This is a cheesy way to do this.
       PDC dc = DC_LockDc ( hDC );
+      ASSERT(dc);
       defaultDCstate = ExAllocatePoolWithTag(PagedPool, sizeof(DC), TAG_DC);
       RtlZeroMemory(defaultDCstate, sizeof(DC));
       defaultDCstate->pdcattr = &defaultDCstate->dcattr;
@@ -62,7 +63,7 @@ DceCreateDisplayDC(VOID)
 
 static
 HRGN FASTCALL
-DceGetVisRgn(PWINDOW_OBJECT Window, ULONG Flags, HWND hWndChild, ULONG CFlags)
+DceGetVisRgn(PWND Window, ULONG Flags, HWND hWndChild, ULONG CFlags)
 {
   HRGN VisRgn;
 
@@ -78,28 +79,25 @@ DceGetVisRgn(PWINDOW_OBJECT Window, ULONG Flags, HWND hWndChild, ULONG CFlags)
 }
 
 PDCE FASTCALL
-DceAllocDCE(PWINDOW_OBJECT Window OPTIONAL, DCE_TYPE Type)
+DceAllocDCE(PWND Window OPTIONAL, DCE_TYPE Type)
 {
   PDCE pDce;
-  PWND Wnd = NULL;
 
-  if (Window) Wnd = Window->Wnd;
-
-  pDce = ExAllocatePoolWithTag(PagedPool, sizeof(DCE), TAG_PDCE);
+  pDce = ExAllocatePoolWithTag(PagedPool, sizeof(DCE), USERTAG_DCE);
   if(!pDce)
         return NULL;
 
   pDce->hDC = DceCreateDisplayDC();
   if (!pDce->hDC)
   {
-      ExFreePoolWithTag(pDce, TAG_PDCE);
+      ExFreePoolWithTag(pDce, USERTAG_DCE);
       return NULL;
   }
   DCECount++;
   DPRINT("Alloc DCE's! %d\n",DCECount);
-  pDce->hwndCurrent = (Window ? Window->hSelf : NULL);
-  pDce->pwndOrg  = Wnd;
-  pDce->pwndClip = Wnd;
+  pDce->hwndCurrent = (Window ? Window->head.h : NULL);
+  pDce->pwndOrg  = Window;
+  pDce->pwndClip = Window;
   pDce->hrgnClip = NULL;
   pDce->hrgnClipPublic = NULL;
   pDce->hrgnSavedVis = NULL;
@@ -116,7 +114,7 @@ DceAllocDCE(PWINDOW_OBJECT Window OPTIONAL, DCE_TYPE Type)
   else
   {
      DPRINT("FREE DCATTR!!!! NOT DCE_WINDOW_DC!!!!! hDC-> %x\n", pDce->hDC);
-     IntGdiSetDCOwnerEx( pDce->hDC, GDI_OBJ_HMGR_NONE, FALSE);
+     GreSetDCOwner(pDce->hDC, GDI_OBJ_HMGR_NONE);
      pDce->ptiOwner = NULL;
   }
 
@@ -127,12 +125,12 @@ DceAllocDCE(PWINDOW_OBJECT Window OPTIONAL, DCE_TYPE Type)
   else
   {
      pDce->DCXFlags = DCX_DCEBUSY;
-     if (Wnd)
+     if (Window)
      {
         if (Type == DCE_WINDOW_DC)
         {
-          if (Wnd->style & WS_CLIPCHILDREN) pDce->DCXFlags |= DCX_CLIPCHILDREN;
-          if (Wnd->style & WS_CLIPSIBLINGS) pDce->DCXFlags |= DCX_CLIPSIBLINGS;
+          if (Window->style & WS_CLIPCHILDREN) pDce->DCXFlags |= DCX_CLIPCHILDREN;
+          if (Window->style & WS_CLIPSIBLINGS) pDce->DCXFlags |= DCX_CLIPSIBLINGS;
         }
      }
   }
@@ -140,12 +138,11 @@ DceAllocDCE(PWINDOW_OBJECT Window OPTIONAL, DCE_TYPE Type)
 }
 
 static VOID APIENTRY
-DceSetDrawable( PWINDOW_OBJECT Window OPTIONAL,
+DceSetDrawable( PWND Window OPTIONAL,
                 HDC hDC,
                 ULONG Flags,
                 BOOL SetClipOrigin)
 {
-  PWND Wnd;
   DC *dc = DC_LockDc(hDC);
   if(!dc)
       return;
@@ -157,16 +154,15 @@ DceSetDrawable( PWINDOW_OBJECT Window OPTIONAL,
   }
   else
   {
-      Wnd = Window->Wnd;
       if (Flags & DCX_WINDOW)
       {
-         dc->ptlDCOrig.x = Wnd->rcWindow.left;
-         dc->ptlDCOrig.y = Wnd->rcWindow.top;
+         dc->ptlDCOrig.x = Window->rcWindow.left;
+         dc->ptlDCOrig.y = Window->rcWindow.top;
       }
       else
       {
-         dc->ptlDCOrig.x = Wnd->rcClient.left;
-         dc->ptlDCOrig.y = Wnd->rcClient.top;
+         dc->ptlDCOrig.x = Window->rcClient.left;
+         dc->ptlDCOrig.y = Window->rcClient.top;
       }
   }
   DC_UnlockDc(dc);
@@ -184,7 +180,7 @@ DceDeleteClipRgn(DCE* Dce)
    }
    else if (Dce->hrgnClip != NULL)
    {
-      GDIOBJ_FreeObjByHandle(Dce->hrgnClip, GDI_OBJECT_TYPE_REGION|GDI_OBJECT_TYPE_SILENT);
+      GreDeleteObject(Dce->hrgnClip);
    }
 
    Dce->hrgnClip = NULL;
@@ -230,7 +226,7 @@ DceReleaseDC(DCE* dce, BOOL EndPaint)
       }
       dce->DCXFlags &= ~DCX_DCEBUSY;
       DPRINT("Exit!!!!! DCX_CACHE!!!!!!   hDC-> %x \n", dce->hDC);
-      if (!IntGdiSetDCOwnerEx( dce->hDC, GDI_OBJ_HMGR_NONE, FALSE))
+      if (!GreSetDCOwner(dce->hDC, GDI_OBJ_HMGR_NONE))
          return 0;
       dce->ptiOwner = NULL; // Reset ownership.
       dce->ppiOwner = NULL;
@@ -251,22 +247,21 @@ DceReleaseDC(DCE* dce, BOOL EndPaint)
          }
          while (pLE != &LEDce );
       }
-#endif      
+#endif
    }
    return 1; // Released!
 }
 
 static VOID FASTCALL
-DceUpdateVisRgn(DCE *Dce, PWINDOW_OBJECT Window, ULONG Flags)
+DceUpdateVisRgn(DCE *Dce, PWND Window, ULONG Flags)
 {
    HANDLE hRgnVisible = NULL;
    ULONG DcxFlags;
-   PWINDOW_OBJECT DesktopWindow;
+   PWND DesktopWindow;
 
    if (Flags & DCX_PARENTCLIP)
    {
-      PWINDOW_OBJECT Parent;
-      PWND ParentWnd;
+      PWND Parent;
 
       Parent = Window->spwndParent;
       if(!Parent)
@@ -275,9 +270,7 @@ DceUpdateVisRgn(DCE *Dce, PWINDOW_OBJECT Window, ULONG Flags)
          goto noparent;
       }
 
-      ParentWnd = Parent->Wnd;
-
-      if (ParentWnd->style & WS_CLIPSIBLINGS)
+      if (Parent->style & WS_CLIPSIBLINGS)
       {
          DcxFlags = DCX_CLIPSIBLINGS |
                     (Flags & ~(DCX_CLIPCHILDREN | DCX_WINDOW));
@@ -286,14 +279,14 @@ DceUpdateVisRgn(DCE *Dce, PWINDOW_OBJECT Window, ULONG Flags)
       {
          DcxFlags = Flags & ~(DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_WINDOW);
       }
-      hRgnVisible = DceGetVisRgn(Parent, DcxFlags, Window->hSelf, Flags);
+      hRgnVisible = DceGetVisRgn(Parent, DcxFlags, Window->head.h, Flags);
    }
    else if (Window == NULL)
    {
       DesktopWindow = UserGetWindowObject(IntGetDesktopWindow());
       if (NULL != DesktopWindow)
       {
-         hRgnVisible = IntSysCreateRectRgnIndirect(&DesktopWindow->Wnd->rcWindow);
+         hRgnVisible = IntSysCreateRectRgnIndirect(&DesktopWindow->rcWindow);
       }
       else
       {
@@ -316,7 +309,7 @@ noparent:
       {
          if(hRgnVisible != NULL)
          {
-            REGION_FreeRgnByHandle(hRgnVisible);
+            GreDeleteObject(hRgnVisible);
          }
          hRgnVisible = IntSysCreateRectRgn(0, 0, 0, 0);
       }
@@ -336,29 +329,26 @@ noparent:
 
    if (hRgnVisible != NULL)
    {
-      REGION_FreeRgnByHandle(hRgnVisible);
+      GreDeleteObject(hRgnVisible);
    }
 }
 
 HDC FASTCALL
-UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
+UserGetDCEx(PWND Wnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
 {
-   PWINDOW_OBJECT Parent;
+   PWND Parent;
    ULONG DcxFlags;
    DCE* Dce = NULL;
    BOOL UpdateClipOrigin = FALSE;
-   PWND Wnd = NULL;
    HDC hDC = NULL;
    PPROCESSINFO ppi;
    PLIST_ENTRY pLE;
 
-   if (NULL == Window)
+   if (NULL == Wnd)
    {
       Flags &= ~DCX_USESTYLE;
       Flags |= DCX_CACHE;
    }
-   else
-       Wnd = Window->Wnd;
 
    if (Flags & (DCX_WINDOW | DCX_PARENTCLIP)) Flags |= DCX_CACHE;
 
@@ -423,9 +413,9 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       Flags &= ~(DCX_PARENTCLIP | DCX_CLIPCHILDREN);
    }
 
-   Parent = (Window ? Window->spwndParent : NULL);
+   Parent = (Wnd ? Wnd->spwndParent : NULL);
 
-   if (NULL == Window || !(Wnd->style & WS_CHILD) || NULL == Parent)
+   if (NULL == Wnd || !(Wnd->style & WS_CHILD) || NULL == Parent)
    {
       Flags &= ~DCX_PARENTCLIP;
       Flags |= DCX_CLIPSIBLINGS;
@@ -437,10 +427,10 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
    if (Flags & DCX_PARENTCLIP)
    {
       if ((Wnd->style & WS_VISIBLE) &&
-          (Parent->Wnd->style & WS_VISIBLE))
+          (Parent->style & WS_VISIBLE))
       {
          Flags &= ~DCX_CLIPCHILDREN;
-         if (Parent->Wnd->style & WS_CLIPSIBLINGS)
+         if (Parent->style & WS_CLIPSIBLINGS)
          {
             Flags |= DCX_CLIPSIBLINGS;
          }
@@ -472,7 +462,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
          if (!Dce) break;
 //
 // The way I understand this, you can have more than one DC per window.
-// Only one Owned if one was requested and saved and one Cached. 
+// Only one Owned if one was requested and saved and one Cached.
 //
          if ((Dce->DCXFlags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE)
          {
@@ -481,7 +471,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
             {
                DceEmpty = Dce;
             }
-            else if (Dce->hwndCurrent == (Window ? Window->hSelf : NULL) &&
+            else if (Dce->hwndCurrent == (Wnd ? Wnd->head.h : NULL) &&
                      ((Dce->DCXFlags & DCX_CACHECOMPAREMASK) == DcxFlags))
             {
                UpdateClipOrigin = TRUE;
@@ -502,7 +492,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       }
       if (!Dce) return NULL;
 
-      Dce->hwndCurrent = (Window ? Window->hSelf : NULL);
+      Dce->hwndCurrent = (Wnd ? Wnd->head.h : NULL);
    }
    else // If we are here, we are POWNED or having CLASS.
    {
@@ -511,7 +501,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       Dce = CONTAINING_RECORD(pLE, DCE, List);
       do
       {   // Check for Window handle than HDC match for CLASS.
-          if ((Dce->hwndCurrent == Window->hSelf) ||
+          if ((Dce->hwndCurrent == Wnd->head.h) ||
               (Dce->hDC == hDC))
              break;
           pLE = Dce->List.Flink;
@@ -521,7 +511,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       KeLeaveCriticalRegion();
 
       if ( (Flags & (DCX_INTERSECTRGN|DCX_EXCLUDERGN)) &&
-           (Dce->DCXFlags & (DCX_INTERSECTRGN|DCX_EXCLUDERGN)) )          
+           (Dce->DCXFlags & (DCX_INTERSECTRGN|DCX_EXCLUDERGN)) )
       {
           DceDeleteClipRgn(Dce);
       }
@@ -532,7 +522,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       return(NULL);
    }
 
-   if (!GDIOBJ_ValidateHandle(Dce->hDC, GDI_OBJECT_TYPE_DC))
+   if (!GreIsHandleValid(Dce->hDC))
    {
       DPRINT1("FIXME: Got DCE with invalid hDC! 0x%x\n", Dce->hDC);
       Dce->hDC = DceCreateDisplayDC();
@@ -559,18 +549,18 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
    {
       Flags |= DCX_INTERSECTRGN | DCX_KEEPCLIPRGN;
       Dce->DCXFlags |= DCX_INTERSECTRGN | DCX_KEEPCLIPRGN;
-      ClipRegion = Window->hrgnUpdate;
+      ClipRegion = Wnd->hrgnUpdate;
    }
 
-   if (ClipRegion == (HRGN) 1)
+   if (ClipRegion == HRGN_WINDOW)
    {
       if (!(Flags & DCX_WINDOW))
       {
-         Dce->hrgnClip = IntSysCreateRectRgnIndirect(&Window->Wnd->rcClient);
+         Dce->hrgnClip = IntSysCreateRectRgnIndirect(&Wnd->rcClient);
       }
       else
       {
-         Dce->hrgnClip = IntSysCreateRectRgnIndirect(&Window->Wnd->rcWindow);
+         Dce->hrgnClip = IntSysCreateRectRgnIndirect(&Wnd->rcWindow);
       }
       Dce->DCXFlags &= ~DCX_KEEPCLIPRGN;
    }
@@ -579,21 +569,21 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       if (Dce->hrgnClip != NULL)
       {
          DPRINT1("Should not be called!!\n");
-         GDIOBJ_FreeObjByHandle(Dce->hrgnClip, GDI_OBJECT_TYPE_REGION|GDI_OBJECT_TYPE_SILENT);
+         GreDeleteObject(Dce->hrgnClip);
          Dce->hrgnClip = NULL;
       }
       Dce->hrgnClip = ClipRegion;
    }
 
-   DceSetDrawable(Window, Dce->hDC, Flags, UpdateClipOrigin);
+   DceSetDrawable(Wnd, Dce->hDC, Flags, UpdateClipOrigin);
 
-   DceUpdateVisRgn(Dce, Window, Flags);
+   DceUpdateVisRgn(Dce, Wnd, Flags);
 
    if (Dce->DCXFlags & DCX_CACHE)
    {
       DPRINT("ENTER!!!!!! DCX_CACHE!!!!!!   hDC-> %x\n", Dce->hDC);
       // Need to set ownership so Sync dcattr will work.
-      IntGdiSetDCOwnerEx( Dce->hDC, GDI_OBJ_HMGR_POWNED, FALSE);
+      GreSetDCOwner(Dce->hDC, GDI_OBJ_HMGR_POWNED);
       Dce->ptiOwner = GetW32ThreadInfo(); // Set the temp owning
    }
 
@@ -604,7 +594,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       NtGdiSetLayout(Dce->hDC, -1, LAYOUT_RTL);
    }
 
-   if (Dce->DCXFlags & DCX_PROCESSOWNED) 
+   if (Dce->DCXFlags & DCX_PROCESSOWNED)
    {
       ppi = PsGetCurrentProcessWin32Process();
       ppi->W32PF_flags |= W32PF_OWNDCCLEANUP;
@@ -632,13 +622,14 @@ DceFreeDCE(PDCE pdce, BOOLEAN Force)
 
   pdce->DCXFlags |= DCX_INDESTROY;
 
-  if (Force && !GDIOBJ_OwnedByCurrentProcess(pdce->hDC))
+  if (Force &&
+      GreGetObjectOwner(pdce->hDC) != GDI_OBJ_HMGR_POWNED)
   {
      DPRINT("Change ownership for DCE! -> %x\n" , pdce);
      // Note: Windows sets W32PF_OWNDCCLEANUP and moves on.
-     if (!IsObjectDead((HGDIOBJ) pdce->hDC))
+     if (GreIsHandleValid(pdce->hDC))
      {
-         DC_SetOwnership( pdce->hDC, PsGetCurrentProcess());
+         GreSetDCOwner(pdce->hDC, GDI_OBJ_HMGR_POWNED);
      }
      else
      {
@@ -648,15 +639,15 @@ DceFreeDCE(PDCE pdce, BOOLEAN Force)
   }
   else
   {
-     if (!GreGetObjectOwner(pdce->hDC, GDIObjType_DC_TYPE))
-        DC_SetOwnership( pdce->hDC, PsGetCurrentProcess());
+     if (GreGetObjectOwner(pdce->hDC) == GDI_OBJ_HMGR_PUBLIC)
+        GreSetDCOwner(pdce->hDC, GDI_OBJ_HMGR_POWNED);
   }
 
   if (!Hit) IntGdiDeleteDC(pdce->hDC, TRUE);
 
   if (pdce->hrgnClip && !(pdce->DCXFlags & DCX_KEEPCLIPRGN))
   {
-      GDIOBJ_FreeObjByHandle(pdce->hrgnClip, GDI_OBJECT_TYPE_REGION|GDI_OBJECT_TYPE_SILENT);
+      GreDeleteObject(pdce->hrgnClip);
       pdce->hrgnClip = NULL;
   }
 
@@ -668,7 +659,7 @@ DceFreeDCE(PDCE pdce, BOOLEAN Force)
       return NULL;
   }
 
-  ExFreePoolWithTag(pdce, TAG_PDCE);
+  ExFreePoolWithTag(pdce, USERTAG_DCE);
 
   DCECount--;
   DPRINT("Freed DCE's! %d \n", DCECount);
@@ -682,7 +673,7 @@ DceFreeDCE(PDCE pdce, BOOLEAN Force)
  * Remove owned DCE and reset unreleased cache DCEs.
  */
 void FASTCALL
-DceFreeWindowDCE(PWINDOW_OBJECT Window)
+DceFreeWindowDCE(PWND Window)
 {
   PDCE pDCE;
   PLIST_ENTRY pLE;
@@ -707,12 +698,12 @@ DceFreeWindowDCE(PWINDOW_OBJECT Window)
         DPRINT1("FreeWindowDCE List is Empty!!!!\n");
         break;
      }
-     if ( pDCE->hwndCurrent == Window->hSelf &&
+     if ( pDCE->hwndCurrent == Window->head.h &&
           !(pDCE->DCXFlags & DCX_DCEEMPTY) )
      {
         if (!(pDCE->DCXFlags & DCX_CACHE)) /* owned or Class DCE*/
         {
-           if (Window->Wnd->pcls->style & CS_CLASSDC) /* Test Class first */
+           if (Window->pcls->style & CS_CLASSDC) /* Test Class first */
            {
               if (pDCE->DCXFlags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) /* Class DCE*/
                  DceDeleteClipRgn(pDCE);
@@ -723,14 +714,14 @@ DceFreeWindowDCE(PWINDOW_OBJECT Window)
               pDCE->hwndCurrent = 0;
 
               DPRINT("POWNED DCE going Cheap!! DCX_CACHE!! hDC-> %x \n", pDCE->hDC);
-              if (!IntGdiSetDCOwnerEx( pDCE->hDC, GDI_OBJ_HMGR_NONE, FALSE))
+              if (!GreSetDCOwner( pDCE->hDC, GDI_OBJ_HMGR_NONE))
               {
                   DPRINT1("Fail Owner Switch hDC-> %x \n", pDCE->hDC);
                   break;
               }
               /* Do not change owner so thread can clean up! */
            }
-           else if (Window->Wnd->pcls->style & CS_OWNDC) /* owned DCE*/
+           else if (Window->pcls->style & CS_OWNDC) /* owned DCE*/
            {
               pDCE = DceFreeDCE(pDCE, FALSE);
               if (!pDCE) break;
@@ -753,7 +744,7 @@ DceFreeWindowDCE(PWINDOW_OBJECT Window)
                * We should change this to DPRINT when ReactOS is more stable
                * (for 1.0?).
                */
-              DPRINT1("[%p] GetDC() without ReleaseDC()!\n", Window->hSelf);
+              DPRINT1("[%p] GetDC() without ReleaseDC()!\n", Window->head.h);
               DceReleaseDC(pDCE, FALSE);
            }
            pDCE->DCXFlags |= DCX_DCEEMPTY;
@@ -833,11 +824,11 @@ DceEmptyCache(VOID)
 }
 
 VOID FASTCALL
-DceResetActiveDCEs(PWINDOW_OBJECT Window)
+DceResetActiveDCEs(PWND Window)
 {
    DCE *pDCE;
    PDC dc;
-   PWINDOW_OBJECT CurrentWindow;
+   PWND CurrentWindow;
    INT DeltaX;
    INT DeltaY;
    PLIST_ENTRY pLE;
@@ -848,14 +839,14 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
    }
    pLE = LEDce.Flink;
    pDCE = CONTAINING_RECORD(pLE, DCE, List);
-   if(!pDCE) return; // Another null test!
+
    do
    {
       if(!pDCE) break;
       if(pLE == &LEDce) break;
       if (0 == (pDCE->DCXFlags & (DCX_DCEEMPTY|DCX_INDESTROY)))
       {
-         if (Window->hSelf == pDCE->hwndCurrent)
+         if (Window->head.h == pDCE->hwndCurrent)
          {
             CurrentWindow = Window;
          }
@@ -870,7 +861,7 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
             }
          }
 
-         if (!GDIOBJ_ValidateHandle(pDCE->hDC, GDI_OBJECT_TYPE_DC) ||
+         if (!GreIsHandleValid(pDCE->hDC) ||
              (dc = DC_LockDc(pDCE->hDC)) == NULL)
          {
             pLE = pDCE->List.Flink;
@@ -881,17 +872,17 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
          {
             if (pDCE->DCXFlags & DCX_WINDOW)
             {
-               DeltaX = CurrentWindow->Wnd->rcWindow.left - dc->ptlDCOrig.x;
-               DeltaY = CurrentWindow->Wnd->rcWindow.top - dc->ptlDCOrig.y;
-               dc->ptlDCOrig.x = CurrentWindow->Wnd->rcWindow.left;
-               dc->ptlDCOrig.y = CurrentWindow->Wnd->rcWindow.top;
+               DeltaX = CurrentWindow->rcWindow.left - dc->ptlDCOrig.x;
+               DeltaY = CurrentWindow->rcWindow.top - dc->ptlDCOrig.y;
+               dc->ptlDCOrig.x = CurrentWindow->rcWindow.left;
+               dc->ptlDCOrig.y = CurrentWindow->rcWindow.top;
             }
             else
             {
-               DeltaX = CurrentWindow->Wnd->rcClient.left - dc->ptlDCOrig.x;
-               DeltaY = CurrentWindow->Wnd->rcClient.top - dc->ptlDCOrig.y;
-               dc->ptlDCOrig.x = CurrentWindow->Wnd->rcClient.left;
-               dc->ptlDCOrig.y = CurrentWindow->Wnd->rcClient.top;
+               DeltaX = CurrentWindow->rcClient.left - dc->ptlDCOrig.x;
+               DeltaY = CurrentWindow->rcClient.top - dc->ptlDCOrig.y;
+               dc->ptlDCOrig.x = CurrentWindow->rcClient.left;
+               dc->ptlDCOrig.y = CurrentWindow->rcClient.top;
             }
             if (NULL != dc->rosdc.hClipRgn)
             {
@@ -907,7 +898,7 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
 
          DceUpdateVisRgn(pDCE, CurrentWindow, pDCE->DCXFlags);
 
-         if (Window->hSelf != pDCE->hwndCurrent)
+         if (Window->head.h != pDCE->hwndCurrent)
          {
 //            IntEngWindowChanged(CurrentWindow, WOC_RGN_CLIENT);
 //            UserDerefObject(CurrentWindow);
@@ -946,7 +937,7 @@ IntWindowFromDC(HDC hDc)
 }
 
 INT FASTCALL
-UserReleaseDC(PWINDOW_OBJECT Window, HDC hDc, BOOL EndPaint)
+UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
 {
   PDCE dce;
   PLIST_ENTRY pLE;
@@ -978,7 +969,7 @@ UserReleaseDC(PWINDOW_OBJECT Window, HDC hDc, BOOL EndPaint)
 }
 
 HDC FASTCALL
-UserGetWindowDC(PWINDOW_OBJECT Wnd)
+UserGetWindowDC(PWND Wnd)
 {
   return UserGetDCEx(Wnd, 0, DCX_USESTYLE | DCX_WINDOW);
 }
@@ -987,7 +978,7 @@ HWND FASTCALL
 UserGethWnd( HDC hdc, PWNDOBJ *pwndo)
 {
   PWNDGDI pWndgdi;
-  PWINDOW_OBJECT Wnd;
+  PWND Wnd;
   HWND hWnd;
 
   hWnd = IntWindowFromDC(hdc);
@@ -1007,7 +998,7 @@ UserGethWnd( HDC hdc, PWNDOBJ *pwndo)
 HDC APIENTRY
 NtUserGetDCEx(HWND hWnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
 {
-  PWINDOW_OBJECT Wnd=NULL;
+  PWND Wnd=NULL;
   DECLARE_RETURN(HDC);
 
   DPRINT("Enter NtUserGetDCEx\n");