2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: subsystems/win32/win32k/ntuser/windc.c
5 * PURPOSE: Window DC management
6 * COPYRIGHT: Copyright 2007 ReactOS
10 /* INCLUDES ******************************************************************/
17 /* GLOBALS *******************************************************************/
19 /* NOTE - I think we should store this per window station (including gdi objects) */
21 static PDCE FirstDce
= NULL
;
22 //static INT DCECount = 0; // Count of DCE in system.
24 #define DCX_CACHECOMPAREMASK (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | \
25 DCX_CACHE | DCX_WINDOW | DCX_PARENTCLIP)
27 /* FUNCTIONS *****************************************************************/
30 // This should be moved to dc.c or dcutil.c.
33 DceCreateDisplayDC(VOID
)
36 UNICODE_STRING DriverName
;
37 RtlInitUnicodeString(&DriverName
, L
"DISPLAY");
38 hDC
= IntGdiCreateDC(&DriverName
, NULL
, NULL
, NULL
, FALSE
);
40 // If NULL, first time through! Build the default window dc!
42 if (hDC
&& !defaultDCstate
) // Ultra HAX! Dedicated to GvG!
43 { // This is a cheesy way to do this.
44 PDC dc
= DC_LockDc ( hDC
);
45 defaultDCstate
= ExAllocatePoolWithTag(PagedPool
, sizeof(DC
), TAG_DC
);
46 RtlZeroMemory(defaultDCstate
, sizeof(DC
));
47 defaultDCstate
->pdcattr
= &defaultDCstate
->dcattr
;
48 DC_vCopyState(dc
, defaultDCstate
);
56 DceGetVisRgn(PWINDOW_OBJECT Window
, ULONG Flags
, HWND hWndChild
, ULONG CFlags
)
60 VisRgn
= VIS_ComputeVisibleRegion( Window
,
61 0 == (Flags
& DCX_WINDOW
),
62 0 != (Flags
& DCX_CLIPCHILDREN
),
63 0 != (Flags
& DCX_CLIPSIBLINGS
));
66 VisRgn
= NtGdiCreateRectRgn(0, 0, 0, 0);
73 DceAllocDCE(PWINDOW_OBJECT Window OPTIONAL
, DCE_TYPE Type
)
78 if (Window
) Wnd
= Window
->Wnd
;
80 pDce
= ExAllocatePoolWithTag(PagedPool
, sizeof(DCE
), TAG_PDCE
);
84 pDce
->hDC
= DceCreateDisplayDC();
87 ExFreePoolWithTag(pDce
, TAG_PDCE
);
91 pDce
->hwndCurrent
= (Window
? Window
->hSelf
: NULL
);
92 pDce
->hClipRgn
= NULL
;
93 pDce
->pProcess
= NULL
;
95 KeEnterCriticalRegion();
99 InitializeListHead(&FirstDce
->List
);
102 InsertTailList(&FirstDce
->List
, &pDce
->List
);
103 KeLeaveCriticalRegion();
105 DCU_SetDcUndeletable(pDce
->hDC
);
107 if (Type
== DCE_WINDOW_DC
|| Type
== DCE_CLASS_DC
) //Window DCE have ownership.
108 { // Process should already own it.
109 pDce
->pProcess
= PsGetCurrentProcess();
113 DPRINT("FREE DCATTR!!!! NOT DCE_WINDOW_DC!!!!! hDC-> %x\n", pDce
->hDC
);
114 IntGdiSetDCOwnerEx( pDce
->hDC
, GDI_OBJ_HMGR_NONE
, FALSE
);
117 if (Type
== DCE_CACHE_DC
)
119 pDce
->DCXFlags
= DCX_CACHE
| DCX_DCEEMPTY
;
123 pDce
->DCXFlags
= DCX_DCEBUSY
;
126 if (Type
== DCE_WINDOW_DC
)
128 if (Wnd
->style
& WS_CLIPCHILDREN
) pDce
->DCXFlags
|= DCX_CLIPCHILDREN
;
129 if (Wnd
->style
& WS_CLIPSIBLINGS
) pDce
->DCXFlags
|= DCX_CLIPSIBLINGS
;
137 DceSetDrawable(PWINDOW_OBJECT Window OPTIONAL
, HDC hDC
, ULONG Flags
,
141 DC
*dc
= DC_LockDc(hDC
);
153 if (Flags
& DCX_WINDOW
)
155 dc
->ptlDCOrig
.x
= Wnd
->rcWindow
.left
;
156 dc
->ptlDCOrig
.y
= Wnd
->rcWindow
.top
;
160 dc
->ptlDCOrig
.x
= Wnd
->rcClient
.left
;
161 dc
->ptlDCOrig
.y
= Wnd
->rcClient
.top
;
169 DceDeleteClipRgn(DCE
* Dce
)
171 Dce
->DCXFlags
&= ~(DCX_EXCLUDERGN
| DCX_INTERSECTRGN
);
173 if (Dce
->DCXFlags
& DCX_KEEPCLIPRGN
)
175 Dce
->DCXFlags
&= ~DCX_KEEPCLIPRGN
;
177 else if (Dce
->hClipRgn
!= NULL
)
179 GreDeleteObject(Dce
->hClipRgn
);
182 Dce
->hClipRgn
= NULL
;
184 /* make it dirty so that the vis rgn gets recomputed next time */
185 Dce
->DCXFlags
|= DCX_DCEDIRTY
;
189 DceReleaseDC(DCE
* dce
, BOOL EndPaint
)
191 if (DCX_DCEBUSY
!= (dce
->DCXFlags
& (DCX_DCEEMPTY
| DCX_DCEBUSY
)))
196 /* restore previous visible region */
198 if ((dce
->DCXFlags
& (DCX_INTERSECTRGN
| DCX_EXCLUDERGN
)) &&
199 ((dce
->DCXFlags
& DCX_CACHE
) || EndPaint
))
201 DceDeleteClipRgn(dce
);
204 if (dce
->DCXFlags
& DCX_CACHE
)
206 if (!(dce
->DCXFlags
& DCX_NORESETATTRS
))
208 /* make the DC clean so that SetDCState doesn't try to update the vis rgn */
209 IntGdiSetHookFlags(dce
->hDC
, DCHF_VALIDATEVISRGN
);
212 if (!IntGdiCleanDC(dce
->hDC
)) return 0;
214 if (dce
->DCXFlags
& DCX_DCEDIRTY
)
216 /* don't keep around invalidated entries
217 * because SetDCState() disables hVisRgn updates
218 * by removing dirty bit. */
219 dce
->hwndCurrent
= 0;
220 dce
->DCXFlags
&= DCX_CACHE
;
221 dce
->DCXFlags
|= DCX_DCEEMPTY
;
224 dce
->DCXFlags
&= ~DCX_DCEBUSY
;
225 DPRINT("Exit!!!!! DCX_CACHE!!!!!! hDC-> %x \n", dce
->hDC
);
226 if (!IntGdiSetDCOwnerEx( dce
->hDC
, GDI_OBJ_HMGR_NONE
, FALSE
))
228 dce
->pProcess
= NULL
; // Reset ownership.
230 return 1; // Released!
234 DceUpdateVisRgn(DCE
*Dce
, PWINDOW_OBJECT Window
, ULONG Flags
)
236 HANDLE hRgnVisible
= NULL
;
238 PWINDOW_OBJECT DesktopWindow
;
240 if (Flags
& DCX_PARENTCLIP
)
242 PWINDOW_OBJECT Parent
;
245 Parent
= Window
->spwndParent
;
252 ParentWnd
= Parent
->Wnd
;
254 if (ParentWnd
->style
& WS_CLIPSIBLINGS
)
256 DcxFlags
= DCX_CLIPSIBLINGS
|
257 (Flags
& ~(DCX_CLIPCHILDREN
| DCX_WINDOW
));
261 DcxFlags
= Flags
& ~(DCX_CLIPSIBLINGS
| DCX_CLIPCHILDREN
| DCX_WINDOW
);
263 hRgnVisible
= DceGetVisRgn(Parent
, DcxFlags
, Window
->hSelf
, Flags
);
265 else if (Window
== NULL
)
267 DesktopWindow
= UserGetWindowObject(IntGetDesktopWindow());
268 if (NULL
!= DesktopWindow
)
270 hRgnVisible
= UnsafeIntCreateRectRgnIndirect(&DesktopWindow
->Wnd
->rcWindow
);
279 hRgnVisible
= DceGetVisRgn(Window
, Flags
, 0, 0);
283 if (Flags
& DCX_INTERSECTRGN
)
285 if(Dce
->hClipRgn
!= NULL
)
287 NtGdiCombineRgn(hRgnVisible
, hRgnVisible
, Dce
->hClipRgn
, RGN_AND
);
291 if(hRgnVisible
!= NULL
)
293 GreDeleteObject(hRgnVisible
);
295 hRgnVisible
= NtGdiCreateRectRgn(0, 0, 0, 0);
299 if (Flags
& DCX_EXCLUDERGN
&& Dce
->hClipRgn
!= NULL
)
301 NtGdiCombineRgn(hRgnVisible
, hRgnVisible
, Dce
->hClipRgn
, RGN_DIFF
);
304 Dce
->DCXFlags
&= ~DCX_DCEDIRTY
;
305 GdiSelectVisRgn(Dce
->hDC
, hRgnVisible
);
309 IntEngWindowChanged(Window
, WOC_RGN_CLIENT
);
312 if (hRgnVisible
!= NULL
)
314 GreDeleteObject(hRgnVisible
);
319 UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL
, HANDLE ClipRegion
, ULONG Flags
)
321 PWINDOW_OBJECT Parent
;
324 BOOL UpdateVisRgn
= TRUE
;
325 BOOL UpdateClipOrigin
= FALSE
;
331 Flags
&= ~DCX_USESTYLE
;
337 if (Flags
& (DCX_WINDOW
| DCX_PARENTCLIP
)) Flags
|= DCX_CACHE
;
339 // When GetDC is called with hWnd nz, DCX_CACHE & _WINDOW are clear w _USESTYLE set.
340 if (Flags
& DCX_USESTYLE
)
342 Flags
&= ~(DCX_CLIPCHILDREN
| DCX_CLIPSIBLINGS
| DCX_PARENTCLIP
);
343 if (!(Flags
& DCX_WINDOW
)) // not window rectangle
345 if (Wnd
->pcls
->style
& CS_PARENTDC
)
347 Flags
|= DCX_PARENTCLIP
;
350 if (!(Flags
& DCX_CACHE
) && // Not on the cheap wine list.
351 !(Wnd
->pcls
->style
& CS_OWNDC
) )
353 if (!(Wnd
->pcls
->style
& CS_CLASSDC
))
354 // The window is not POWNED or has any CLASS, so we are looking for cheap wine.
358 if (Wnd
->pcls
->pdce
) hDC
= ((PDCE
)Wnd
->pcls
->pdce
)->hDC
;
359 DPRINT("We have CLASS!!\n");
362 /* else // For Testing!
364 DPRINT1("We have POWNER!!\n");
365 if (Window->Dce) DPRINT1("We have POWNER with DCE!!\n");
368 if (Wnd
->style
& WS_CLIPSIBLINGS
)
370 Flags
|= DCX_CLIPSIBLINGS
;
373 if (Wnd
->style
& WS_CLIPCHILDREN
&&
374 !(Wnd
->style
& WS_MINIMIZE
))
376 Flags
|= DCX_CLIPCHILDREN
;
381 if (Wnd
->style
& WS_CLIPSIBLINGS
) Flags
|= DCX_CLIPSIBLINGS
;
386 if (Flags
& DCX_WINDOW
) Flags
&= ~DCX_CLIPCHILDREN
;
388 if (Flags
& DCX_NOCLIPCHILDREN
)
391 Flags
&= ~(DCX_PARENTCLIP
| DCX_CLIPCHILDREN
);
394 Parent
= (Window
? Window
->spwndParent
: NULL
);
396 if (NULL
== Window
|| !(Wnd
->style
& WS_CHILD
) || NULL
== Parent
)
398 Flags
&= ~DCX_PARENTCLIP
;
399 Flags
|= DCX_CLIPSIBLINGS
;
402 /* it seems parent clip is ignored when clipping siblings or children */
403 if (Flags
& (DCX_CLIPSIBLINGS
| DCX_CLIPCHILDREN
)) Flags
&= ~DCX_PARENTCLIP
;
405 if (Flags
& DCX_PARENTCLIP
)
407 if ((Wnd
->style
& WS_VISIBLE
) &&
408 (Parent
->Wnd
->style
& WS_VISIBLE
))
410 Flags
&= ~DCX_CLIPCHILDREN
;
411 if (Parent
->Wnd
->style
& WS_CLIPSIBLINGS
)
413 Flags
|= DCX_CLIPSIBLINGS
;
418 // Window nz, check to see if we still own this or it is just cheap wine tonight.
419 if (!(Flags
& DCX_CACHE
))
421 if ( Wnd
->head
.pti
!= GetW32ThreadInfo())
422 Flags
|= DCX_CACHE
; // Ah~ Not Powned! Forced to be cheap~
425 DcxFlags
= Flags
& DCX_CACHECOMPAREMASK
;
427 if (Flags
& DCX_CACHE
)
428 { // Scan the cheap wine list for our match.
429 DCE
* DceEmpty
= NULL
;
430 DCE
* DceUnused
= NULL
;
431 KeEnterCriticalRegion();
435 // The reason for this you may ask?
436 // Well, it seems ReactOS calls GetDC with out first creating a desktop DC window!
437 // Need to test for null here. Not sure if this is a bug or a feature.
438 // First time use hax, need to use DceAllocDCE during window display init.
441 // The way I understand this, you can have more than one DC per window.
442 // Only one Owned if one was requested and saved and one Cached.
444 if ((Dce
->DCXFlags
& (DCX_CACHE
| DCX_DCEBUSY
)) == DCX_CACHE
)
447 if (Dce
->DCXFlags
& DCX_DCEEMPTY
)
451 else if (Dce
->hwndCurrent
== (Window
? Window
->hSelf
: NULL
) &&
452 ((Dce
->DCXFlags
& DCX_CACHECOMPAREMASK
) == DcxFlags
))
455 UpdateVisRgn
= FALSE
;
457 UpdateClipOrigin
= TRUE
;
461 Dce
= (PDCE
)Dce
->List
.Flink
;
462 } while (Dce
!= FirstDce
);
463 KeLeaveCriticalRegion();
465 Dce
= (DceEmpty
== NULL
) ? DceUnused
: DceEmpty
;
469 Dce
= DceAllocDCE(NULL
, DCE_CACHE_DC
);
471 if (!Dce
) return NULL
;
473 Dce
->hwndCurrent
= (Window
? Window
->hSelf
: NULL
);
475 else // If we are here, we are POWNED or having CLASS.
477 KeEnterCriticalRegion();
480 { // Check for Window handle than HDC match for CLASS.
481 if ((Dce
->hwndCurrent
== Window
->hSelf
) || (Dce
->hDC
== hDC
)) break;
482 Dce
= (PDCE
)Dce
->List
.Flink
;
483 } while (Dce
!= FirstDce
);
484 KeLeaveCriticalRegion();
486 DPRINT("DCX:Flags -> %x:%x\n",Dce
->DCXFlags
& DCX_CACHE
, Flags
& DCX_CACHE
);
488 if (Dce
->hwndCurrent
== Window
->hSelf
)
490 DPRINT("Owned DCE!\n");
491 UpdateVisRgn
= FALSE
; /* updated automatically, via DCHook() */
495 DPRINT("Owned/Class DCE\n");
496 /* we should free dce->clip_rgn here, but Windows apparently doesn't */
497 Dce
->DCXFlags
&= ~(DCX_EXCLUDERGN
| DCX_INTERSECTRGN
);
498 Dce
->hClipRgn
= NULL
;
506 // First time use hax, need to use DceAllocDCE during window display init.
512 if (!GDIOBJ_ValidateHandle(Dce
->hDC
, GDI_OBJECT_TYPE_DC
))
514 DPRINT1("FIXME: Got DCE with invalid hDC! 0x%x\n", Dce
->hDC
);
515 Dce
->hDC
= DceCreateDisplayDC();
516 /* FIXME: Handle error */
519 if (!(Flags
& (DCX_EXCLUDERGN
| DCX_INTERSECTRGN
)) && ClipRegion
)
521 if (!(Flags
& DCX_KEEPCLIPRGN
))
522 GreDeleteObject(ClipRegion
);
527 if (NULL
!= Dce
->hClipRgn
)
529 DceDeleteClipRgn(Dce
);
533 Dce
->DCXFlags
= Flags
| DCX_DCEBUSY
;
535 if (0 != (Flags
& DCX_INTERSECTUPDATE
) && NULL
== ClipRegion
)
537 Flags
|= DCX_INTERSECTRGN
| DCX_KEEPCLIPRGN
;
538 Dce
->DCXFlags
|= DCX_INTERSECTRGN
| DCX_KEEPCLIPRGN
;
539 ClipRegion
= Window
->hrgnUpdate
;
542 if (ClipRegion
== (HRGN
) 1)
544 if (!(Flags
& DCX_WINDOW
))
546 Dce
->hClipRgn
= UnsafeIntCreateRectRgnIndirect(&Window
->Wnd
->rcClient
);
550 Dce
->hClipRgn
= UnsafeIntCreateRectRgnIndirect(&Window
->Wnd
->rcWindow
);
552 Dce
->DCXFlags
&= ~DCX_KEEPCLIPRGN
;
554 else if (ClipRegion
!= NULL
)
556 Dce
->hClipRgn
= ClipRegion
;
559 DceSetDrawable(Window
, Dce
->hDC
, Flags
, UpdateClipOrigin
);
563 DceUpdateVisRgn(Dce
, Window
, Flags
);
566 if (Dce
->DCXFlags
& DCX_CACHE
)
568 DPRINT("ENTER!!!!!! DCX_CACHE!!!!!! hDC-> %x\n", Dce
->hDC
);
569 // Need to set ownership so Sync dcattr will work.
570 IntGdiSetDCOwnerEx( Dce
->hDC
, GDI_OBJ_HMGR_POWNED
, FALSE
);
571 Dce
->pProcess
= PsGetCurrentProcess(); // Set the temp owning process
576 /***********************************************************************
580 DceFreeDCE(PDCE pdce
, BOOLEAN Force
)
585 if (NULL
== pdce
) return NULL
;
587 ret
= (PDCE
) pdce
->List
.Flink
;
590 SetDCHook(pdce
->hDC
, NULL
, 0L);
593 if (Force
&& !GDIOBJ_OwnedByCurrentProcess(pdce
->hDC
))
595 DPRINT("Change ownership for DCE! -> %x\n" , pdce
);
596 // Note: Windows sets W32PF_OWNDCCLEANUP and moves on.
597 if (!IsObjectDead((HGDIOBJ
) pdce
->hDC
))
599 DC_SetOwnership( pdce
->hDC
, PsGetCurrentProcess());
603 DPRINT1("Attempted to change ownership of an DCEhDC 0x%x currently being destroyed!!!\n",pdce
->hDC
);
608 if (!Hit
) IntGdiDeleteDC(pdce
->hDC
, TRUE
);
610 if (pdce
->hClipRgn
&& ! (pdce
->DCXFlags
& DCX_KEEPCLIPRGN
))
612 GreDeleteObject(pdce
->hClipRgn
);
615 RemoveEntryList(&pdce
->List
);
617 if (IsListEmpty(&pdce
->List
))
619 DPRINT1("List is Empty! DCE! -> %x\n" , pdce
);
624 ExFreePoolWithTag(pdce
, TAG_PDCE
);
630 /***********************************************************************
633 * Remove owned DCE and reset unreleased cache DCEs.
636 DceFreeWindowDCE(PWINDOW_OBJECT Window
)
641 KeEnterCriticalRegion();
645 if (pDCE
->hwndCurrent
== Window
->hSelf
)
647 if (!(pDCE
->DCXFlags
& DCX_CACHE
)) /* owned or Class DCE*/
649 if (Window
->Wnd
->pcls
->style
& CS_CLASSDC
||
650 Window
->Wnd
->style
& CS_CLASSDC
) /* Test Class first */
652 if (pDCE
->DCXFlags
& (DCX_INTERSECTRGN
| DCX_EXCLUDERGN
)) /* Class DCE*/
653 DceDeleteClipRgn(pDCE
);
654 // Update and reset Vis Rgn and clear the dirty bit.
655 // Should release VisRgn than reset it to default.
656 DceUpdateVisRgn(pDCE
, Window
, pDCE
->DCXFlags
);
657 pDCE
->DCXFlags
= DCX_DCEEMPTY
;
658 pDCE
->hwndCurrent
= 0;
660 else if (Window
->Wnd
->pcls
->style
& CS_OWNDC
||
661 Window
->Wnd
->style
& CS_OWNDC
) /* owned DCE*/
663 pDCE
= DceFreeDCE(pDCE
, FALSE
);
675 if (pDCE
->DCXFlags
& DCX_DCEBUSY
) /* shared cache DCE */
677 /* FIXME: AFAICS we are doing the right thing here so
678 * this should be a DPRINT. But this is best left as an ERR
679 * because the 'application error' is likely to come from
680 * another part of Wine (i.e. it's our fault after all).
681 * We should change this to DPRINT when ReactOS is more stable
684 DPRINT1("[%p] GetDC() without ReleaseDC()!\n", Window
->hSelf
);
685 DceReleaseDC(pDCE
, FALSE
);
687 pDCE
->DCXFlags
|= DCX_DCEEMPTY
;
688 pDCE
->hwndCurrent
= 0;
691 pDCE
= (PDCE
) pDCE
->List
.Flink
;
692 } while (pDCE
!= FirstDce
);
693 KeLeaveCriticalRegion();
697 DceFreeClassDCE(HDC hDC
)
699 PDCE pDCE
= FirstDce
;
700 KeEnterCriticalRegion();
704 if (pDCE
->hDC
== hDC
)
706 pDCE
= DceFreeDCE(pDCE
, FALSE
);
710 pDCE
= (PDCE
)pDCE
->List
.Flink
;
711 } while (pDCE
!= FirstDce
);
712 KeLeaveCriticalRegion();
718 PDCE pDCE
= FirstDce
;
719 KeEnterCriticalRegion();
723 pDCE
= DceFreeDCE(pDCE
, TRUE
);
725 } while (pDCE
!= FirstDce
);
726 KeLeaveCriticalRegion();
731 DceResetActiveDCEs(PWINDOW_OBJECT Window
)
735 PWINDOW_OBJECT CurrentWindow
;
744 if(!pDCE
) return; // Another null test!
748 if (0 == (pDCE
->DCXFlags
& DCX_DCEEMPTY
))
750 if (Window
->hSelf
== pDCE
->hwndCurrent
)
752 CurrentWindow
= Window
;
756 CurrentWindow
= UserGetWindowObject(pDCE
->hwndCurrent
);
757 if (NULL
== CurrentWindow
)
759 pDCE
= (PDCE
) pDCE
->List
.Flink
;
764 if (!GDIOBJ_ValidateHandle(pDCE
->hDC
, GDI_OBJECT_TYPE_DC
) ||
765 (dc
= DC_LockDc(pDCE
->hDC
)) == NULL
)
767 pDCE
= (PDCE
) pDCE
->List
.Flink
;
770 if (Window
== CurrentWindow
|| IntIsChildWindow(Window
, CurrentWindow
))
772 if (pDCE
->DCXFlags
& DCX_WINDOW
)
774 DeltaX
= CurrentWindow
->Wnd
->rcWindow
.left
- dc
->ptlDCOrig
.x
;
775 DeltaY
= CurrentWindow
->Wnd
->rcWindow
.top
- dc
->ptlDCOrig
.y
;
776 dc
->ptlDCOrig
.x
= CurrentWindow
->Wnd
->rcWindow
.left
;
777 dc
->ptlDCOrig
.y
= CurrentWindow
->Wnd
->rcWindow
.top
;
781 DeltaX
= CurrentWindow
->Wnd
->rcClient
.left
- dc
->ptlDCOrig
.x
;
782 DeltaY
= CurrentWindow
->Wnd
->rcClient
.top
- dc
->ptlDCOrig
.y
;
783 dc
->ptlDCOrig
.x
= CurrentWindow
->Wnd
->rcClient
.left
;
784 dc
->ptlDCOrig
.y
= CurrentWindow
->Wnd
->rcClient
.top
;
786 if (NULL
!= dc
->rosdc
.hClipRgn
)
788 int FASTCALL
CLIPPING_UpdateGCRegion(DC
* Dc
);
789 NtGdiOffsetRgn(dc
->rosdc
.hClipRgn
, DeltaX
, DeltaY
);
790 CLIPPING_UpdateGCRegion(dc
);
792 if (NULL
!= pDCE
->hClipRgn
)
794 NtGdiOffsetRgn(pDCE
->hClipRgn
, DeltaX
, DeltaY
);
799 DceUpdateVisRgn(pDCE
, CurrentWindow
, pDCE
->DCXFlags
);
801 if (Window
->hSelf
!= pDCE
->hwndCurrent
)
803 // IntEngWindowChanged(CurrentWindow, WOC_RGN_CLIENT);
804 // UserDerefObject(CurrentWindow);
807 pDCE
=(PDCE
) pDCE
->List
.Flink
;
808 } while (pDCE
!= FirstDce
);
812 IntWindowFromDC(HDC hDc
)
816 KeEnterCriticalRegion();
822 Ret
= Dce
->hwndCurrent
;
825 Dce
= (PDCE
)Dce
->List
.Flink
;
826 } while (Dce
!= FirstDce
);
827 KeLeaveCriticalRegion();
832 UserReleaseDC(PWINDOW_OBJECT Window
, HDC hDc
, BOOL EndPaint
)
838 DPRINT("%p %p\n", Window
, hDc
);
840 KeEnterCriticalRegion();
850 dce
= (PDCE
) dce
->List
.Flink
;
852 while (dce
!= FirstDce
);
853 KeLeaveCriticalRegion();
855 if ( Hit
&& (dce
->DCXFlags
& DCX_DCEBUSY
))
857 nRet
= DceReleaseDC(dce
, EndPaint
);
864 UserGetWindowDC(PWINDOW_OBJECT Wnd
)
866 return UserGetDCEx(Wnd
, 0, DCX_USESTYLE
| DCX_WINDOW
);
870 UserGethWnd( HDC hdc
, PWNDOBJ
*pwndo
)
872 PWNDGDI pWndgdi
= NULL
;
873 PWINDOW_OBJECT Wnd
= NULL
;
877 hWnd
= IntWindowFromDC(hdc
);
879 if (hWnd
&& !(Wnd
= UserGetWindowObject(hWnd
)))
881 KeEnterCriticalRegion();
882 Entry
= Wnd
->WndObjListHead
.Flink
;
883 while (Entry
!= &Wnd
->WndObjListHead
)
885 pWndgdi
= (PWNDGDI
)Entry
;
886 if (pWndgdi
->Hwnd
== hWnd
)
891 Entry
= Entry
->Flink
;
893 if (pwndo
&& Hit
) *pwndo
= (PWNDOBJ
)pWndgdi
;
894 KeLeaveCriticalRegion();
900 NtUserGetDCEx(HWND hWnd OPTIONAL
, HANDLE ClipRegion
, ULONG Flags
)
902 PWINDOW_OBJECT Wnd
=NULL
;
905 DPRINT("Enter NtUserGetDCEx\n");
906 UserEnterExclusive();
908 if (hWnd
&& !(Wnd
= UserGetWindowObject(hWnd
)))
912 RETURN( UserGetDCEx(Wnd
, ClipRegion
, Flags
));
915 DPRINT("Leave NtUserGetDCEx, ret=%i\n",_ret_
);
923 * The NtUserGetWindowDC function retrieves the device context (DC) for the
924 * entire window, including title bar, menus, and scroll bars. A window device
925 * context permits painting anywhere in a window, because the origin of the
926 * device context is the upper-left corner of the window instead of the client
933 NtUserGetWindowDC(HWND hWnd
)
935 return NtUserGetDCEx(hWnd
, 0, DCX_USESTYLE
| DCX_WINDOW
);
939 NtUserGetDC(HWND hWnd
)
941 DPRINT("NtUGetDC -> %x:%x\n", hWnd
, !hWnd
? DCX_CACHE
| DCX_WINDOW
: DCX_USESTYLE
);
943 return NtUserGetDCEx(hWnd
, NULL
, NULL
== hWnd
? DCX_CACHE
| DCX_WINDOW
: DCX_USESTYLE
);
947 * Select logical palette into device context.
948 * \param hDC handle to the device context
949 * \param hpal handle to the palette
950 * \param ForceBackground If this value is FALSE the logical palette will be copied to the device palette only when the applicatioon
951 * is in the foreground. If this value is TRUE then map the colors in the logical palette to the device
952 * palette colors in the best way.
953 * \return old palette
955 * \todo implement ForceBackground == TRUE
959 NtUserSelectPalette(HDC hDC
,
961 BOOL ForceBackground
)
964 UserEnterExclusive();
965 // Implement window checks
966 oldPal
= GdiSelectPalette( hDC
, hpal
, ForceBackground
);