- More movement to WND with updates to related files. Removed unused code rewritten others. Review patch.

svn path=/trunk/; revision=45051
This commit is contained in:
James Tabor 2010-01-12 05:25:22 +00:00
parent 1f21afc098
commit 66c33fe237
13 changed files with 134 additions and 195 deletions

View file

@ -16,20 +16,17 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
/* $Id$ /*
*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: GDI WNDOBJ Functions * PURPOSE: GDI WNDOBJ Functions
* FILE: subsys/win32k/eng/window.c * FILE: subsystems/win32/win32k/eng/engwindow.c
* PROGRAMER: Gregor Anich * PROGRAMER: Gregor Anich
* REVISION HISTORY: * REVISION HISTORY:
* 16/11/2004: Created * 16/11/2004: Created
*/ */
/* TODO: Check how the WNDOBJ implementation should behave with a driver on windows. /* TODO: Check how the WNDOBJ implementation should behave with a driver on windows.
Simple! Use Prop's!
*/ */
#include <w32k.h> #include <w32k.h>
@ -37,6 +34,8 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
INT gcountPWO = 0;
/* /*
* Calls the WNDOBJCHANGEPROC of the given WNDOBJ * Calls the WNDOBJCHANGEPROC of the given WNDOBJ
*/ */
@ -153,17 +152,18 @@ IntEngWindowChanged(
PWINDOW_OBJECT Window, PWINDOW_OBJECT Window,
FLONG flChanged) FLONG flChanged)
{ {
PLIST_ENTRY CurrentEntry;
WNDGDI *Current; WNDGDI *Current;
HWND hWnd;
ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL); ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL);
CurrentEntry = Window->WndObjListHead.Flink; hWnd = Window->hSelf; // pWnd->head.h;
while (CurrentEntry != &Window->WndObjListHead) Current = (WNDGDI *)IntGetProp(Window, AtomWndObj);
{
Current = CONTAINING_RECORD(CurrentEntry, WNDGDI, ListEntry);
if (Current->WndObj.pvConsumer != NULL) if ( gcountPWO &&
Current &&
Current->Hwnd == hWnd &&
Current->WndObj.pvConsumer != NULL )
{ {
/* Update the WNDOBJ */ /* Update the WNDOBJ */
switch (flChanged) switch (flChanged)
@ -186,13 +186,9 @@ IntEngWindowChanged(
{ {
IntEngWndCallChangeProc(&Current->WndObj, WOC_CHANGED); IntEngWndCallChangeProc(&Current->WndObj, WOC_CHANGED);
} }
CurrentEntry = CurrentEntry->Flink;
} }
} }
}
/* /*
* @implemented * @implemented
*/ */
@ -254,7 +250,8 @@ EngCreateWnd(
WndObjInt->PixelFormat = iPixelFormat; WndObjInt->PixelFormat = iPixelFormat;
/* associate object with window */ /* associate object with window */
InsertTailList(&Window->WndObjListHead, &WndObjInt->ListEntry); IntSetProp(Window, AtomWndObj, WndObjInt);
++gcountPWO;
DPRINT("EngCreateWnd: SUCCESS!\n"); DPRINT("EngCreateWnd: SUCCESS!\n");
@ -294,12 +291,12 @@ EngDeleteWnd(
if (Window == NULL) if (Window == NULL)
{ {
DPRINT1("Warning: Couldnt get window object for WndObjInt->Hwnd!!!\n"); DPRINT1("Warning: Couldnt get window object for WndObjInt->Hwnd!!!\n");
RemoveEntryList(&WndObjInt->ListEntry);
} }
else else
{ {
/* Remove object from window */ /* Remove object from window */
RemoveEntryList(&WndObjInt->ListEntry); IntRemoveProp(Window, AtomWndObj);
--gcountPWO;
} }
if (!calledFromUser){ if (!calledFromUser){

View file

@ -28,11 +28,16 @@ typedef struct tagDCE
LIST_ENTRY List; LIST_ENTRY List;
HDC hDC; HDC hDC;
HWND hwndCurrent; HWND hwndCurrent;
HWND hwndDC; PWND pwndOrg;
HRGN hClipRgn; PWND pwndClip;
PWND pwndRedirect;
HRGN hrgnClip;
HRGN hrgnClipPublic;
HRGN hrgnSavedVis;
DWORD DCXFlags; DWORD DCXFlags;
PEPROCESS pProcess; PTHREADINFO ptiOwner;
HANDLE Self; PPROCESSINFO ppiOwner;
struct _MONITOR* pMonitor;
} DCE; /* PDCE already declared at top of file */ } DCE; /* PDCE already declared at top of file */
/* internal DCX flags, see psdk/winuser.h for the rest */ /* internal DCX flags, see psdk/winuser.h for the rest */
@ -52,7 +57,6 @@ INT FASTCALL DCE_ExcludeRgn(HDC, HWND, HRGN);
BOOL FASTCALL DCE_InvalidateDCE(HWND, const PRECTL); BOOL FASTCALL DCE_InvalidateDCE(HWND, const PRECTL);
HWND FASTCALL IntWindowFromDC(HDC hDc); HWND FASTCALL IntWindowFromDC(HDC hDc);
PDCE FASTCALL DceFreeDCE(PDCE dce, BOOLEAN Force); PDCE FASTCALL DceFreeDCE(PDCE dce, BOOLEAN Force);
void FASTCALL DceFreeWindowDCE(PWINDOW_OBJECT Window);
void FASTCALL DceEmptyCache(void); void FASTCALL DceEmptyCache(void);
VOID FASTCALL DceResetActiveDCEs(PWINDOW_OBJECT Window); VOID FASTCALL DceResetActiveDCEs(PWINDOW_OBJECT Window);
void FASTCALL DceFreeClassDCE(HDC); void FASTCALL DceFreeClassDCE(HDC);

View file

@ -89,7 +89,6 @@ typedef struct _PATHGDI {
typedef struct _WNDGDI { typedef struct _WNDGDI {
WNDOBJ WndObj; WNDOBJ WndObj;
LIST_ENTRY ListEntry;
HWND Hwnd; HWND Hwnd;
CLIPOBJ *ClientClipObj; CLIPOBJ *ClientClipObj;
WNDOBJCHANGEPROC ChangeProc; WNDOBJCHANGEPROC ChangeProc;

View file

@ -14,6 +14,7 @@ typedef struct _WINDOW_OBJECT *PWINDOW_OBJECT;
#include <include/scroll.h> #include <include/scroll.h>
extern ATOM AtomMessage; extern ATOM AtomMessage;
extern ATOM AtomWndObj; /* WNDOBJ list */
BOOL FASTCALL UserUpdateUiState(PWND Wnd, WPARAM wParam); BOOL FASTCALL UserUpdateUiState(PWND Wnd, WPARAM wParam);
@ -29,8 +30,6 @@ typedef struct _WINDOW_OBJECT
PTHREADINFO pti; // Use Wnd->head.pti PTHREADINFO pti; // Use Wnd->head.pti
/* system menu handle. */ /* system menu handle. */
HMENU SystemMenu; HMENU SystemMenu;
/* Entry in the thread's list of windows. */
LIST_ENTRY ListEntry;
/* Handle for the window. */ /* Handle for the window. */
HWND hSelf; // Use Wnd->head.h HWND hSelf; // Use Wnd->head.h
/* Window flags. */ /* Window flags. */
@ -42,19 +41,16 @@ typedef struct _WINDOW_OBJECT
struct _WINDOW_OBJECT* spwndChild; struct _WINDOW_OBJECT* spwndChild;
struct _WINDOW_OBJECT* spwndNext; struct _WINDOW_OBJECT* spwndNext;
struct _WINDOW_OBJECT* spwndPrev; struct _WINDOW_OBJECT* spwndPrev;
/* Entry in the list of thread windows. */
LIST_ENTRY ThreadListEntry;
/* Handle to the parent window. */ /* Handle to the parent window. */
struct _WINDOW_OBJECT* spwndParent; struct _WINDOW_OBJECT* spwndParent;
/* Handle to the owner window. */ /* Handle to the owner window. */
HWND hOwner; // Use spwndOwner HWND hOwner; // Use spwndOwner
/* DC Entries (DCE) */
PDCE Dce;
/* Scrollbar info */ /* Scrollbar info */
PSBINFOEX pSBInfo; // convert to PSBINFO PSBINFOEX pSBInfo; // convert to PSBINFO
PETHREAD OwnerThread; // Use Wnd->head.pti->pEThread /* Entry in the list of thread windows. */
/* WNDOBJ list */ LIST_ENTRY ThreadListEntry;
LIST_ENTRY WndObjListHead; // Use Props
} WINDOW_OBJECT; /* PWINDOW_OBJECT already declared at top of file */ } WINDOW_OBJECT; /* PWINDOW_OBJECT already declared at top of file */
/* Window flags. */ /* Window flags. */
@ -86,16 +82,16 @@ typedef struct _WINDOW_OBJECT
#define IntWndBelongsToThread(WndObj, W32Thread) \ #define IntWndBelongsToThread(WndObj, W32Thread) \
(((WndObj->OwnerThread && WndObj->OwnerThread->Tcb.Win32Thread)) && \ (((WndObj->pti->pEThread && WndObj->pti->pEThread->Tcb.Win32Thread)) && \
(WndObj->OwnerThread->Tcb.Win32Thread == W32Thread)) (WndObj->pti->pEThread->Tcb.Win32Thread == W32Thread))
// ((WndObj->head.pti) && (WndObj->head.pti == W32Thread)) // ((WndObj->head.pti) && (WndObj->head.pti == W32Thread))
#define IntGetWndThreadId(WndObj) \ #define IntGetWndThreadId(WndObj) \
WndObj->OwnerThread->Cid.UniqueThread WndObj->pti->pEThread->Cid.UniqueThread
// WndObj->head.pti->pEThread->Cid.UniqueThread // WndObj->head.pti->pEThread->Cid.UniqueThread
#define IntGetWndProcessId(WndObj) \ #define IntGetWndProcessId(WndObj) \
WndObj->OwnerThread->ThreadsProcess->UniqueProcessId WndObj->pti->pEThread->ThreadsProcess->UniqueProcessId
// WndObj->head.pti->pEThread->ThreadsProcess->UniqueProcessId // WndObj->head.pti->pEThread->ThreadsProcess->UniqueProcessId
BOOL FASTCALL BOOL FASTCALL

View file

@ -245,7 +245,7 @@ BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window OPTIONAL)
if (Window) ASSERT_REFS_CO(Window); if (Window) ASSERT_REFS_CO(Window);
if(Window && Window->OwnerThread != PsGetCurrentThread()) if(Window && Window->pti->pEThread != PsGetCurrentThread())
{ {
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE; return FALSE;
@ -280,7 +280,7 @@ BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window OPTIONAL)
if (Window) ASSERT_REFS_CO(Window); if (Window) ASSERT_REFS_CO(Window);
if(Window && Window->OwnerThread != PsGetCurrentThread()) if(Window && Window->pti->pEThread != PsGetCurrentThread())
{ {
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE; return FALSE;
@ -332,7 +332,7 @@ NtUserCreateCaret(
RETURN(FALSE); RETURN(FALSE);
} }
if(Window->OwnerThread != PsGetCurrentThread()) if(Window->pti->pEThread != PsGetCurrentThread())
{ {
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
RETURN(FALSE); RETURN(FALSE);

View file

@ -217,7 +217,7 @@ co_IntSetForegroundAndFocusWindow(PWINDOW_OBJECT Window, PWINDOW_OBJECT FocusWin
} }
if (0 == (Wnd->style & WS_VISIBLE) && if (0 == (Wnd->style & WS_VISIBLE) &&
Window->OwnerThread->ThreadsProcess != CsrProcess) Window->pti->pEThread->ThreadsProcess != CsrProcess)
{ {
DPRINT("Failed - Invisible\n"); DPRINT("Failed - Invisible\n");
return FALSE; return FALSE;
@ -339,7 +339,7 @@ co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL)
{ {
Wnd = Window->Wnd; Wnd = Window->Wnd;
if ((!(Wnd->style & WS_VISIBLE) && if ((!(Wnd->style & WS_VISIBLE) &&
Window->OwnerThread->ThreadsProcess != CsrProcess) || Window->pti->pEThread->ThreadsProcess != CsrProcess) ||
(Wnd->style & (WS_POPUP | WS_CHILD)) == WS_CHILD) (Wnd->style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
{ {
return ThreadQueue ? 0 : ThreadQueue->ActiveWindow; return ThreadQueue ? 0 : ThreadQueue->ActiveWindow;

View file

@ -16,8 +16,7 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
/* $Id$ /*
*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: HotKey support * PURPOSE: HotKey support
@ -182,7 +181,7 @@ NtUserRegisterHotKey(HWND hWnd,
{ {
RETURN( FALSE); RETURN( FALSE);
} }
HotKeyThread = Window->OwnerThread; HotKeyThread = Window->pti->pEThread;
} }
/* Check for existing hotkey */ /* Check for existing hotkey */

View file

@ -191,6 +191,14 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice,
Monitor->rcWork = Monitor->rcMonitor; Monitor->rcWork = Monitor->rcMonitor;
Monitor->cWndStack = 0; Monitor->cWndStack = 0;
Monitor->hrgnMonitor= NtGdiCreateRectRgn( Monitor->rcMonitor.left,
Monitor->rcMonitor.top,
Monitor->rcMonitor.right,
Monitor->rcMonitor.bottom );
// Replace with IntGdiSetRegeionOwner(Monitor->hrgnMonitor, GDI_OBJ_HMGR_PUBLIC);
GDIOBJ_SetOwnership(Monitor->hrgnMonitor, NULL);
if (gMonitorList == NULL) if (gMonitorList == NULL)
{ {
DPRINT("Primary monitor is beeing attached\n"); DPRINT("Primary monitor is beeing attached\n");

View file

@ -20,6 +20,7 @@ BOOL InitSysParams();
ERESOURCE UserLock; ERESOURCE UserLock;
ATOM AtomMessage; // Window Message atom. ATOM AtomMessage; // Window Message atom.
ATOM AtomWndObj; // Window Object atom.
BOOL gbInitialized; BOOL gbInitialized;
HINSTANCE hModClient = NULL; HINSTANCE hModClient = NULL;
BOOL ClientPfnInit = FALSE; BOOL ClientPfnInit = FALSE;
@ -45,6 +46,8 @@ InitUserAtoms(VOID)
/* System Context Help Id Atom */ /* System Context Help Id Atom */
gpsi->atomContextHelpIdProp = IntAddGlobalAtom(L"SysCH", TRUE); gpsi->atomContextHelpIdProp = IntAddGlobalAtom(L"SysCH", TRUE);
AtomWndObj = IntAddGlobalAtom(L"SysWNDO", TRUE);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -199,7 +199,7 @@ InternalSetTimer( PWINDOW_OBJECT Window,
if (!pTmr) return 0; if (!pTmr) return 0;
if (Window && (Type & TMRF_TIFROMWND)) if (Window && (Type & TMRF_TIFROMWND))
pTmr->pti = Window->OwnerThread->Tcb.Win32Thread; pTmr->pti = Window->pti->pEThread->Tcb.Win32Thread;
else else
{ {
if (Type & TMRF_RIT) if (Type & TMRF_RIT)
@ -253,7 +253,7 @@ SetSystemTimer( PWINDOW_OBJECT Window,
UINT uElapse, UINT uElapse,
TIMERPROC lpTimerFunc) TIMERPROC lpTimerFunc)
{ {
if (Window && Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess()) if (Window && Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess())
{ {
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
return 0; return 0;
@ -419,7 +419,7 @@ IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL S
return 0; return 0;
} }
if (Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess()) if (Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess())
{ {
DPRINT1("Trying to set timer for window in another process (shatter attack?)\n"); DPRINT1("Trying to set timer for window in another process (shatter attack?)\n");
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);

View file

@ -89,8 +89,13 @@ DceAllocDCE(PWINDOW_OBJECT Window OPTIONAL, DCE_TYPE Type)
} }
pDce->hwndCurrent = (Window ? Window->hSelf : NULL); pDce->hwndCurrent = (Window ? Window->hSelf : NULL);
pDce->hClipRgn = NULL; pDce->pwndOrg = Wnd;
pDce->pProcess = NULL; pDce->pwndClip = Wnd;
pDce->hrgnClip = NULL;
pDce->hrgnClipPublic = NULL;
pDce->hrgnSavedVis = NULL;
pDce->ptiOwner = NULL;
pDce->ppiOwner = NULL;
KeEnterCriticalRegion(); KeEnterCriticalRegion();
if (FirstDce == NULL) if (FirstDce == NULL)
@ -105,8 +110,9 @@ DceAllocDCE(PWINDOW_OBJECT Window OPTIONAL, DCE_TYPE Type)
DCU_SetDcUndeletable(pDce->hDC); DCU_SetDcUndeletable(pDce->hDC);
if (Type == DCE_WINDOW_DC || Type == DCE_CLASS_DC) //Window DCE have ownership. if (Type == DCE_WINDOW_DC || Type == DCE_CLASS_DC) //Window DCE have ownership.
{ // Process should already own it. {
pDce->pProcess = PsGetCurrentProcess(); pDce->ptiOwner = GetW32ThreadInfo();
pDce->ppiOwner = pDce->ptiOwner->ppi;
} }
else else
{ {
@ -174,12 +180,12 @@ DceDeleteClipRgn(DCE* Dce)
{ {
Dce->DCXFlags &= ~DCX_KEEPCLIPRGN; Dce->DCXFlags &= ~DCX_KEEPCLIPRGN;
} }
else if (Dce->hClipRgn != NULL) else if (Dce->hrgnClip != NULL)
{ {
GreDeleteObject(Dce->hClipRgn); GreDeleteObject(Dce->hrgnClip);
} }
Dce->hClipRgn = NULL; Dce->hrgnClip = NULL;
/* make it dirty so that the vis rgn gets recomputed next time */ /* make it dirty so that the vis rgn gets recomputed next time */
Dce->DCXFlags |= DCX_DCEDIRTY; Dce->DCXFlags |= DCX_DCEDIRTY;
@ -225,7 +231,8 @@ DceReleaseDC(DCE* dce, BOOL EndPaint)
DPRINT("Exit!!!!! DCX_CACHE!!!!!! hDC-> %x \n", dce->hDC); DPRINT("Exit!!!!! DCX_CACHE!!!!!! hDC-> %x \n", dce->hDC);
if (!IntGdiSetDCOwnerEx( dce->hDC, GDI_OBJ_HMGR_NONE, FALSE)) if (!IntGdiSetDCOwnerEx( dce->hDC, GDI_OBJ_HMGR_NONE, FALSE))
return 0; return 0;
dce->pProcess = NULL; // Reset ownership. dce->ptiOwner = NULL; // Reset ownership.
dce->ppiOwner = NULL;
} }
return 1; // Released! return 1; // Released!
} }
@ -282,9 +289,9 @@ DceUpdateVisRgn(DCE *Dce, PWINDOW_OBJECT Window, ULONG Flags)
noparent: noparent:
if (Flags & DCX_INTERSECTRGN) if (Flags & DCX_INTERSECTRGN)
{ {
if(Dce->hClipRgn != NULL) if(Dce->hrgnClip != NULL)
{ {
NtGdiCombineRgn(hRgnVisible, hRgnVisible, Dce->hClipRgn, RGN_AND); NtGdiCombineRgn(hRgnVisible, hRgnVisible, Dce->hrgnClip, RGN_AND);
} }
else else
{ {
@ -296,9 +303,9 @@ noparent:
} }
} }
if (Flags & DCX_EXCLUDERGN && Dce->hClipRgn != NULL) if (Flags & DCX_EXCLUDERGN && Dce->hrgnClip != NULL)
{ {
NtGdiCombineRgn(hRgnVisible, hRgnVisible, Dce->hClipRgn, RGN_DIFF); NtGdiCombineRgn(hRgnVisible, hRgnVisible, Dce->hrgnClip, RGN_DIFF);
} }
Dce->DCXFlags &= ~DCX_DCEDIRTY; Dce->DCXFlags &= ~DCX_DCEDIRTY;
@ -495,7 +502,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
DPRINT("Owned/Class DCE\n"); DPRINT("Owned/Class DCE\n");
/* we should free dce->clip_rgn here, but Windows apparently doesn't */ /* we should free dce->clip_rgn here, but Windows apparently doesn't */
Dce->DCXFlags &= ~(DCX_EXCLUDERGN | DCX_INTERSECTRGN); Dce->DCXFlags &= ~(DCX_EXCLUDERGN | DCX_INTERSECTRGN);
Dce->hClipRgn = NULL; Dce->hrgnClip = NULL;
} }
#if 1 /* FIXME */ #if 1 /* FIXME */
@ -524,7 +531,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
} }
#if 0 #if 0
if (NULL != Dce->hClipRgn) if (NULL != Dce->hrgnClip)
{ {
DceDeleteClipRgn(Dce); DceDeleteClipRgn(Dce);
} }
@ -543,17 +550,17 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
{ {
if (!(Flags & DCX_WINDOW)) if (!(Flags & DCX_WINDOW))
{ {
Dce->hClipRgn = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->rcClient); Dce->hrgnClip = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->rcClient);
} }
else else
{ {
Dce->hClipRgn = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->rcWindow); Dce->hrgnClip = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->rcWindow);
} }
Dce->DCXFlags &= ~DCX_KEEPCLIPRGN; Dce->DCXFlags &= ~DCX_KEEPCLIPRGN;
} }
else if (ClipRegion != NULL) else if (ClipRegion != NULL)
{ {
Dce->hClipRgn = ClipRegion; Dce->hrgnClip = ClipRegion;
} }
DceSetDrawable(Window, Dce->hDC, Flags, UpdateClipOrigin); DceSetDrawable(Window, Dce->hDC, Flags, UpdateClipOrigin);
@ -568,7 +575,8 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
DPRINT("ENTER!!!!!! DCX_CACHE!!!!!! hDC-> %x\n", Dce->hDC); DPRINT("ENTER!!!!!! DCX_CACHE!!!!!! hDC-> %x\n", Dce->hDC);
// Need to set ownership so Sync dcattr will work. // Need to set ownership so Sync dcattr will work.
IntGdiSetDCOwnerEx( Dce->hDC, GDI_OBJ_HMGR_POWNED, FALSE); IntGdiSetDCOwnerEx( Dce->hDC, GDI_OBJ_HMGR_POWNED, FALSE);
Dce->pProcess = PsGetCurrentProcess(); // Set the temp owning process Dce->ptiOwner = GetW32ThreadInfo(); // Set the temp owning
Dce->ppiOwner = Dce->ptiOwner->ppi;
} }
return(Dce->hDC); return(Dce->hDC);
} }
@ -607,9 +615,9 @@ DceFreeDCE(PDCE pdce, BOOLEAN Force)
if (!Hit) IntGdiDeleteDC(pdce->hDC, TRUE); if (!Hit) IntGdiDeleteDC(pdce->hDC, TRUE);
if (pdce->hClipRgn && ! (pdce->DCXFlags & DCX_KEEPCLIPRGN)) if (pdce->hrgnClip && ! (pdce->DCXFlags & DCX_KEEPCLIPRGN))
{ {
GreDeleteObject(pdce->hClipRgn); GreDeleteObject(pdce->hrgnClip);
} }
RemoveEntryList(&pdce->List); RemoveEntryList(&pdce->List);
@ -626,73 +634,6 @@ DceFreeDCE(PDCE pdce, BOOLEAN Force)
return ret; return ret;
} }
/***********************************************************************
* DceFreeWindowDCE
*
* Remove owned DCE and reset unreleased cache DCEs.
*/
void FASTCALL
DceFreeWindowDCE(PWINDOW_OBJECT Window)
{
PDCE pDCE;
pDCE = FirstDce;
KeEnterCriticalRegion();
do
{
if (!pDCE) break;
if (pDCE->hwndCurrent == Window->hSelf)
{
if (!(pDCE->DCXFlags & DCX_CACHE)) /* owned or Class DCE*/
{
if (Window->Wnd->pcls->style & CS_CLASSDC ||
Window->Wnd->style & CS_CLASSDC) /* Test Class first */
{
if (pDCE->DCXFlags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) /* Class DCE*/
DceDeleteClipRgn(pDCE);
// Update and reset Vis Rgn and clear the dirty bit.
// Should release VisRgn than reset it to default.
DceUpdateVisRgn(pDCE, Window, pDCE->DCXFlags);
pDCE->DCXFlags = DCX_DCEEMPTY;
pDCE->hwndCurrent = 0;
}
else if (Window->Wnd->pcls->style & CS_OWNDC ||
Window->Wnd->style & CS_OWNDC) /* owned DCE*/
{
pDCE = DceFreeDCE(pDCE, FALSE);
if (!pDCE) break;
Window->Dce = NULL;
continue;
}
else
{
ASSERT(FALSE);
}
}
else
{
if (pDCE->DCXFlags & DCX_DCEBUSY) /* shared cache DCE */
{
/* FIXME: AFAICS we are doing the right thing here so
* this should be a DPRINT. But this is best left as an ERR
* because the 'application error' is likely to come from
* another part of Wine (i.e. it's our fault after all).
* We should change this to DPRINT when ReactOS is more stable
* (for 1.0?).
*/
DPRINT1("[%p] GetDC() without ReleaseDC()!\n", Window->hSelf);
DceReleaseDC(pDCE, FALSE);
}
pDCE->DCXFlags |= DCX_DCEEMPTY;
pDCE->hwndCurrent = 0;
}
}
pDCE = (PDCE) pDCE->List.Flink;
} while (pDCE != FirstDce);
KeLeaveCriticalRegion();
}
void FASTCALL void FASTCALL
DceFreeClassDCE(HDC hDC) DceFreeClassDCE(HDC hDC)
{ {
@ -789,9 +730,9 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
NtGdiOffsetRgn(dc->rosdc.hClipRgn, DeltaX, DeltaY); NtGdiOffsetRgn(dc->rosdc.hClipRgn, DeltaX, DeltaY);
CLIPPING_UpdateGCRegion(dc); CLIPPING_UpdateGCRegion(dc);
} }
if (NULL != pDCE->hClipRgn) if (NULL != pDCE->hrgnClip)
{ {
NtGdiOffsetRgn(pDCE->hClipRgn, DeltaX, DeltaY); NtGdiOffsetRgn(pDCE->hrgnClip, DeltaX, DeltaY);
} }
} }
DC_UnlockDc(dc); DC_UnlockDc(dc);
@ -869,29 +810,20 @@ UserGetWindowDC(PWINDOW_OBJECT Wnd)
HWND FASTCALL HWND FASTCALL
UserGethWnd( HDC hdc, PWNDOBJ *pwndo) UserGethWnd( HDC hdc, PWNDOBJ *pwndo)
{ {
PWNDGDI pWndgdi = NULL; PWNDGDI pWndgdi;
PWINDOW_OBJECT Wnd = NULL; PWINDOW_OBJECT Wnd;
HWND hWnd; HWND hWnd;
BOOL Hit = FALSE;
PLIST_ENTRY Entry;
hWnd = IntWindowFromDC(hdc); hWnd = IntWindowFromDC(hdc);
if (hWnd && !(Wnd = UserGetWindowObject(hWnd))) if (hWnd && !(Wnd = UserGetWindowObject(hWnd)))
{ {
KeEnterCriticalRegion(); pWndgdi = (WNDGDI *)IntGetProp(Wnd, AtomWndObj);
Entry = Wnd->WndObjListHead.Flink;
while (Entry != &Wnd->WndObjListHead) if ( pWndgdi && pWndgdi->Hwnd == hWnd )
{ {
pWndgdi = (PWNDGDI)Entry; if (pwndo) *pwndo = (PWNDOBJ)pWndgdi;
if (pWndgdi->Hwnd == hWnd)
{
Hit = TRUE;
break;
} }
Entry = Entry->Flink;
}
if (pwndo && Hit) *pwndo = (PWNDOBJ)pWndgdi;
KeLeaveCriticalRegion();
} }
return hWnd; return hWnd;
} }

