2010-01-12 05:25:22 +00:00
|
|
|
/*
|
2005-07-31 12:11:56 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: GDI WNDOBJ Functions
|
2010-01-12 05:25:22 +00:00
|
|
|
* FILE: subsystems/win32/win32k/eng/engwindow.c
|
2005-07-31 12:11:56 +00:00
|
|
|
* PROGRAMER: Gregor Anich
|
|
|
|
*/
|
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2010-01-12 05:25:22 +00:00
|
|
|
INT gcountPWO = 0;
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
/*
|
|
|
|
* Calls the WNDOBJCHANGEPROC of the given WNDOBJ
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
IntEngWndCallChangeProc(
|
2014-01-29 19:09:15 +00:00
|
|
|
IN WNDOBJ *pwo,
|
|
|
|
IN FLONG flChanged)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
if (WndObjInt->ChangeProc == NULL)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
return;
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
/* check flags of the WNDOBJ */
|
|
|
|
flChanged &= WndObjInt->Flags;
|
|
|
|
if (flChanged == 0)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
return;
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
/* Call the WNDOBJCHANGEPROC */
|
|
|
|
if (flChanged == WOC_CHANGED)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
pwo = NULL;
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
DPRINT("Calling WNDOBJCHANGEPROC (0x%p), Changed = 0x%x\n",
|
|
|
|
WndObjInt->ChangeProc, flChanged);
|
|
|
|
WndObjInt->ChangeProc(pwo, flChanged);
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-10-11 03:41:41 +00:00
|
|
|
* Fills the CLIPOBJ and client rect of the WNDOBJ with the data from the given WND
|
2005-07-31 12:11:56 +00:00
|
|
|
*/
|
|
|
|
BOOLEAN
|
|
|
|
FASTCALL
|
|
|
|
IntEngWndUpdateClipObj(
|
2014-01-29 19:09:15 +00:00
|
|
|
WNDGDI *WndObjInt,
|
|
|
|
PWND Window)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
HRGN hVisRgn;
|
|
|
|
PROSRGNDATA visRgn;
|
|
|
|
CLIPOBJ *ClipObj = NULL;
|
|
|
|
CLIPOBJ *OldClipObj;
|
|
|
|
|
|
|
|
DPRINT("IntEngWndUpdateClipObj\n");
|
|
|
|
|
|
|
|
hVisRgn = VIS_ComputeVisibleRegion(Window, TRUE, TRUE, TRUE);
|
|
|
|
if (hVisRgn != NULL)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
NtGdiOffsetRgn(hVisRgn, Window->rcClient.left, Window->rcClient.top);
|
|
|
|
visRgn = RGNOBJAPI_Lock(hVisRgn, NULL);
|
|
|
|
if (visRgn != NULL)
|
|
|
|
{
|
|
|
|
if (visRgn->rdh.nCount > 0)
|
|
|
|
{
|
|
|
|
ClipObj = IntEngCreateClipRegion(visRgn->rdh.nCount, visRgn->Buffer,
|
|
|
|
&visRgn->rdh.rcBound);
|
|
|
|
DPRINT("Created visible region with %lu rects\n", visRgn->rdh.nCount);
|
|
|
|
DPRINT(" BoundingRect: %d, %d %d, %d\n",
|
|
|
|
visRgn->rdh.rcBound.left, visRgn->rdh.rcBound.top,
|
|
|
|
visRgn->rdh.rcBound.right, visRgn->rdh.rcBound.bottom);
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
for (i = 0; i < visRgn->rdh.nCount; i++)
|
|
|
|
{
|
|
|
|
DPRINT(" Rect #%lu: %ld,%ld %ld,%ld\n", i+1,
|
|
|
|
visRgn->Buffer[i].left, visRgn->Buffer[i].top,
|
|
|
|
visRgn->Buffer[i].right, visRgn->Buffer[i].bottom);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RGNOBJAPI_Unlock(visRgn);
|
|
|
|
}
|
|
|
|
else
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
DPRINT1("Warning: Couldn't lock visible region of window DC\n");
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
2014-01-29 19:09:15 +00:00
|
|
|
GreDeleteObject(hVisRgn);
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
DPRINT1("Warning: VIS_ComputeVisibleRegion failed!\n");
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
2014-01-29 19:09:15 +00:00
|
|
|
|
|
|
|
if (ClipObj == NULL)
|
|
|
|
{
|
|
|
|
/* Fall back to client rect */
|
|
|
|
ClipObj = IntEngCreateClipRegion(1, &Window->rcClient,
|
|
|
|
&Window->rcClient);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ClipObj == NULL)
|
|
|
|
{
|
|
|
|
DPRINT1("Warning: IntEngCreateClipRegion() failed!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
RtlCopyMemory(&WndObjInt->WndObj.coClient, ClipObj, sizeof (CLIPOBJ));
|
|
|
|
RtlCopyMemory(&WndObjInt->WndObj.rclClient, &Window->rcClient, sizeof (RECT));
|
|
|
|
OldClipObj = InterlockedExchangePointer((PVOID*)&WndObjInt->ClientClipObj, ClipObj);
|
|
|
|
if (OldClipObj != NULL)
|
|
|
|
IntEngDeleteClipRegion(OldClipObj);
|
|
|
|
|
|
|
|
return TRUE;
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-10-11 03:41:41 +00:00
|
|
|
* Updates all WNDOBJs of the given WND and calls the change-procs.
|
2005-07-31 12:11:56 +00:00
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
IntEngWindowChanged(
|
2014-01-29 19:09:15 +00:00
|
|
|
_In_ PWND Window,
|
|
|
|
_In_ FLONG flChanged)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
PPROPERTY pprop;
|
|
|
|
WNDGDI *Current;
|
|
|
|
HWND hWnd;
|
|
|
|
|
|
|
|
ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL);
|
|
|
|
|
|
|
|
hWnd = Window->head.h;
|
|
|
|
pprop = IntGetProp(Window, AtomWndObj);
|
|
|
|
if (!pprop)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Current = (WNDGDI *)pprop->Data;
|
|
|
|
if ( gcountPWO &&
|
|
|
|
Current &&
|
|
|
|
Current->Hwnd == hWnd &&
|
|
|
|
Current->WndObj.pvConsumer != NULL )
|
|
|
|
{
|
|
|
|
/* Update the WNDOBJ */
|
|
|
|
switch (flChanged)
|
|
|
|
{
|
2010-01-12 05:25:22 +00:00
|
|
|
case WOC_RGN_CLIENT:
|
2014-01-29 19:09:15 +00:00
|
|
|
/* Update the clipobj and client rect of the WNDOBJ */
|
|
|
|
IntEngWndUpdateClipObj(Current, Window);
|
|
|
|
break;
|
2010-01-12 05:25:22 +00:00
|
|
|
|
|
|
|
case WOC_DELETE:
|
2014-01-29 19:09:15 +00:00
|
|
|
/* FIXME: Should the WNDOBJs be deleted by win32k or by the driver? */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the change proc */
|
|
|
|
IntEngWndCallChangeProc(&Current->WndObj, flChanged);
|
|
|
|
|
|
|
|
/* HACK: Send WOC_CHANGED after WOC_RGN_CLIENT */
|
|
|
|
if (flChanged == WOC_RGN_CLIENT)
|
|
|
|
{
|
|
|
|
IntEngWndCallChangeProc(&Current->WndObj, WOC_CHANGED);
|
|
|
|
}
|
|
|
|
}
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
WNDOBJ*
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2005-07-31 12:11:56 +00:00
|
|
|
EngCreateWnd(
|
2014-01-29 19:09:15 +00:00
|
|
|
SURFOBJ *pso,
|
|
|
|
HWND hWnd,
|
|
|
|
WNDOBJCHANGEPROC pfn,
|
|
|
|
FLONG fl,
|
|
|
|
int iPixelFormat)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
WNDGDI *WndObjInt = NULL;
|
|
|
|
WNDOBJ *WndObjUser = NULL;
|
|
|
|
PWND Window;
|
|
|
|
BOOL calledFromUser;
|
|
|
|
DECLARE_RETURN(WNDOBJ*);
|
|
|
|
|
|
|
|
DPRINT1("EngCreateWnd: pso = 0x%p, hwnd = 0x%p, pfn = 0x%p, fl = 0x%lx, pixfmt = %d\n",
|
|
|
|
pso, hWnd, pfn, fl, iPixelFormat);
|
|
|
|
|
|
|
|
calledFromUser = UserIsEntered();
|
|
|
|
if (!calledFromUser) {
|
|
|
|
UserEnterShared();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get window object */
|
|
|
|
Window = UserGetWindowObject(hWnd);
|
|
|
|
if (Window == NULL)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
RETURN( NULL);
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
/* Create WNDOBJ */
|
|
|
|
WndObjInt = EngAllocMem(0, sizeof (WNDGDI), GDITAG_WNDOBJ);
|
|
|
|
if (WndObjInt == NULL)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
DPRINT1("Failed to allocate memory for a WND structure!\n");
|
|
|
|
RETURN( NULL);
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
/* Fill the clipobj */
|
|
|
|
WndObjInt->ClientClipObj = NULL;
|
|
|
|
if (!IntEngWndUpdateClipObj(WndObjInt, Window))
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
EngFreeMem(WndObjInt);
|
|
|
|
RETURN( NULL);
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
/* Fill user object */
|
|
|
|
WndObjUser = GDIToObj(WndObjInt, WND);
|
|
|
|
WndObjUser->psoOwner = pso;
|
|
|
|
WndObjUser->pvConsumer = NULL;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
/* Fill internal object */
|
|
|
|
WndObjInt->Hwnd = hWnd;
|
|
|
|
WndObjInt->ChangeProc = pfn;
|
|
|
|
WndObjInt->Flags = fl;
|
|
|
|
WndObjInt->PixelFormat = iPixelFormat;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
/* associate object with window */
|
|
|
|
IntSetProp(Window, AtomWndObj, WndObjInt);
|
|
|
|
++gcountPWO;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
DPRINT("EngCreateWnd: SUCCESS!\n");
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
RETURN( WndObjUser);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
CLEANUP:
|
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
if (!calledFromUser) {
|
|
|
|
UserLeave();
|
|
|
|
}
|
2005-09-05 21:19:23 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
END_CLEANUP;
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2005-07-31 12:11:56 +00:00
|
|
|
EngDeleteWnd(
|
2014-01-29 19:09:15 +00:00
|
|
|
IN WNDOBJ *pwo)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
|
|
|
|
PWND Window;
|
|
|
|
BOOL calledFromUser;
|
|
|
|
|
|
|
|
DPRINT("EngDeleteWnd: pwo = 0x%p\n", pwo);
|
|
|
|
|
|
|
|
calledFromUser = UserIsEntered();
|
|
|
|
if (!calledFromUser) {
|
|
|
|
UserEnterExclusive();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get window object */
|
|
|
|
Window = UserGetWindowObject(WndObjInt->Hwnd);
|
|
|
|
if (Window == NULL)
|
|
|
|
{
|
|
|
|
DPRINT1("Warning: Couldnt get window object for WndObjInt->Hwnd!!!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Remove object from window */
|
|
|
|
IntRemoveProp(Window, AtomWndObj);
|
|
|
|
--gcountPWO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!calledFromUser) {
|
|
|
|
UserLeave();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free resources */
|
|
|
|
IntEngDeleteClipRegion(WndObjInt->ClientClipObj);
|
|
|
|
EngFreeMem(WndObjInt);
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2005-07-31 12:11:56 +00:00
|
|
|
WNDOBJ_bEnum(
|
2014-01-29 19:09:15 +00:00
|
|
|
IN WNDOBJ *pwo,
|
|
|
|
IN ULONG cj,
|
|
|
|
OUT ULONG *pul)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
|
|
|
|
BOOL Ret;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
DPRINT("WNDOBJ_bEnum: pwo = 0x%p, cj = %lu, pul = 0x%p\n", pwo, cj, pul);
|
|
|
|
Ret = CLIPOBJ_bEnum(WndObjInt->ClientClipObj, cj, pul);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
DPRINT("WNDOBJ_bEnum: Returning %s\n", Ret ? "True" : "False");
|
|
|
|
return Ret;
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
ULONG
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2005-07-31 12:11:56 +00:00
|
|
|
WNDOBJ_cEnumStart(
|
2014-01-29 19:09:15 +00:00
|
|
|
IN WNDOBJ *pwo,
|
|
|
|
IN ULONG iType,
|
|
|
|
IN ULONG iDirection,
|
|
|
|
IN ULONG cLimit)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
|
|
|
|
ULONG Ret;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
DPRINT("WNDOBJ_cEnumStart: pwo = 0x%p, iType = %lu, iDirection = %lu, cLimit = %lu\n",
|
|
|
|
pwo, iType, iDirection, cLimit);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
/* FIXME: Should we enumerate all rectangles or not? */
|
|
|
|
Ret = CLIPOBJ_cEnumStart(WndObjInt->ClientClipObj, FALSE, iType, iDirection, cLimit);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
2014-01-29 19:09:15 +00:00
|
|
|
DPRINT("WNDOBJ_cEnumStart: Returning 0x%lx\n", Ret);
|
|
|
|
return Ret;
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2005-07-31 12:11:56 +00:00
|
|
|
WNDOBJ_vSetConsumer(
|
2014-01-29 19:09:15 +00:00
|
|
|
IN WNDOBJ *pwo,
|
|
|
|
IN PVOID pvConsumer)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
BOOL Hack;
|
|
|
|
|
|
|
|
DPRINT("WNDOBJ_vSetConsumer: pwo = 0x%p, pvConsumer = 0x%p\n", pwo, pvConsumer);
|
|
|
|
|
|
|
|
Hack = (pwo->pvConsumer == NULL);
|
|
|
|
pwo->pvConsumer = pvConsumer;
|
|
|
|
|
|
|
|
/* HACKHACKHACK
|
|
|
|
*
|
|
|
|
* MSDN says that the WNDOBJCHANGEPROC will be called with the most recent state
|
|
|
|
* when a WNDOBJ is created - we do it here because most drivers will need pvConsumer
|
|
|
|
* in the callback to identify the WNDOBJ I think.
|
|
|
|
*
|
|
|
|
* - blight
|
|
|
|
*/
|
|
|
|
if (Hack)
|
2005-07-31 12:11:56 +00:00
|
|
|
{
|
2014-01-29 19:09:15 +00:00
|
|
|
IntEngWndCallChangeProc(pwo, WOC_RGN_CLIENT);
|
|
|
|
IntEngWndCallChangeProc(pwo, WOC_CHANGED);
|
|
|
|
IntEngWndCallChangeProc(pwo, WOC_DRAWN);
|
2005-07-31 12:11:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|
|
|
|
|