Store the internal window placement directly inside the WINDOW structure

svn path=/trunk/; revision=30610
This commit is contained in:
Thomas Bluemel 2007-11-21 05:35:33 +00:00
parent bfc8890eee
commit 2bc07496f3
7 changed files with 82 additions and 103 deletions

View file

@ -1854,7 +1854,13 @@ DWORD
STDCALL STDCALL
GetWindowContextHelpId(HWND hwnd) GetWindowContextHelpId(HWND hwnd)
{ {
return NtUserGetWindowContextHelpId(hwnd); PWINDOW Wnd = ValidateHwnd(hwnd);
if (Wnd != NULL)
{
return Wnd->ContextHelpId;
}
return 0;
} }
/* /*

View file

@ -140,10 +140,20 @@ typedef struct _WINDOW
PWINDOWCLASS Class; PWINDOWCLASS Class;
/* Window name. */ /* Window name. */
UNICODE_STRING WindowName; UNICODE_STRING WindowName;
/* Context help id */
DWORD ContextHelpId;
struct
{
RECT NormalRect;
POINT IconPos;
POINT MaxPos;
} InternalPos;
UINT Unicode : 1; UINT Unicode : 1;
/* Indicates whether the window is derived from a system class */ /* Indicates whether the window is derived from a system class */
UINT IsSystem : 1; UINT IsSystem : 1;
UINT InternalPosInitialized : 1;
} WINDOW, *PWINDOW; } WINDOW, *PWINDOW;
typedef struct _W32PROCESSINFO typedef struct _W32PROCESSINFO

View file

@ -13,17 +13,6 @@ typedef struct _WINDOW_OBJECT *PWINDOW_OBJECT;
#include <include/prop.h> #include <include/prop.h>
#include <include/scroll.h> #include <include/scroll.h>
VOID FASTCALL
WinPosSetupInternalPos(VOID);
typedef struct _INTERNALPOS
{
RECT NormalRect;
POINT IconPos;
POINT MaxPos;
} INTERNALPOS, *PINTERNALPOS;
typedef struct _WINDOW_OBJECT typedef struct _WINDOW_OBJECT
{ {
/* NOTE: Do *NOT* Move this pointer anywhere in this structure! This /* NOTE: Do *NOT* Move this pointer anywhere in this structure! This
@ -36,8 +25,6 @@ typedef struct _WINDOW_OBJECT
PW32THREADINFO ti; PW32THREADINFO ti;
/* Pointer to the desktop */ /* Pointer to the desktop */
PDESKTOP Desktop; PDESKTOP Desktop;
/* Context help id */
DWORD ContextHelpId;
/* system menu handle. */ /* system menu handle. */
HMENU SystemMenu; HMENU SystemMenu;
/* Entry in the thread's list of windows. */ /* Entry in the thread's list of windows. */
@ -71,7 +58,6 @@ typedef struct _WINDOW_OBJECT
PWINDOW_SCROLLINFO Scroll; PWINDOW_SCROLLINFO Scroll;
PETHREAD OwnerThread; PETHREAD OwnerThread;
HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/ HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/
PINTERNALPOS InternalPos;
ULONG Status; ULONG Status;
/* counter for tiled child windows */ /* counter for tiled child windows */
ULONG TiledCounter; ULONG TiledCounter;

View file

@ -35,7 +35,7 @@ co_WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTes
PWINDOW_OBJECT* Window); PWINDOW_OBJECT* Window);
VOID FASTCALL co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window); VOID FASTCALL co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window);
PINTERNALPOS FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, VOID FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject,
POINT *pt, PRECT RestoreRect); POINT *pt, PRECT RestoreRect);
#endif /* _WIN32K_WINPOS_H */ #endif /* _WIN32K_WINPOS_H */

View file

