https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1f619b27814f3bbf96737…
commit 1f619b27814f3bbf9673754a69bcae50c89fed19
Author: jimtabor <james.tabor(a)reactos.org>
AuthorDate: Tue Mar 26 15:56:57 2019 -0500
Commit: jimtabor <james.tabor(a)reactos.org>
CommitDate: Tue Mar 26 15:56:57 2019 -0500
[Win32SS] Fix maximized window positioning.
Fix CORE-5177 TaskMgr and ProcExp possionong when maximized.
---
win32ss/user/ntuser/winpos.c | 99 ++++++++++++++++++++----------------
win32ss/user/user32/windows/winpos.c | 5 +-
2 files changed, 58 insertions(+), 46 deletions(-)
diff --git a/win32ss/user/ntuser/winpos.c b/win32ss/user/ntuser/winpos.c
index 66f35304606..2083526ee3b 100644
--- a/win32ss/user/ntuser/winpos.c
+++ b/win32ss/user/ntuser/winpos.c
@@ -888,14 +888,14 @@ UserGetWindowBorders(DWORD Style, DWORD ExStyle, SIZE *Size, BOOL
WithClient)
if (UserHasWindowEdge(Style, ExStyle))
Border += 2;
- else if (ExStyle & WS_EX_STATICEDGE)
- Border += 1;
+ else if ((ExStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == WS_EX_STATICEDGE)
+ Border += 1; /* for the outer frame always present */
if ((ExStyle & WS_EX_CLIENTEDGE) && WithClient)
Border += 2;
if (Style & WS_CAPTION || ExStyle & WS_EX_DLGMODALFRAME)
- Border ++;
+ Border ++; /* The other border */
Size->cx = Size->cy = Border;
- if ((Style & WS_THICKFRAME) && !(Style & WS_MINIMIZE))
+ if ((Style & WS_THICKFRAME) && !(Style & WS_MINIMIZE)) /* The resize
border */
{
Size->cx += UserGetSystemMetrics(SM_CXFRAME) -
UserGetSystemMetrics(SM_CXDLGFRAME);
Size->cy += UserGetSystemMetrics(SM_CYFRAME) -
UserGetSystemMetrics(SM_CYDLGFRAME);
@@ -904,32 +904,27 @@ UserGetWindowBorders(DWORD Style, DWORD ExStyle, SIZE *Size, BOOL
WithClient)
Size->cy *= UserGetSystemMetrics(SM_CYBORDER);
}
-BOOL WINAPI
-UserAdjustWindowRectEx(LPRECT lpRect,
- DWORD dwStyle,
- BOOL bMenu,
- DWORD dwExStyle)
+//
+// Fix CORE-5177
+// See winetests:user32:win.c:wine_AdjustWindowRectEx,
+// Simplified version.
+//
+DWORD IntGetWindowBorders(DWORD Style, DWORD ExStyle)
{
- SIZE BorderSize;
+ DWORD adjust = 0;
- if (bMenu)
- {
- lpRect->top -= UserGetSystemMetrics(SM_CYMENU);
- }
- if ((dwStyle & WS_CAPTION) == WS_CAPTION)
- {
- if (dwExStyle & WS_EX_TOOLWINDOW)
- lpRect->top -= UserGetSystemMetrics(SM_CYSMCAPTION);
- else
- lpRect->top -= UserGetSystemMetrics(SM_CYCAPTION);
- }
- UserGetWindowBorders(dwStyle, dwExStyle, &BorderSize, TRUE);
- RECTL_vInflateRect(
- lpRect,
- BorderSize.cx,
- BorderSize.cy);
+ if ( ExStyle & WS_EX_WINDOWEDGE ) // 1st
+ adjust = 2; /* outer */
+ else if ( ExStyle & WS_EX_STATICEDGE ) // 2nd
+ adjust = 1; /* for the outer frame always present */
- return TRUE;
+ if (ExStyle & WS_EX_CLIENTEDGE)
+ adjust += 2;
+
+ if ( Style & WS_CAPTION || ExStyle & WS_EX_DLGMODALFRAME )
+ adjust++; /* The other border */
+
+ return adjust;
}
UINT FASTCALL
@@ -943,6 +938,7 @@ co_WinPosGetMinMaxInfo(PWND Window, POINT* MaxSize, POINT* MaxPos,
LONG adjustedStyle;
LONG exstyle = Window->ExStyle;
RECT rc;
+ DWORD adjust;
ASSERT_REFS_CO(Window);
@@ -957,9 +953,22 @@ co_WinPosGetMinMaxInfo(PWND Window, POINT* MaxSize, POINT* MaxPos,
else
adjustedStyle = style;
- if(Window->spwndParent)
+ if (Window->spwndParent)
IntGetClientRect(Window->spwndParent, &rc);
- UserAdjustWindowRectEx(&rc, adjustedStyle, ((style & WS_POPUP) &&
Window->IDMenu), exstyle);
+
+ adjust = IntGetWindowBorders(adjustedStyle, exstyle);
+
+ xinc = yinc = adjust;
+
+ if ((adjustedStyle & WS_THICKFRAME) && (adjustedStyle & WS_CHILD)
&& !(adjustedStyle & WS_MINIMIZE))
+ {
+ xinc += UserGetSystemMetrics(SM_CXFRAME) - UserGetSystemMetrics(SM_CXDLGFRAME);
+ yinc += UserGetSystemMetrics(SM_CYFRAME) - UserGetSystemMetrics(SM_CYDLGFRAME);
+ }
+
+ RECTL_vInflateRect( &rc,
+ xinc * UserGetSystemMetrics(SM_CXBORDER),
+ yinc * UserGetSystemMetrics(SM_CYBORDER) );
xinc = -rc.left;
yinc = -rc.top;
@@ -981,7 +990,7 @@ co_WinPosGetMinMaxInfo(PWND Window, POINT* MaxSize, POINT* MaxPos,
MinMax.ptMaxPosition.x = -xinc;
MinMax.ptMaxPosition.y = -yinc;
- if (!EMPTYPOINT(Window->InternalPos.MaxPos)) MinMax.ptMaxPosition =
Window->InternalPos.MaxPos;
+ if (!EMPTYPOINT(Window->InternalPos.MaxPos)) MinMax.ptMaxPosition =
Window->InternalPos.MaxPos;
co_IntSendMessage(Window->head.h, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
@@ -995,7 +1004,7 @@ co_WinPosGetMinMaxInfo(PWND Window, POINT* MaxSize, POINT* MaxPos,
if (style & WS_MAXIMIZEBOX)
{
if ((style & WS_CAPTION) == WS_CAPTION || !(style & (WS_CHILD |
WS_POPUP)))
- rc_work = monitor->rcWork;
+ rc_work = monitor->rcWork;
}
if (MinMax.ptMaxSize.x == UserGetSystemMetrics(SM_CXSCREEN) + 2 * xinc
&&
@@ -1011,27 +1020,29 @@ co_WinPosGetMinMaxInfo(PWND Window, POINT* MaxSize, POINT*
MaxPos,
}
if (MinMax.ptMaxSize.x >= (monitor->rcMonitor.right -
monitor->rcMonitor.left) &&
MinMax.ptMaxSize.y >= (monitor->rcMonitor.bottom -
monitor->rcMonitor.top) )
+ {
Window->state |= WNDS_MAXIMIZESTOMONITOR;
+ }
else
Window->state &= ~WNDS_MAXIMIZESTOMONITOR;
}
- MinMax.ptMaxTrackSize.x = max(MinMax.ptMaxTrackSize.x,
- MinMax.ptMinTrackSize.x);
- MinMax.ptMaxTrackSize.y = max(MinMax.ptMaxTrackSize.y,
- MinMax.ptMinTrackSize.y);
+ MinMax.ptMaxTrackSize.x = max(MinMax.ptMaxTrackSize.x,
+ MinMax.ptMinTrackSize.x);
+ MinMax.ptMaxTrackSize.y = max(MinMax.ptMaxTrackSize.y,
+ MinMax.ptMinTrackSize.y);
- if (MaxSize)
- *MaxSize = MinMax.ptMaxSize;
- if (MaxPos)
- *MaxPos = MinMax.ptMaxPosition;
- if (MinTrack)
- *MinTrack = MinMax.ptMinTrackSize;
- if (MaxTrack)
- *MaxTrack = MinMax.ptMaxTrackSize;
+ if (MaxSize)
+ *MaxSize = MinMax.ptMaxSize;
+ if (MaxPos)
+ *MaxPos = MinMax.ptMaxPosition;
+ if (MinTrack)
+ *MinTrack = MinMax.ptMinTrackSize;
+ if (MaxTrack)
+ *MaxTrack = MinMax.ptMaxTrackSize;
- return 0; // FIXME: What does it return?
+ return 0; // FIXME: What does it return? Wine returns MINMAXINFO.
}
static
diff --git a/win32ss/user/user32/windows/winpos.c b/win32ss/user/user32/windows/winpos.c
index 156b46a28e7..373b711cdd6 100644
--- a/win32ss/user/user32/windows/winpos.c
+++ b/win32ss/user/user32/windows/winpos.c
@@ -22,6 +22,7 @@ void mirror_rect( const RECT *window_rect, RECT *rect )
/* FUNCTIONS *****************************************************************/
+#if 0 // Keep legacy code. Moved to Win32k:NtUser:WinPos.c.
#define EMPTYPOINT(pt) ((pt).x == -1 && (pt).y == -1)
UINT WINAPI
@@ -126,9 +127,9 @@ WinPosGetMinMaxInfo(HWND hwnd, POINT* maxSize, POINT* maxPos,
if (minTrack) *minTrack = MinMax.ptMinTrackSize;
if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
- return 0; //FIXME: what does it return?
+ return 0; //FIXME: what does it return? Wine returns MINMAXINFO.
}
-
+#endif
/*
* @implemented