View file

@ -478,7 +478,6 @@ static LRESULT co_UserFreeWindow(PWINDOW_OBJECT Window,
Window->SystemMenu = (HMENU)0; Window->SystemMenu = (HMENU)0;
} }
DceFreeWindowDCE(Window); /* Always do this to catch orphaned DCs */
#if 0 /* FIXME */ #if 0 /* FIXME */
WINPROC_FreeProc(Window->winproc, WIN_PROC_WINDOW); WINPROC_FreeProc(Window->winproc, WIN_PROC_WINDOW);
@ -1150,7 +1149,7 @@ co_IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent)
// return NULL; // return NULL;
/* Window must belong to current process */ /* Window must belong to current process */
if (Wnd->OwnerThread->ThreadsProcess != PsGetCurrentProcess()) if (Wnd->pti->pEThread->ThreadsProcess != PsGetCurrentProcess())
return NULL; return NULL;
WndOldParent = Wnd->spwndParent; WndOldParent = Wnd->spwndParent;
@ -1948,7 +1947,6 @@ AllocErr:
} }
} }
Window->OwnerThread = PsGetCurrentThread();
Window->spwndChild = NULL; Window->spwndChild = NULL;
Window->spwndPrev = NULL; Window->spwndPrev = NULL;
Window->spwndNext = NULL; Window->spwndNext = NULL;
@ -1960,7 +1958,6 @@ AllocErr:
Wnd->cbwndExtra = Wnd->pcls->cbwndExtra; Wnd->cbwndExtra = Wnd->pcls->cbwndExtra;
InitializeListHead(&Wnd->PropListHead); InitializeListHead(&Wnd->PropListHead);
InitializeListHead(&Window->WndObjListHead);
if ( NULL != WindowName->Buffer && WindowName->Length > 0 ) if ( NULL != WindowName->Buffer && WindowName->Length > 0 )
{ {
@ -2052,11 +2049,16 @@ AllocErr:
InsertTailList (&pti->WindowListHead, &Window->ThreadListEntry); InsertTailList (&pti->WindowListHead, &Window->ThreadListEntry);
/* Handle "CS_CLASSDC", it is tested first. */ /* Handle "CS_CLASSDC", it is tested first. */
if ((Wnd->pcls->style & CS_CLASSDC) && !(Wnd->pcls->pdce)) // One DCE per class to have CLASS. if ( (Wnd->pcls->style & CS_CLASSDC) && !(Wnd->pcls->pdce) )
{ /* One DCE per class to have CLASS. */
Wnd->pcls->pdce = DceAllocDCE( Window, DCE_CLASS_DC ); Wnd->pcls->pdce = DceAllocDCE( Window, DCE_CLASS_DC );
/* Allocate a DCE for this window. */ }
else if ( Wnd->pcls->style & CS_OWNDC) else if ( Wnd->pcls->style & CS_OWNDC)
Window->Dce = DceAllocDCE(Window, DCE_WINDOW_DC); { /* Allocate a DCE for this window. */
PDCE pDce = DceAllocDCE(Window, DCE_WINDOW_DC);
if (!Wnd->pcls->pdce)
Wnd->pcls->pdce = pDce;
}
Pos.x = x; Pos.x = x;
Pos.y = y; Pos.y = y;
@ -2107,7 +2109,7 @@ AllocErr:
PRTL_USER_PROCESS_PARAMETERS ProcessParams; PRTL_USER_PROCESS_PARAMETERS ProcessParams;
BOOL CalculatedDefPosSize = FALSE; BOOL CalculatedDefPosSize = FALSE;
IntGetDesktopWorkArea(((PTHREADINFO)Window->OwnerThread->Tcb.Win32Thread)->Desktop, &WorkArea); IntGetDesktopWorkArea(((PTHREADINFO)Window->pti->pEThread->Tcb.Win32Thread)->Desktop, &WorkArea);
rc = WorkArea; rc = WorkArea;
ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters; ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
@ -2624,7 +2626,7 @@ BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Window)
DPRINT("co_UserDestroyWindow \n"); DPRINT("co_UserDestroyWindow \n");
/* Check for owner thread */ /* Check for owner thread */
if ( (Window->OwnerThread != PsGetCurrentThread()) || if ( (Window->pti->pEThread != PsGetCurrentThread()) ||
Wnd->head.pti != PsGetCurrentThreadWin32Thread() ) Wnd->head.pti != PsGetCurrentThreadWin32Thread() )
{ {
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
@ -3765,7 +3767,7 @@ UserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi)
* WndProc is only available to the owner process * WndProc is only available to the owner process
*/ */
if (GWL_WNDPROC == Index if (GWL_WNDPROC == Index
&& Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess()) && Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess())
{ {
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
return 0; return 0;
@ -3886,7 +3888,7 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
/* /*
* Remove extended window style bit WS_EX_TOPMOST for shell windows. * Remove extended window style bit WS_EX_TOPMOST for shell windows.
*/ */
WindowStation = ((PTHREADINFO)Window->OwnerThread->Tcb.Win32Thread)->Desktop->WindowStation; WindowStation = Window->pti->Desktop->WindowStation;
if(WindowStation) if(WindowStation)
{ {
if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView) if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)

View file

@ -16,8 +16,7 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
/* $Id$ /*
*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: Windows * PURPOSE: Windows
@ -120,7 +119,7 @@ BOOL FASTCALL can_activate_window( PWINDOW_OBJECT Wnd OPTIONAL)
if (!Wnd->Wnd) return FALSE; if (!Wnd->Wnd) return FALSE;
style = Wnd->Wnd->style; style = Wnd->Wnd->style;
if (!(style & WS_VISIBLE) && if (!(style & WS_VISIBLE) &&
Wnd->OwnerThread->ThreadsProcess != CsrProcess) return FALSE; Wnd->pti->pEThread->ThreadsProcess != CsrProcess) return FALSE;
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE;
return !(style & WS_DISABLED); return !(style & WS_DISABLED);
} }
@ -905,7 +904,7 @@ co_WinPosSetWindowPos(
* Only allow CSRSS to mess with the desktop window * Only allow CSRSS to mess with the desktop window
*/ */
if (Window->hSelf == IntGetDesktopWindow() && if (Window->hSelf == IntGetDesktopWindow() &&
Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess()) Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess())
{ {
return FALSE; return FALSE;
} }