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;
static
HRGN FASTCALL
-DceGetVisRgn(PWINDOW_OBJECT Window, ULONG Flags, HWND hWndChild, ULONG CFlags)
+DceGetVisRgn(PWND Window, ULONG Flags, HWND hWndChild, ULONG CFlags)
{
HRGN VisRgn;
}
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;
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;
}
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;
}
}
}
}
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;
}
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);
}
else if (Dce->hrgnClip != NULL)
{
- GDIOBJ_FreeObjByHandle(Dce->hrgnClip, GDI_OBJECT_TYPE_REGION|GDI_OBJECT_TYPE_SILENT);
+ GreDeleteObject(Dce->hrgnClip);
}
Dce->hrgnClip = NULL;
}
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;
}
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)
goto noparent;
}
- ParentWnd = Parent->Wnd;
-
- if (ParentWnd->style & WS_CLIPSIBLINGS)
+ if (Parent->style & WS_CLIPSIBLINGS)
{
DcxFlags = DCX_CLIPSIBLINGS |
(Flags & ~(DCX_CLIPCHILDREN | DCX_WINDOW));
{
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
{
{
if(hRgnVisible != NULL)
{
- REGION_FreeRgnByHandle(hRgnVisible);
+ GreDeleteObject(hRgnVisible);
}
hRgnVisible = IntSysCreateRectRgn(0, 0, 0, 0);
}
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;
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;
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;
}
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)
{
{
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;
}
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.
{
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;
KeLeaveCriticalRegion();
if ( (Flags & (DCX_INTERSECTRGN|DCX_EXCLUDERGN)) &&
- (Dce->DCXFlags & (DCX_INTERSECTRGN|DCX_EXCLUDERGN)) )
+ (Dce->DCXFlags & (DCX_INTERSECTRGN|DCX_EXCLUDERGN)) )
{
DceDeleteClipRgn(Dce);
}
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();
{
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;
}
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
}
NtGdiSetLayout(Dce->hDC, -1, LAYOUT_RTL);
}
- if (Dce->DCXFlags & DCX_PROCESSOWNED)
+ if (Dce->DCXFlags & DCX_PROCESSOWNED)
{
ppi = PsGetCurrentProcessWin32Process();
ppi->W32PF_flags |= W32PF_OWNDCCLEANUP;
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
{
}
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;
}
return NULL;
}
- ExFreePoolWithTag(pdce, TAG_PDCE);
+ ExFreePoolWithTag(pdce, USERTAG_DCE);
DCECount--;
DPRINT("Freed DCE's! %d \n", DCECount);
* Remove owned DCE and reset unreleased cache DCEs.
*/
void FASTCALL
-DceFreeWindowDCE(PWINDOW_OBJECT Window)
+DceFreeWindowDCE(PWND Window)
{
PDCE pDCE;
PLIST_ENTRY pLE;
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);
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;
* 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;
}
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;
}
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;
}
}
}
- if (!GDIOBJ_ValidateHandle(pDCE->hDC, GDI_OBJECT_TYPE_DC) ||
+ if (!GreIsHandleValid(pDCE->hDC) ||
(dc = DC_LockDc(pDCE->hDC)) == NULL)
{
pLE = pDCE->List.Flink;
{
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)
{
DceUpdateVisRgn(pDCE, CurrentWindow, pDCE->DCXFlags);
- if (Window->hSelf != pDCE->hwndCurrent)
+ if (Window->head.h != pDCE->hwndCurrent)
{
// IntEngWindowChanged(CurrentWindow, WOC_RGN_CLIENT);
// UserDerefObject(CurrentWindow);
}
INT FASTCALL
-UserReleaseDC(PWINDOW_OBJECT Window, HDC hDc, BOOL EndPaint)
+UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
{
PDCE dce;
PLIST_ENTRY pLE;
}
HDC FASTCALL
-UserGetWindowDC(PWINDOW_OBJECT Wnd)
+UserGetWindowDC(PWND Wnd)
{
return UserGetDCEx(Wnd, 0, DCX_USESTYLE | DCX_WINDOW);
}
UserGethWnd( HDC hdc, PWNDOBJ *pwndo)
{
PWNDGDI pWndgdi;
- PWINDOW_OBJECT Wnd;
+ PWND Wnd;
HWND hWnd;
hWnd = IntWindowFromDC(hdc);
HDC APIENTRY
NtUserGetDCEx(HWND hWnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
{
- PWINDOW_OBJECT Wnd=NULL;
+ PWND Wnd=NULL;
DECLARE_RETURN(HDC);
DPRINT("Enter NtUserGetDCEx\n");