@ -301,7 +301,7 @@ NtUserCallOneParam(
RETURN( FALSE); RETURN( FALSE);
} }
Result = Window->ContextHelpId; Result = Window->Wnd->ContextHelpId;
RETURN( Result); RETURN( Result);
} }
@ -605,7 +605,7 @@ NtUserCallTwoParam(
RETURN( (DWORD)FALSE); RETURN( (DWORD)FALSE);
} }
Window->ContextHelpId = Param2; Window->Wnd->ContextHelpId = Param2;
RETURN( (DWORD)TRUE); RETURN( (DWORD)TRUE);

View file

@ -1618,7 +1618,7 @@ AllocErr:
Class = NULL; Class = NULL;
Window->SystemMenu = (HMENU)0; Window->SystemMenu = (HMENU)0;
Window->ContextHelpId = 0; Wnd->ContextHelpId = 0;
Wnd->IDMenu = 0; Wnd->IDMenu = 0;
Wnd->Instance = hInstance; Wnd->Instance = hInstance;
Window->hSelf = hWnd; Window->hSelf = hWnd;
@ -3883,7 +3883,6 @@ NtUserGetWindowPlacement(HWND hWnd,
{ {
PWINDOW_OBJECT Window; PWINDOW_OBJECT Window;
PWINDOW Wnd; PWINDOW Wnd;
PINTERNALPOS InternalPos;
POINT Size; POINT Size;
WINDOWPLACEMENT Safepl; WINDOWPLACEMENT Safepl;
NTSTATUS Status; NTSTATUS Status;
@ -3930,18 +3929,12 @@ NtUserGetWindowPlacement(HWND hWnd,
Size.x = Wnd->WindowRect.left; Size.x = Wnd->WindowRect.left;
Size.y = Wnd->WindowRect.top; Size.y = Wnd->WindowRect.top;
InternalPos = WinPosInitInternalPos(Window, &Size, WinPosInitInternalPos(Window, &Size,
&Wnd->WindowRect); &Wnd->WindowRect);
if (InternalPos)
{ Safepl.rcNormalPosition = Wnd->InternalPos.NormalRect;
Safepl.rcNormalPosition = InternalPos->NormalRect; Safepl.ptMinPosition = Wnd->InternalPos.IconPos;
Safepl.ptMinPosition = InternalPos->IconPos; Safepl.ptMaxPosition = Wnd->InternalPos.MaxPos;
Safepl.ptMaxPosition = InternalPos->MaxPos;
}
else
{
RETURN( FALSE);
}
Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT)); Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT));
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
@ -4334,11 +4327,10 @@ NtUserSetWindowPlacement(HWND hWnd,
/* FIXME - change window status */ /* FIXME - change window status */
co_WinPosShowWindow(Window, Safepl.showCmd); co_WinPosShowWindow(Window, Safepl.showCmd);
if (Window->InternalPos == NULL) Wnd->InternalPosInitialized = TRUE;
Window->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST); Wnd->InternalPos.NormalRect = Safepl.rcNormalPosition;
Window->InternalPos->NormalRect = Safepl.rcNormalPosition; Wnd->InternalPos.IconPos = Safepl.ptMinPosition;
Window->InternalPos->IconPos = Safepl.ptMinPosition; Wnd->InternalPos.MaxPos = Safepl.ptMaxPosition;
Window->InternalPos->MaxPos = Safepl.ptMaxPosition;
UserDerefObjectCo(Window); UserDerefObjectCo(Window);
RETURN(TRUE); RETURN(TRUE);

View file

