Window = UserGetWindowObject(hWnd);
if (Window)
{
- ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0);
+ ASSERT(Window->head.cLockObj >= 0);
- USER_BODY_TO_HEADER(Window)->RefCount++;
+ Window->head.cLockObj++;
}
return Window;
}
return NULL;
}
- ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0);
+ ASSERT(Window->head.cLockObj >= 0);
return Window;
}
/* don't remove the WINDOWSTATUS_DESTROYING bit */
/* reset shell window handles */
- if(ThreadData->Desktop)
+ if(ThreadData->rpdesk)
{
- if (Window->hSelf == ThreadData->Desktop->WindowStation->ShellWindow)
- ThreadData->Desktop->WindowStation->ShellWindow = NULL;
+ if (Window->hSelf == ThreadData->rpdesk->rpwinstaParent->ShellWindow)
+ ThreadData->rpdesk->rpwinstaParent->ShellWindow = NULL;
- if (Window->hSelf == ThreadData->Desktop->WindowStation->ShellListView)
- ThreadData->Desktop->WindowStation->ShellListView = NULL;
+ if (Window->hSelf == ThreadData->rpdesk->rpwinstaParent->ShellListView)
+ ThreadData->rpdesk->rpwinstaParent->ShellListView = NULL;
}
/* Unregister hot keys */
Window->pti->ppi);
Wnd->pcls = NULL;
- if(Window->WindowRegion)
+ if(Window->hrgnClip)
{
- GreDeleteObject(Window->WindowRegion);
+ GreDeleteObject(Window->hrgnClip);
}
ASSERT(Window->Wnd != NULL);
{
W32Thread = PsGetCurrentThreadWin32Thread();
- if(!W32Thread->Desktop)
+ if(!W32Thread->rpdesk)
return NULL;
if(Window->SystemMenu)
}
}
- if(W32Thread->Desktop->WindowStation->SystemMenuTemplate)
+ if(W32Thread->rpdesk->rpwinstaParent->SystemMenuTemplate)
{
/* clone system menu */
- Menu = UserGetMenuObject(W32Thread->Desktop->WindowStation->SystemMenuTemplate);
+ Menu = UserGetMenuObject(W32Thread->rpdesk->rpwinstaParent->SystemMenuTemplate);
if(!Menu)
return NULL;
// return NULL;
/* Window must belong to current process */
- if (Wnd->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
+ if (Wnd->pti->pEThread->ThreadsProcess != PsGetCurrentProcess())
return NULL;
WndOldParent = Wnd->spwndParent;
if (Wnd->spwndParent && Wnd->spwndParent->spwndChild == Wnd)
Wnd->spwndParent->spwndChild = Wnd->spwndNext;
- Wnd->spwndParent = Wnd->spwndPrev = Wnd->spwndNext = Wnd->spwndParent = NULL;
+ Wnd->spwndPrev = Wnd->spwndNext = Wnd->spwndParent = NULL;
}
* calculates the default position of a window
*/
BOOL FASTCALL
-IntCalcDefPosSize(PWINDOW_OBJECT Parent, PWINDOW_OBJECT Window, RECTL *rc, BOOL IncPos)
+IntCalcDefPosSize(PWINDOW_OBJECT Parent, RECTL *rc, BOOL IncPos)
{
SIZE Sz;
+ PMONITOR pMonitor;
POINT Pos = {0, 0};
+
+ pMonitor = IntGetPrimaryMonitor();
if(Parent != NULL)
{
- RECTL_bIntersectRect(rc, rc, &Parent->Wnd->rcClient);
+ RECTL_bIntersectRect(rc, rc, &pMonitor->rcMonitor);
if(IncPos)
{
- Pos.x = Parent->TiledCounter * (UserGetSystemMetrics(SM_CXSIZE) + UserGetSystemMetrics(SM_CXFRAME));
- Pos.y = Parent->TiledCounter * (UserGetSystemMetrics(SM_CYSIZE) + UserGetSystemMetrics(SM_CYFRAME));
- if(Pos.x > ((rc->right - rc->left) / 4) ||
- Pos.y > ((rc->bottom - rc->top) / 4))
+ Pos.x = pMonitor->cWndStack * (UserGetSystemMetrics(SM_CXSIZE) + UserGetSystemMetrics(SM_CXFRAME));
+ Pos.y = pMonitor->cWndStack * (UserGetSystemMetrics(SM_CYSIZE) + UserGetSystemMetrics(SM_CYFRAME));
+ if (Pos.x > ((rc->right - rc->left) / 4) ||
+ Pos.y > ((rc->bottom - rc->top) / 4))
{
/* reset counter and position */
Pos.x = 0;
Pos.y = 0;
- Parent->TiledCounter = 0;
+ pMonitor->cWndStack = 0;
}
- Parent->TiledCounter++;
+ pMonitor->cWndStack++;
}
Pos.x += rc->left;
Pos.y += rc->top;
pti = PsGetCurrentThreadWin32Thread();
- if (pti->Desktop)
+ if (pti->rpdesk)
{
- ParentWindowHandle = pti->Desktop->DesktopWindow;
+ ParentWindowHandle = pti->rpdesk->DesktopWindow;
}
/* Check the window station. */
ti = GetW32ThreadInfo();
- if (ti == NULL || pti->Desktop == NULL)
+ if (ti == NULL || pti->rpdesk == NULL)
{
DPRINT1("Thread is not attached to a desktop! Cannot create window!\n");
RETURN( (PWND)0);
DPRINT("ClassAtom %x\n", ClassAtom);
Class = IntReferenceClass(Class,
ClassLink,
- pti->Desktop);
+ pti->rpdesk);
if (Class == NULL)
{
DPRINT1("Failed to reference window class!\n");
RETURN(NULL);
}
- WinSta = pti->Desktop->WindowStation;
+ WinSta = pti->rpdesk->rpwinstaParent;
//FIXME: Reference thread/desktop instead
ObReferenceObjectByPointer(WinSta, KernelMode, ExWindowStationObjectType, 0);
/* Create the window object. */
Window = (PWINDOW_OBJECT) UserCreateObject( gHandleTable,
+ pti->rpdesk,
(PHANDLE)&hWnd,
otWindow,
sizeof(WINDOW_OBJECT));
if (Window)
{
- Window->Wnd = DesktopHeapAlloc(pti->Desktop,
+ Window->Wnd = DesktopHeapAlloc(pti->rpdesk,
sizeof(WND) + Class->cbwndExtra);
if (!Window->Wnd)
goto AllocErr;
Wnd->fnid = 0;
Wnd->head.pti = ti;
- Wnd->head.rpdesk = pti->Desktop;
+ Wnd->head.rpdesk = pti->rpdesk;
Wnd->hWndLastActive = hWnd;
Wnd->state2 |= WNDS2_WIN40COMPAT;
}
ObDereferenceObject(WinSta);
- if (NULL == pti->Desktop->DesktopWindow)
+ if (NULL == pti->rpdesk->DesktopWindow)
{
/* If there is no desktop window yet, we must be creating it */
- pti->Desktop->DesktopWindow = hWnd;
- pti->Desktop->pDeskInfo->Wnd = Wnd;
+ pti->rpdesk->DesktopWindow = hWnd;
+ pti->rpdesk->pDeskInfo->spwnd = Wnd;
}
/*
Wnd->hModule = hInstance;
Window->hSelf = hWnd;
- Window->MessageQueue = pti->MessageQueue;
- IntReferenceMessageQueue(Window->MessageQueue);
+ IntReferenceMessageQueue(Window->pti->MessageQueue);
Window->spwndParent = ParentWindow;
Wnd->spwndParent = ParentWindow ? ParentWindow->Wnd : NULL;
if (Wnd->spwndParent != NULL && hWndParent != 0)
}
}
- Window->OwnerThread = PsGetCurrentThread();
Window->spwndChild = NULL;
Window->spwndPrev = NULL;
Window->spwndNext = NULL;
Wnd->cbwndExtra = Wnd->pcls->cbwndExtra;
InitializeListHead(&Wnd->PropListHead);
- InitializeListHead(&Window->WndObjListHead);
if ( NULL != WindowName->Buffer && WindowName->Length > 0 )
{
InsertTailList (&pti->WindowListHead, &Window->ThreadListEntry);
/* Handle "CS_CLASSDC", it is tested first. */
- if ((Wnd->pcls->style & CS_CLASSDC) && !(Wnd->pcls->pdce)) // One DCE per class to have CLASS.
- Wnd->pcls->pdce = DceAllocDCE(Window, DCE_CLASS_DC);
- /* Allocate a DCE for this window. */
+ if ( (Wnd->pcls->style & CS_CLASSDC) && !(Wnd->pcls->pdce) )
+ { /* One DCE per class to have CLASS. */
+ Wnd->pcls->pdce = DceAllocDCE( Window, DCE_CLASS_DC );
+ }
else if ( Wnd->pcls->style & CS_OWNDC)
- Window->Dce = DceAllocDCE(Window, DCE_WINDOW_DC);
+ { /* Allocate a DCE for this window. */
+ DceAllocDCE(Window, DCE_WINDOW_DC);
+ }
Pos.x = x;
Pos.y = y;
PRTL_USER_PROCESS_PARAMETERS ProcessParams;
BOOL CalculatedDefPosSize = FALSE;
- IntGetDesktopWorkArea(((PTHREADINFO)Window->OwnerThread->Tcb.Win32Thread)->Desktop, &WorkArea);
+ IntGetDesktopWorkArea(Window->pti->rpdesk, &WorkArea);
rc = WorkArea;
ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
if(x == CW_USEDEFAULT || x == CW_USEDEFAULT16)
{
- CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, Window, &rc, TRUE);
+ CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, &rc, TRUE);
if(ProcessParams->WindowFlags & STARTF_USEPOSITION)
{
{
if(!CalculatedDefPosSize)
{
- IntCalcDefPosSize(ParentWindow, Window, &rc, FALSE);
+ IntCalcDefPosSize(ParentWindow, &rc, FALSE);
}
if(ProcessParams->WindowFlags & STARTF_USESIZE)
{
}
IntLinkWindow(Window, ParentWindow, InsertAfter /* prev sibling */);
-
}
}
DPRINT("co_UserDestroyWindow \n");
/* Check for owner thread */
- if ( (Window->OwnerThread != PsGetCurrentThread()) ||
+ if ( (Window->pti->pEThread != PsGetCurrentThread()) ||
Wnd->head.pti != PsGetCurrentThreadWin32Thread() )
{
SetLastWin32Error(ERROR_ACCESS_DENIED);
}
}
- if (Window->MessageQueue->ActiveWindow == Window->hSelf)
- Window->MessageQueue->ActiveWindow = NULL;
- if (Window->MessageQueue->FocusWindow == Window->hSelf)
- Window->MessageQueue->FocusWindow = NULL;
- if (Window->MessageQueue->CaptureWindow == Window->hSelf)
- Window->MessageQueue->CaptureWindow = NULL;
+ if (Window->pti->MessageQueue->ActiveWindow == Window->hSelf)
+ Window->pti->MessageQueue->ActiveWindow = NULL;
+ if (Window->pti->MessageQueue->FocusWindow == Window->hSelf)
+ Window->pti->MessageQueue->FocusWindow = NULL;
+ if (Window->pti->MessageQueue->CaptureWindow == Window->hSelf)
+ Window->pti->MessageQueue->CaptureWindow = NULL;
- IntDereferenceMessageQueue(Window->MessageQueue);
+ IntDereferenceMessageQueue(Window->pti->MessageQueue);
IntEngWindowChanged(Window, WOC_DELETE);
isChild = (0 != (Wnd->style & WS_CHILD));
* WndProc is only available to the owner process
*/
if (GWL_WNDPROC == Index
- && Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
+ && Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess())
{
SetLastWin32Error(ERROR_ACCESS_DENIED);
return 0;
/*
* Remove extended window style bit WS_EX_TOPMOST for shell windows.
*/
- WindowStation = ((PTHREADINFO)Window->OwnerThread->Tcb.Win32Thread)->Desktop->WindowStation;
+ WindowStation = Window->pti->rpdesk->rpwinstaParent;
if(WindowStation)
{
if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)
break;
case QUERY_WINDOW_ISHUNG:
- Result = (DWORD)MsqIsHung(Window->MessageQueue);
+ Result = (DWORD)MsqIsHung(Window->pti->MessageQueue);
break;
case QUERY_WINDOW_REAL_ID:
Wnd = Window->Wnd;
/* Create a new window region using the window rectangle */
- VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->rcWindow);
+ VisRgn = IntSysCreateRectRgnIndirect(&Window->Wnd->rcWindow);
NtGdiOffsetRgn(VisRgn, -Window->Wnd->rcWindow.left, -Window->Wnd->rcWindow.top);
/* if there's a region assigned to the window, combine them both */
- if(Window->WindowRegion && !(Wnd->style & WS_MINIMIZE))
- NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
+ if(Window->hrgnClip && !(Wnd->style & WS_MINIMIZE))
+ NtGdiCombineRgn(VisRgn, VisRgn, Window->hrgnClip, RGN_AND);
/* Copy the region into hRgn */
NtGdiCombineRgn(hRgn, VisRgn, NULL, RGN_COPY);
else
Ret = ERROR;
- GreDeleteObject(VisRgn);
+ REGION_FreeRgnByHandle(VisRgn);
return Ret;
}
Wnd = Window->Wnd;
/* Create a new window region using the window rectangle */
- VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->rcWindow);
+ VisRgn = IntSysCreateRectRgnIndirect(&Window->Wnd->rcWindow);
NtGdiOffsetRgn(VisRgn, -Window->Wnd->rcWindow.left, -Window->Wnd->rcWindow.top);
/* if there's a region assigned to the window, combine them both */
- if(Window->WindowRegion && !(Wnd->style & WS_MINIMIZE))
- NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
+ if(Window->hrgnClip && !(Wnd->style & WS_MINIMIZE))
+ NtGdiCombineRgn(VisRgn, VisRgn, Window->hrgnClip, RGN_AND);
if((pRgn = RGNOBJAPI_Lock(VisRgn, NULL)))
{
else
Ret = ERROR;
- GreDeleteObject(VisRgn);
+ REGION_FreeRgnByHandle(VisRgn);
return Ret;
}
HRGN hRgn,
BOOL bRedraw)
{
+ HRGN hrgnCopy;
PWINDOW_OBJECT Window;
DECLARE_RETURN(INT);
RETURN( 0);
}
- /* FIXME - Verify if hRgn is a valid handle!!!!
- Propably make this operation thread-safe, but maybe it's not necessary */
+ if (hRgn) // The region will be deleted in user32.
+ {
+ if (GDIOBJ_ValidateHandle(hRgn, GDI_OBJECT_TYPE_REGION))
+ {
+ hrgnCopy = IntSysCreateRectRgn(0, 0, 0, 0);
+ NtGdiCombineRgn(hrgnCopy, hRgn, 0, RGN_COPY);
+ }
+ else
+ RETURN( 0);
+ }
+ else
+ hrgnCopy = (HRGN) 1;
- if(Window->WindowRegion)
+ if (Window->hrgnClip)
{
/* Delete no longer needed region handle */
- GreDeleteObject(Window->WindowRegion);
+ GreDeleteObject(Window->hrgnClip);
}
- Window->WindowRegion = hRgn;
+ Window->hrgnClip = hrgnCopy;
/* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window */
}
case otMonitor:
{
- PMONITOR_OBJECT Monitor;
+ PMONITOR Monitor;
if ((Monitor = UserGetMonitorObject((HMONITOR) handle))) return TRUE;
return FALSE;
}