Gabriel Ivăncescu : user32: Add a helper to retrieve the work rect.
Alexandre Julliard
julliard at winehq.org
Wed Sep 1 15:45:09 CDT 2021
Module: wine
Branch: master
Commit: d8252025d1c6bf9e16406cb430f0531477da76bc
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d8252025d1c6bf9e16406cb430f0531477da76bc
Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date: Wed Sep 1 08:30:50 2021 +0100
user32: Add a helper to retrieve the work rect.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/winpos.c | 45 +++++++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 16 deletions(-)
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index 6e96a4b5964..bc8c35afc58 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -675,6 +675,33 @@ BOOL WINAPI MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
}
+/*******************************************************************
+ * get_work_rect
+ *
+ * Get the work area that a maximized window can cover, depending on style.
+ */
+static BOOL get_work_rect( HWND hwnd, RECT *rect )
+{
+ HMONITOR monitor = MonitorFromWindow( hwnd, MONITOR_DEFAULTTOPRIMARY );
+ MONITORINFO mon_info;
+ DWORD style;
+
+ if (!monitor) return FALSE;
+
+ mon_info.cbSize = sizeof(mon_info);
+ GetMonitorInfoW( monitor, &mon_info );
+ *rect = mon_info.rcMonitor;
+
+ style = GetWindowLongW( hwnd, GWL_STYLE );
+ if (style & WS_MAXIMIZEBOX)
+ {
+ if ((style & WS_CAPTION) == WS_CAPTION || !(style & (WS_CHILD | WS_POPUP)))
+ *rect = mon_info.rcWork;
+ }
+ return TRUE;
+}
+
+
/*******************************************************************
* WINPOS_GetMinMaxInfo
*
@@ -683,8 +710,8 @@ BOOL WINAPI MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
MINMAXINFO WINPOS_GetMinMaxInfo( HWND hwnd )
{
DPI_AWARENESS_CONTEXT context;
+ RECT rc_work, rc_primary;
MINMAXINFO MinMax;
- HMONITOR monitor;
INT xinc, yinc;
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
LONG adjustedStyle;
@@ -738,22 +765,8 @@ MINMAXINFO WINPOS_GetMinMaxInfo( HWND hwnd )
/* if the app didn't change the values, adapt them for the current monitor */
- if ((monitor = MonitorFromWindow( hwnd, MONITOR_DEFAULTTOPRIMARY )))
+ if (get_work_rect( hwnd, &rc_work ))
{
- RECT rc_work, rc_primary;
- MONITORINFO mon_info;
-
- mon_info.cbSize = sizeof(mon_info);
- GetMonitorInfoW( monitor, &mon_info );
-
- rc_work = mon_info.rcMonitor;
-
- if (style & WS_MAXIMIZEBOX)
- {
- if ((style & WS_CAPTION) == WS_CAPTION || !(style & (WS_CHILD | WS_POPUP)))
- rc_work = mon_info.rcWork;
- }
-
rc_primary = get_primary_monitor_rect();
if (MinMax.ptMaxSize.x == (rc_primary.right - rc_primary.left) + 2 * xinc &&
MinMax.ptMaxSize.y == (rc_primary.bottom - rc_primary.top) + 2 * yinc)
More information about the wine-cvs
mailing list