@ -267,14 +267,14 @@ WinPosFindIconPos(PWINDOW_OBJECT Window, POINT *Pos)
/* FIXME */ /* FIXME */
} }
PINTERNALPOS FASTCALL VOID FASTCALL
WinPosInitInternalPos(PWINDOW_OBJECT Window, POINT *pt, PRECT RestoreRect) WinPosInitInternalPos(PWINDOW_OBJECT Window, POINT *pt, PRECT RestoreRect)
{ {
PWINDOW_OBJECT Parent; PWINDOW_OBJECT Parent;
UINT XInc, YInc; UINT XInc, YInc;
PWINDOW Wnd = Window->Wnd; PWINDOW Wnd = Window->Wnd;
if (Window->InternalPos == NULL) if (!Wnd->InternalPosInitialized)
{ {
RECT WorkArea; RECT WorkArea;
PDESKTOP_OBJECT Desktop = PsGetCurrentThreadWin32Thread()->Desktop; /* Or rather get it from the window? */ PDESKTOP_OBJECT Desktop = PsGetCurrentThreadWin32Thread()->Desktop; /* Or rather get it from the window? */
@ -290,51 +290,43 @@ WinPosInitInternalPos(PWINDOW_OBJECT Window, POINT *pt, PRECT RestoreRect)
else else
IntGetDesktopWorkArea(Desktop, &WorkArea); IntGetDesktopWorkArea(Desktop, &WorkArea);
Window->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST); Wnd->InternalPos.NormalRect = Window->Wnd->WindowRect;
if(!Window->InternalPos)
{
DPRINT1("Failed to allocate INTERNALPOS structure for window 0x%x\n", Window->hSelf);
return NULL;
}
Window->InternalPos->NormalRect = Window->Wnd->WindowRect;
IntGetWindowBorderMeasures(Window, &XInc, &YInc); IntGetWindowBorderMeasures(Window, &XInc, &YInc);
Window->InternalPos->MaxPos.x = WorkArea.left - XInc; Wnd->InternalPos.MaxPos.x = WorkArea.left - XInc;
Window->InternalPos->MaxPos.y = WorkArea.top - YInc; Wnd->InternalPos.MaxPos.y = WorkArea.top - YInc;
Window->InternalPos->IconPos.x = WorkArea.left; Wnd->InternalPos.IconPos.x = WorkArea.left;
Window->InternalPos->IconPos.y = WorkArea.bottom - UserGetSystemMetrics(SM_CYMINIMIZED); Wnd->InternalPos.IconPos.y = WorkArea.bottom - UserGetSystemMetrics(SM_CYMINIMIZED);
Wnd->InternalPosInitialized = TRUE;
} }
if (Wnd->Style & WS_MINIMIZE) if (Wnd->Style & WS_MINIMIZE)
{ {
Window->InternalPos->IconPos = *pt; Wnd->InternalPos.IconPos = *pt;
} }
else if (Wnd->Style & WS_MAXIMIZE) else if (Wnd->Style & WS_MAXIMIZE)
{ {
Window->InternalPos->MaxPos = *pt; Wnd->InternalPos.MaxPos = *pt;
} }
else if (RestoreRect != NULL) else if (RestoreRect != NULL)
{ {
Window->InternalPos->NormalRect = *RestoreRect; Wnd->InternalPos.NormalRect = *RestoreRect;
} }
return(Window->InternalPos);
} }
UINT FASTCALL UINT FASTCALL
co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos) co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos)
{ {
POINT Size; POINT Size;
PINTERNALPOS InternalPos;
UINT SwpFlags = 0; UINT SwpFlags = 0;
PWINDOW Wnd; PWINDOW Wnd;
ASSERT_REFS_CO(Window); ASSERT_REFS_CO(Window);
Wnd = Window->Wnd; Wnd = Window->Wnd;
Size.x = Window->Wnd->WindowRect.left; Size.x = Wnd->WindowRect.left;
Size.y = Window->Wnd->WindowRect.top; Size.y = Wnd->WindowRect.top;
InternalPos = WinPosInitInternalPos(Window, &Size, &Window->Wnd->WindowRect); WinPosInitInternalPos(Window, &Size, &Wnd->WindowRect);
if (InternalPos)
{
if (Wnd->Style & WS_MINIMIZE) if (Wnd->Style & WS_MINIMIZE)
{ {
if (!co_IntSendMessage(Window->hSelf, WM_QUERYOPEN, 0, 0)) if (!co_IntSendMessage(Window->hSelf, WM_QUERYOPEN, 0, 0))
@ -359,8 +351,8 @@ co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos)
co_UserRedrawWindow(Window, NULL, 0, RDW_VALIDATE | RDW_NOERASE | co_UserRedrawWindow(Window, NULL, 0, RDW_VALIDATE | RDW_NOERASE |
RDW_NOINTERNALPAINT); RDW_NOINTERNALPAINT);
Wnd->Style |= WS_MINIMIZE; Wnd->Style |= WS_MINIMIZE;
WinPosFindIconPos(Window, &InternalPos->IconPos); WinPosFindIconPos(Window, &Wnd->InternalPos.IconPos);
IntGdiSetRect(NewPos, InternalPos->IconPos.x, InternalPos->IconPos.y, IntGdiSetRect(NewPos, Wnd->InternalPos.IconPos.x, Wnd->InternalPos.IconPos.y,
UserGetSystemMetrics(SM_CXMINIMIZED), UserGetSystemMetrics(SM_CXMINIMIZED),
UserGetSystemMetrics(SM_CYMINIMIZED)); UserGetSystemMetrics(SM_CYMINIMIZED));
SwpFlags |= SWP_NOCOPYBITS; SwpFlags |= SWP_NOCOPYBITS;
@ -369,16 +361,16 @@ co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos)
case SW_MAXIMIZE: case SW_MAXIMIZE:
{ {
co_WinPosGetMinMaxInfo(Window, &Size, &InternalPos->MaxPos, co_WinPosGetMinMaxInfo(Window, &Size, &Wnd->InternalPos.MaxPos,
NULL, NULL); NULL, NULL);
DPRINT("Maximize: %d,%d %dx%d\n", DPRINT("Maximize: %d,%d %dx%d\n",
InternalPos->MaxPos.x, InternalPos->MaxPos.y, Size.x, Size.y); Wnd->InternalPos.MaxPos.x, Wnd->InternalPos.MaxPos.y, Size.x, Size.y);
if (Wnd->Style & WS_MINIMIZE) if (Wnd->Style & WS_MINIMIZE)
{ {
Wnd->Style &= ~WS_MINIMIZE; Wnd->Style &= ~WS_MINIMIZE;
} }
Wnd->Style |= WS_MAXIMIZE; Wnd->Style |= WS_MAXIMIZE;
IntGdiSetRect(NewPos, InternalPos->MaxPos.x, InternalPos->MaxPos.y, IntGdiSetRect(NewPos, Wnd->InternalPos.MaxPos.x, Wnd->InternalPos.MaxPos.y,
Size.x, Size.y); Size.x, Size.y);
break; break;
} }
@ -391,15 +383,15 @@ co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos)
if (Window->Flags & WINDOWOBJECT_RESTOREMAX) if (Window->Flags & WINDOWOBJECT_RESTOREMAX)
{ {
co_WinPosGetMinMaxInfo(Window, &Size, co_WinPosGetMinMaxInfo(Window, &Size,
&InternalPos->MaxPos, NULL, NULL); &Wnd->InternalPos.MaxPos, NULL, NULL);
Wnd->Style |= WS_MAXIMIZE; Wnd->Style |= WS_MAXIMIZE;
IntGdiSetRect(NewPos, InternalPos->MaxPos.x, IntGdiSetRect(NewPos, Wnd->InternalPos.MaxPos.x,
InternalPos->MaxPos.y, Size.x, Size.y); Wnd->InternalPos.MaxPos.y, Size.x, Size.y);
break; break;
} }
else else
{ {
*NewPos = InternalPos->NormalRect; *NewPos = Wnd->InternalPos.NormalRect;
NewPos->right -= NewPos->left; NewPos->right -= NewPos->left;
NewPos->bottom -= NewPos->top; NewPos->bottom -= NewPos->top;
break; break;
@ -412,18 +404,14 @@ co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos)
return 0; return 0;
} }
Wnd->Style &= ~WS_MAXIMIZE; Wnd->Style &= ~WS_MAXIMIZE;
*NewPos = InternalPos->NormalRect; *NewPos = Wnd->InternalPos.NormalRect;
NewPos->right -= NewPos->left; NewPos->right -= NewPos->left;
NewPos->bottom -= NewPos->top; NewPos->bottom -= NewPos->top;
break; break;
} }
} }
} }
}
else
{
SwpFlags |= SWP_NOSIZE | SWP_NOMOVE;
}
return(SwpFlags); return(SwpFlags);
} }
@ -447,9 +435,9 @@ WinPosFillMinMaxInfoStruct(PWINDOW_OBJECT Window, MINMAXINFO *Info)
Info->ptMaxTrackSize.x = Info->ptMaxSize.x; Info->ptMaxTrackSize.x = Info->ptMaxSize.x;
Info->ptMaxTrackSize.y = Info->ptMaxSize.y; Info->ptMaxTrackSize.y = Info->ptMaxSize.y;
if (Window->InternalPos != NULL) if (Window->Wnd->InternalPosInitialized)
{ {
Info->ptMaxPosition = Window->InternalPos->MaxPos; Info->ptMaxPosition = Window->Wnd->InternalPos.MaxPos;
} }
else else
{ {
@ -1696,8 +1684,8 @@ NtUserGetMinMaxInfo(
BOOL SendMessage) BOOL SendMessage)
{ {
POINT Size; POINT Size;
PINTERNALPOS InternalPos;
PWINDOW_OBJECT Window = NULL; PWINDOW_OBJECT Window = NULL;
PWINDOW Wnd;
MINMAXINFO SafeMinMax; MINMAXINFO SafeMinMax;
NTSTATUS Status; NTSTATUS Status;
DECLARE_RETURN(BOOL); DECLARE_RETURN(BOOL);
@ -1712,33 +1700,30 @@ NtUserGetMinMaxInfo(
} }
UserRefObjectCo(Window, &Ref); UserRefObjectCo(Window, &Ref);
Wnd = Window->Wnd;
Size.x = Window->Wnd->WindowRect.left; Size.x = Window->Wnd->WindowRect.left;
Size.y = Window->Wnd->WindowRect.top; Size.y = Window->Wnd->WindowRect.top;
InternalPos = WinPosInitInternalPos(Window, &Size, WinPosInitInternalPos(Window, &Size,
&Window->Wnd->WindowRect); &Wnd->WindowRect);
if(InternalPos)
{
if(SendMessage)
{
co_WinPosGetMinMaxInfo(Window, &SafeMinMax.ptMaxSize, &SafeMinMax.ptMaxPosition,
&SafeMinMax.ptMinTrackSize, &SafeMinMax.ptMaxTrackSize);
}
else
{
WinPosFillMinMaxInfoStruct(Window, &SafeMinMax);
}
Status = MmCopyToCaller(MinMaxInfo, &SafeMinMax, sizeof(MINMAXINFO));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( FALSE);
}
RETURN( TRUE); if(SendMessage)
{
co_WinPosGetMinMaxInfo(Window, &SafeMinMax.ptMaxSize, &SafeMinMax.ptMaxPosition,
&SafeMinMax.ptMinTrackSize, &SafeMinMax.ptMaxTrackSize);
}
else
{
WinPosFillMinMaxInfoStruct(Window, &SafeMinMax);
}
Status = MmCopyToCaller(MinMaxInfo, &SafeMinMax, sizeof(MINMAXINFO));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( FALSE);
} }
RETURN( FALSE); RETURN( TRUE);
CLEANUP: CLEANUP:
if (Window) UserDerefObjectCo(Window); if (Window) UserDerefObjectCo(Window);