Zebediah Figura : user32: Correctly place minimized windows.
Alexandre Julliard
julliard at winehq.org
Tue Feb 19 15:29:35 CST 2019
Module: wine
Branch: master
Commit: 04707a342fa3535cf1b36742ac0fbb8c7c9532fb
URL: https://source.winehq.org/git/wine.git/?a=commit;h=04707a342fa3535cf1b36742ac0fbb8c7c9532fb
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Tue Feb 19 12:17:41 2019 -0600
user32: Correctly place minimized windows.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/tests/win.c | 6 -----
dlls/user32/winpos.c | 68 ++++++++++++++-----------------------------------
2 files changed, 19 insertions(+), 55 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 5f101b3..3444aba 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -6915,14 +6915,12 @@ static void test_ShowWindow_child(HWND hwndMain)
SetRect(&expect, 0, expect.bottom - GetSystemMetrics(SM_CYMINIMIZED),
GetSystemMetrics(SM_CXMINIMIZED), expect.bottom);
OffsetRect(&expect, pt.x, pt.y);
- todo_wine
ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect));
/* shouldn't be able to resize minimized windows */
ret = SetWindowPos(hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
ok(ret, "wrong ret %d\n", ret);
GetWindowRect(hwnd, &rect);
- todo_wine
ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect));
/* test NC area */
@@ -6943,7 +6941,6 @@ static void test_ShowWindow_child(HWND hwndMain)
ok(style & WS_MINIMIZE, "window should be minimized\n");
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
GetWindowRect(hwnd2, &rect);
- todo_wine
ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect));
@@ -7046,14 +7043,12 @@ static void test_ShowWindow_mdichild(HWND hwndMain)
SetRect(&expect, 0, expect.bottom - GetSystemMetrics(SM_CYMINIMIZED),
GetSystemMetrics(SM_CXMINIMIZED), expect.bottom);
OffsetRect(&expect, pt.x, pt.y);
- todo_wine
ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect));
/* shouldn't be able to resize minimized windows */
ret = SetWindowPos(hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
ok(ret, "wrong ret %d\n", ret);
GetWindowRect(hwnd, &rect);
- todo_wine
ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect));
/* test NC area */
@@ -7074,7 +7069,6 @@ static void test_ShowWindow_mdichild(HWND hwndMain)
ok(style & WS_MINIMIZE, "window should be minimized\n");
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
GetWindowRect(hwnd2, &rect);
- todo_wine
ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect));
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index 6d137d7..4a28a6f 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -922,21 +922,13 @@ static void get_next_minimized_child_pos( const RECT *parent, const MINIMIZEDMET
}
}
-/***********************************************************************
- * WINPOS_FindIconPos
- *
- * Find a suitable place for an iconic window.
- */
-static POINT WINPOS_FindIconPos( HWND hwnd, POINT pt )
+static POINT get_minimized_pos( HWND hwnd, POINT pt )
{
RECT rect, rectParent;
HWND parent, child;
HRGN hrgn, tmp;
- int x, y, xspacing, yspacing;
MINIMIZEDMETRICS metrics;
-
- metrics.cbSize = sizeof(metrics);
- SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(metrics), &metrics, 0 );
+ int width, height;
parent = GetAncestor( hwnd, GA_PARENT );
if (parent == GetDesktopWindow())
@@ -950,12 +942,15 @@ static POINT WINPOS_FindIconPos( HWND hwnd, POINT pt )
}
else GetClientRect( parent, &rectParent );
- if ((pt.x >= rectParent.left) && (pt.x + GetSystemMetrics(SM_CXICON) < rectParent.right) &&
- (pt.y >= rectParent.top) && (pt.y + GetSystemMetrics(SM_CYICON) < rectParent.bottom))
+ if ((pt.x >= rectParent.left) && (pt.x + GetSystemMetrics( SM_CXMINIMIZED ) < rectParent.right) &&
+ (pt.y >= rectParent.top) && (pt.y + GetSystemMetrics( SM_CYMINIMIZED ) < rectParent.bottom))
return pt; /* The icon already has a suitable position */
- xspacing = GetSystemMetrics(SM_CXICONSPACING);
- yspacing = GetSystemMetrics(SM_CYICONSPACING);
+ width = GetSystemMetrics( SM_CXMINIMIZED );
+ height = GetSystemMetrics( SM_CYMINIMIZED );
+
+ metrics.cbSize = sizeof(metrics);
+ SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(metrics), &metrics, 0 );
/* Check if another icon already occupies this spot */
/* FIXME: this is completely inefficient */
@@ -975,42 +970,17 @@ static POINT WINPOS_FindIconPos( HWND hwnd, POINT pt )
}
DeleteObject( tmp );
- for (y = 0; y < (rectParent.bottom - rectParent.top) / yspacing; y++)
+ pt = get_first_minimized_child_pos( &rectParent, &metrics, width, height );
+ for (;;)
{
- if (metrics.iArrange & ARW_STARTTOP)
- {
- rect.top = rectParent.top + y * yspacing;
- rect.bottom = rect.top + yspacing;
- }
- else
- {
- rect.bottom = rectParent.bottom - y * yspacing;
- rect.top = rect.bottom - yspacing;
- }
- for (x = 0; x < (rectParent.right - rectParent.left) / xspacing; x++)
- {
- if (metrics.iArrange & ARW_STARTRIGHT)
- {
- rect.right = rectParent.right - x * xspacing;
- rect.left = rect.right - xspacing;
- }
- else
- {
- rect.left = rectParent.left + x * xspacing;
- rect.right = rect.left + xspacing;
- }
- if (!RectInRegion( hrgn, &rect ))
- {
- /* No window was found, so it's OK for us */
- pt.x = rect.left + (xspacing - GetSystemMetrics(SM_CXICON)) / 2;
- pt.y = rect.top + (yspacing - GetSystemMetrics(SM_CYICON)) / 2;
- DeleteObject( hrgn );
- return pt;
- }
- }
+ SetRect( &rect, pt.x, pt.y, pt.x + width, pt.y + height );
+ if (!RectInRegion( hrgn, &rect ))
+ break;
+
+ get_next_minimized_child_pos( &rectParent, &metrics, width, height, &pt );
}
+
DeleteObject( hrgn );
- pt.x = pt.y = 0;
return pt;
}
@@ -1041,7 +1011,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
case SW_SHOWMINIMIZED:
case SW_FORCEMINIMIZE:
case SW_MINIMIZE:
- wpl.ptMinPosition = WINPOS_FindIconPos( hwnd, wpl.ptMinPosition );
+ wpl.ptMinPosition = get_minimized_pos( hwnd, wpl.ptMinPosition );
SetRect( rect, wpl.ptMinPosition.x, wpl.ptMinPosition.y,
wpl.ptMinPosition.x + GetSystemMetrics(SM_CXMINIMIZED),
@@ -1071,7 +1041,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
old_style = WIN_SetStyle( hwnd, WS_MINIMIZE, WS_MAXIMIZE );
- wpl.ptMinPosition = WINPOS_FindIconPos( hwnd, wpl.ptMinPosition );
+ wpl.ptMinPosition = get_minimized_pos( hwnd, wpl.ptMinPosition );
if (!(old_style & WS_MINIMIZE)) swpFlags |= SWP_STATECHANGED;
SetRect( rect, wpl.ptMinPosition.x, wpl.ptMinPosition.y,
More information about the wine-cvs
mailing list