[NtUser]
[reactos.git] / reactos / win32ss / user / ntuser / windc.c
index e3f8d8b..96b1f18 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PROJECT:         ReactOS Win32k subsystem
  * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            subsystems/win32/win32k/ntuser/windc.c
+ * FILE:            win32ss/user/ntuser/windc.c
  * PURPOSE:         Window DC management
  * COPYRIGHT:       Copyright 2007 ReactOS Team
  */
@@ -146,30 +146,22 @@ DceSetDrawable( PWND Window OPTIONAL,
                 ULONG Flags,
                 BOOL SetClipOrigin)
 {
-  DC *dc = DC_LockDc(hDC);
-  if(!dc)
-      return;
+  RECTL rect;
 
-  if (Window == NULL)
-  {
-      dc->ptlDCOrig.x = 0;
-      dc->ptlDCOrig.y = 0;
-  }
-  else
+  if (Window)
   {
       if (Flags & DCX_WINDOW)
       {
-         dc->ptlDCOrig.x = Window->rcWindow.left;
-         dc->ptlDCOrig.y = Window->rcWindow.top;
+         rect = Window->rcWindow;
       }
       else
       {
-         dc->ptlDCOrig.x = Window->rcClient.left;
-         dc->ptlDCOrig.y = Window->rcClient.top;
+         rect = Window->rcClient;
       }
   }
-  dc->fs |= DC_FLAG_DIRTY_RAO;
-  DC_UnlockDc(dc);
+
+  /* Set DC Origin and Window Rectangle */
+  GreSetDCOrg( hDC, rect.left, rect.top, &rect);
 }
 
 
@@ -366,7 +358,7 @@ UserGetDCEx(PWND Wnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       Flags |= DCX_CACHE;
    }
 
-   if (Flags & (DCX_WINDOW | DCX_PARENTCLIP)) Flags |= DCX_CACHE;
+   if (Flags & DCX_PARENTCLIP) Flags |= DCX_CACHE;
 
    // When GetDC is called with hWnd nz, DCX_CACHE & _WINDOW are clear w _USESTYLE set.
    if (Flags & DCX_USESTYLE)
@@ -403,11 +395,7 @@ UserGetDCEx(PWND Wnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
             Flags |= DCX_CLIPCHILDREN;
          }
          /* If minized with icon in the set, we are forced to be cheap! */
-#ifdef NEW_CURSORICON
          if (Wnd->style & WS_MINIMIZE && Wnd->pcls->spicn)
-#else
-         if (Wnd->style & WS_MINIMIZE && Wnd->pcls->hIcon)
-#endif
          {
             Flags |= DCX_CACHE;
          }
@@ -488,6 +476,7 @@ UserGetDCEx(PWND Wnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
                break;
             }
          }
+         Dce = NULL; // Loop issue?
       }
       KeLeaveCriticalRegion();
 
@@ -497,7 +486,7 @@ UserGetDCEx(PWND Wnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       {
          Dce = DceAllocDCE(NULL, DCE_CACHE_DC);
       }
-      if (!Dce) return NULL;
+      if (Dce == NULL) return NULL;
 
       Dce->hwndCurrent = (Wnd ? Wnd->head.h : NULL);
       Dce->pwndOrg = Dce->pwndClip = Wnd;
@@ -510,20 +499,31 @@ UserGetDCEx(PWND Wnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
       {
           Dce = CONTAINING_RECORD(ListEntry, DCE, List);
           ListEntry = ListEntry->Flink;
-          // Check for Window handle than HDC match for CLASS.
-          if (Dce->hwndCurrent == Wnd->head.h)
+
+          // Skip Cache DCE entries.
+          if (!(Dce->DCXFlags & DCX_CACHE))
           {
-             bUpdateVisRgn = FALSE;
-             break;
+             // Check for Window handle than HDC match for CLASS.
+             if (Dce->hwndCurrent == Wnd->head.h)
+             {
+                bUpdateVisRgn = FALSE;
+                break;
+             }
+             else if (Dce->hDC == hDC) break;
           }
-          if (Dce->hDC == hDC) break;
+          Dce = NULL; // Loop issue?
       }
       KeLeaveCriticalRegion();
 
+      if (Dce == NULL)
+      {
+         return(NULL);
+      }
+
       if ( (Flags & (DCX_INTERSECTRGN|DCX_EXCLUDERGN)) &&
            (Dce->DCXFlags & (DCX_INTERSECTRGN|DCX_EXCLUDERGN)) )
       {
-          DceDeleteClipRgn(Dce);
+         DceDeleteClipRgn(Dce);
       }
    }
 // First time use hax, need to use DceAllocDCE during window display init.
@@ -758,7 +758,7 @@ DceFreeWindowDCE(PWND Window)
 }
 
 void FASTCALL
-DceFreeClassDCE(HDC hDC)
+DceFreeClassDCE(PDCE pdceClass)
 {
    PDCE pDCE;
    PLIST_ENTRY ListEntry;
@@ -768,7 +768,7 @@ DceFreeClassDCE(HDC hDC)
    {
        pDCE = CONTAINING_RECORD(ListEntry, DCE, List);
        ListEntry = ListEntry->Flink;
-       if (pDCE->hDC == hDC)
+       if (pDCE == pdceClass)
        {
           DceFreeDCE(pDCE, TRUE); // Might have gone cheap!
        }
@@ -873,7 +873,7 @@ DceResetActiveDCEs(PWND Window)
 
             if (NULL != dc->dclevel.prgnClip)
             {
-               IntGdiOffsetRgn(dc->dclevel.prgnClip, DeltaX, DeltaY);
+               REGION_bOffsetRgn(dc->dclevel.prgnClip, DeltaX, DeltaY);
                dc->fs |= DC_FLAG_DIRTY_RAO;
             }
             if (NULL != pDCE->hrgnClip)
@@ -954,15 +954,12 @@ UserGethWnd( HDC hdc, PWNDOBJ *pwndo)
   XCLIPOBJ* Clip;
   PWND Wnd;
   HWND hWnd;
-  PPROPERTY pprop;
 
   hWnd = IntWindowFromDC(hdc);
 
   if (hWnd && (Wnd = UserGetWindowObject(hWnd)))
   {
-     pprop = IntGetProp(Wnd, AtomWndObj);
-
-     Clip = (XCLIPOBJ*)pprop->Data;
+     Clip = (XCLIPOBJ*)UserGetProp(Wnd, AtomWndObj, TRUE);
 
      if ( Clip && Clip->Hwnd == hWnd )
      {