diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 5bd206eb531..86c05452506 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -1854,7 +1854,13 @@ DWORD STDCALL GetWindowContextHelpId(HWND hwnd) { - return NtUserGetWindowContextHelpId(hwnd); + PWINDOW Wnd = ValidateHwnd(hwnd); + if (Wnd != NULL) + { + return Wnd->ContextHelpId; + } + + return 0; } /* diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index 78f5e8d94dd..05afa0a0892 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -140,10 +140,20 @@ typedef struct _WINDOW PWINDOWCLASS Class; /* Window name. */ UNICODE_STRING WindowName; + /* Context help id */ + DWORD ContextHelpId; + + struct + { + RECT NormalRect; + POINT IconPos; + POINT MaxPos; + } InternalPos; UINT Unicode : 1; /* Indicates whether the window is derived from a system class */ UINT IsSystem : 1; + UINT InternalPosInitialized : 1; } WINDOW, *PWINDOW; typedef struct _W32PROCESSINFO diff --git a/reactos/subsystems/win32/win32k/include/window.h b/reactos/subsystems/win32/win32k/include/window.h index 0fc8e0c46e5..c9bd93e8229 100644 --- a/reactos/subsystems/win32/win32k/include/window.h +++ b/reactos/subsystems/win32/win32k/include/window.h @@ -13,17 +13,6 @@ typedef struct _WINDOW_OBJECT *PWINDOW_OBJECT; #include #include - -VOID FASTCALL -WinPosSetupInternalPos(VOID); - -typedef struct _INTERNALPOS -{ - RECT NormalRect; - POINT IconPos; - POINT MaxPos; -} INTERNALPOS, *PINTERNALPOS; - typedef struct _WINDOW_OBJECT { /* NOTE: Do *NOT* Move this pointer anywhere in this structure! This @@ -36,8 +25,6 @@ typedef struct _WINDOW_OBJECT PW32THREADINFO ti; /* Pointer to the desktop */ PDESKTOP Desktop; - /* Context help id */ - DWORD ContextHelpId; /* system menu handle. */ HMENU SystemMenu; /* Entry in the thread's list of windows. */ @@ -71,7 +58,6 @@ typedef struct _WINDOW_OBJECT PWINDOW_SCROLLINFO Scroll; PETHREAD OwnerThread; HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/ - PINTERNALPOS InternalPos; ULONG Status; /* counter for tiled child windows */ ULONG TiledCounter; diff --git a/reactos/subsystems/win32/win32k/include/winpos.h b/reactos/subsystems/win32/win32k/include/winpos.h index 837a1e9b3b7..5791544548a 100644 --- a/reactos/subsystems/win32/win32k/include/winpos.h +++ b/reactos/subsystems/win32/win32k/include/winpos.h @@ -35,7 +35,7 @@ co_WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTes PWINDOW_OBJECT* Window); VOID FASTCALL co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window); -PINTERNALPOS FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, - POINT *pt, PRECT RestoreRect); +VOID FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, + POINT *pt, PRECT RestoreRect); #endif /* _WIN32K_WINPOS_H */ diff --git a/reactos/subsystems/win32/win32k/ntuser/misc.c b/reactos/subsystems/win32/win32k/ntuser/misc.c index 5424ba6f24e..e48589ce215 100644 --- a/reactos/subsystems/win32/win32k/ntuser/misc.c +++ b/reactos/subsystems/win32/win32k/ntuser/misc.c @@ -301,7 +301,7 @@ NtUserCallOneParam( RETURN( FALSE); } - Result = Window->ContextHelpId; + Result = Window->Wnd->ContextHelpId; RETURN( Result); } @@ -605,7 +605,7 @@ NtUserCallTwoParam( RETURN( (DWORD)FALSE); } - Window->ContextHelpId = Param2; + Window->Wnd->ContextHelpId = Param2; RETURN( (DWORD)TRUE); diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index a92734eba2a..27a37410b43 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -1618,7 +1618,7 @@ AllocErr: Class = NULL; Window->SystemMenu = (HMENU)0; - Window->ContextHelpId = 0; + Wnd->ContextHelpId = 0; Wnd->IDMenu = 0; Wnd->Instance = hInstance; Window->hSelf = hWnd; @@ -3883,7 +3883,6 @@ NtUserGetWindowPlacement(HWND hWnd, { PWINDOW_OBJECT Window; PWINDOW Wnd; - PINTERNALPOS InternalPos; POINT Size; WINDOWPLACEMENT Safepl; NTSTATUS Status; @@ -3930,18 +3929,12 @@ NtUserGetWindowPlacement(HWND hWnd, Size.x = Wnd->WindowRect.left; Size.y = Wnd->WindowRect.top; - InternalPos = WinPosInitInternalPos(Window, &Size, - &Wnd->WindowRect); - if (InternalPos) - { - Safepl.rcNormalPosition = InternalPos->NormalRect; - Safepl.ptMinPosition = InternalPos->IconPos; - Safepl.ptMaxPosition = InternalPos->MaxPos; - } - else - { - RETURN( FALSE); - } + WinPosInitInternalPos(Window, &Size, + &Wnd->WindowRect); + + Safepl.rcNormalPosition = Wnd->InternalPos.NormalRect; + Safepl.ptMinPosition = Wnd->InternalPos.IconPos; + Safepl.ptMaxPosition = Wnd->InternalPos.MaxPos; Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT)); if(!NT_SUCCESS(Status)) @@ -4334,11 +4327,10 @@ NtUserSetWindowPlacement(HWND hWnd, /* FIXME - change window status */ co_WinPosShowWindow(Window, Safepl.showCmd); - if (Window->InternalPos == NULL) - Window->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST); - Window->InternalPos->NormalRect = Safepl.rcNormalPosition; - Window->InternalPos->IconPos = Safepl.ptMinPosition; - Window->InternalPos->MaxPos = Safepl.ptMaxPosition; + Wnd->InternalPosInitialized = TRUE; + Wnd->InternalPos.NormalRect = Safepl.rcNormalPosition; + Wnd->InternalPos.IconPos = Safepl.ptMinPosition; + Wnd->InternalPos.MaxPos = Safepl.ptMaxPosition; UserDerefObjectCo(Window); RETURN(TRUE); diff --git a/reactos/subsystems/win32/win32k/ntuser/winpos.c b/reactos/subsystems/win32/win32k/ntuser/winpos.c index 700f8d2a615..e073b3e70cf 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winpos.c +++ b/reactos/subsystems/win32/win32k/ntuser/winpos.c @@ -267,14 +267,14 @@ WinPosFindIconPos(PWINDOW_OBJECT Window, POINT *Pos) /* FIXME */ } -PINTERNALPOS FASTCALL +VOID FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT Window, POINT *pt, PRECT RestoreRect) { - PWINDOW_OBJECT Parent; - UINT XInc, YInc; - PWINDOW Wnd = Window->Wnd; + PWINDOW_OBJECT Parent; + UINT XInc, YInc; + PWINDOW Wnd = Window->Wnd; - if (Window->InternalPos == NULL) + if (!Wnd->InternalPosInitialized) { RECT WorkArea; 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 IntGetDesktopWorkArea(Desktop, &WorkArea); - Window->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST); - if(!Window->InternalPos) - { - DPRINT1("Failed to allocate INTERNALPOS structure for window 0x%x\n", Window->hSelf); - return NULL; - } - Window->InternalPos->NormalRect = Window->Wnd->WindowRect; + Wnd->InternalPos.NormalRect = Window->Wnd->WindowRect; IntGetWindowBorderMeasures(Window, &XInc, &YInc); - Window->InternalPos->MaxPos.x = WorkArea.left - XInc; - Window->InternalPos->MaxPos.y = WorkArea.top - YInc; - Window->InternalPos->IconPos.x = WorkArea.left; - Window->InternalPos->IconPos.y = WorkArea.bottom - UserGetSystemMetrics(SM_CYMINIMIZED); + Wnd->InternalPos.MaxPos.x = WorkArea.left - XInc; + Wnd->InternalPos.MaxPos.y = WorkArea.top - YInc; + Wnd->InternalPos.IconPos.x = WorkArea.left; + Wnd->InternalPos.IconPos.y = WorkArea.bottom - UserGetSystemMetrics(SM_CYMINIMIZED); + + Wnd->InternalPosInitialized = TRUE; } if (Wnd->Style & WS_MINIMIZE) { - Window->InternalPos->IconPos = *pt; + Wnd->InternalPos.IconPos = *pt; } else if (Wnd->Style & WS_MAXIMIZE) { - Window->InternalPos->MaxPos = *pt; + Wnd->InternalPos.MaxPos = *pt; } else if (RestoreRect != NULL) { - Window->InternalPos->NormalRect = *RestoreRect; + Wnd->InternalPos.NormalRect = *RestoreRect; } - return(Window->InternalPos); } UINT FASTCALL co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos) { POINT Size; - PINTERNALPOS InternalPos; UINT SwpFlags = 0; PWINDOW Wnd; ASSERT_REFS_CO(Window); Wnd = Window->Wnd; - Size.x = Window->Wnd->WindowRect.left; - Size.y = Window->Wnd->WindowRect.top; - InternalPos = WinPosInitInternalPos(Window, &Size, &Window->Wnd->WindowRect); + Size.x = Wnd->WindowRect.left; + Size.y = Wnd->WindowRect.top; + WinPosInitInternalPos(Window, &Size, &Wnd->WindowRect); - if (InternalPos) - { if (Wnd->Style & WS_MINIMIZE) { 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 | RDW_NOINTERNALPAINT); Wnd->Style |= WS_MINIMIZE; - WinPosFindIconPos(Window, &InternalPos->IconPos); - IntGdiSetRect(NewPos, InternalPos->IconPos.x, InternalPos->IconPos.y, + WinPosFindIconPos(Window, &Wnd->InternalPos.IconPos); + IntGdiSetRect(NewPos, Wnd->InternalPos.IconPos.x, Wnd->InternalPos.IconPos.y, UserGetSystemMetrics(SM_CXMINIMIZED), UserGetSystemMetrics(SM_CYMINIMIZED)); SwpFlags |= SWP_NOCOPYBITS; @@ -369,16 +361,16 @@ co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos) case SW_MAXIMIZE: { - co_WinPosGetMinMaxInfo(Window, &Size, &InternalPos->MaxPos, + co_WinPosGetMinMaxInfo(Window, &Size, &Wnd->InternalPos.MaxPos, NULL, NULL); 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) { Wnd->Style &= ~WS_MINIMIZE; } 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); break; } @@ -391,15 +383,15 @@ co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos) if (Window->Flags & WINDOWOBJECT_RESTOREMAX) { co_WinPosGetMinMaxInfo(Window, &Size, - &InternalPos->MaxPos, NULL, NULL); + &Wnd->InternalPos.MaxPos, NULL, NULL); Wnd->Style |= WS_MAXIMIZE; - IntGdiSetRect(NewPos, InternalPos->MaxPos.x, - InternalPos->MaxPos.y, Size.x, Size.y); + IntGdiSetRect(NewPos, Wnd->InternalPos.MaxPos.x, + Wnd->InternalPos.MaxPos.y, Size.x, Size.y); break; } else { - *NewPos = InternalPos->NormalRect; + *NewPos = Wnd->InternalPos.NormalRect; NewPos->right -= NewPos->left; NewPos->bottom -= NewPos->top; break; @@ -412,18 +404,14 @@ co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos) return 0; } Wnd->Style &= ~WS_MAXIMIZE; - *NewPos = InternalPos->NormalRect; + *NewPos = Wnd->InternalPos.NormalRect; NewPos->right -= NewPos->left; NewPos->bottom -= NewPos->top; break; } } } - } - else - { - SwpFlags |= SWP_NOSIZE | SWP_NOMOVE; - } + return(SwpFlags); } @@ -447,9 +435,9 @@ WinPosFillMinMaxInfoStruct(PWINDOW_OBJECT Window, MINMAXINFO *Info) Info->ptMaxTrackSize.x = Info->ptMaxSize.x; 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 { @@ -1696,8 +1684,8 @@ NtUserGetMinMaxInfo( BOOL SendMessage) { POINT Size; - PINTERNALPOS InternalPos; PWINDOW_OBJECT Window = NULL; + PWINDOW Wnd; MINMAXINFO SafeMinMax; NTSTATUS Status; DECLARE_RETURN(BOOL); @@ -1712,33 +1700,30 @@ NtUserGetMinMaxInfo( } UserRefObjectCo(Window, &Ref); + Wnd = Window->Wnd; Size.x = Window->Wnd->WindowRect.left; Size.y = Window->Wnd->WindowRect.top; - InternalPos = WinPosInitInternalPos(Window, &Size, - &Window->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); - } + WinPosInitInternalPos(Window, &Size, + &Wnd->WindowRect); - 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: if (Window) UserDerefObjectCo(Window);