From 8e3fef2627d0bfd6c7912fab77a794941518983c Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 18 Mar 2022 14:29:17 +0100 Subject: [PATCH] win32u: Move ArrangeIconicWindows implementation from user32. Signed-off-by: Jacek Caban Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/user32/winpos.c | 123 +------------------------------------------ dlls/win32u/window.c | 44 ++++++++++++++++ include/ntuser.h | 1 + 3 files changed, 46 insertions(+), 122 deletions(-) diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index 6f0dfec23ac..fa074e9f7c8 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -31,19 +31,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(win); -#define SWP_AGG_NOGEOMETRYCHANGE \ - (SWP_NOSIZE | SWP_NOCLIENTSIZE | SWP_NOZORDER) -#define SWP_AGG_NOPOSCHANGE \ - (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER) -#define SWP_AGG_STATUSFLAGS \ - (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW) -#define SWP_AGG_NOCLIENTCHANGE \ - (SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE) - -#define HAS_DLGFRAME(style,exStyle) \ - (((exStyle) & WS_EX_DLGMODALFRAME) || \ - (((style) & WS_DLGFRAME) && !((style) & WS_BORDER))) - #define HAS_THICKFRAME(style) \ (((style) & WS_THICKFRAME) && \ !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME)) @@ -551,78 +538,6 @@ MINMAXINFO WINPOS_GetMinMaxInfo( HWND hwnd ) return info; } - -static POINT get_first_minimized_child_pos( const RECT *parent, const MINIMIZEDMETRICS *mm, - int width, int height ) -{ - POINT ret; - - if (mm->iArrange & ARW_STARTRIGHT) - ret.x = parent->right - mm->iHorzGap - width; - else - ret.x = parent->left + mm->iHorzGap; - if (mm->iArrange & ARW_STARTTOP) - ret.y = parent->top + mm->iVertGap; - else - ret.y = parent->bottom - mm->iVertGap - height; - - return ret; -} - -static void get_next_minimized_child_pos( const RECT *parent, const MINIMIZEDMETRICS *mm, - int width, int height, POINT *pos ) -{ - BOOL next; - - if (mm->iArrange & ARW_UP) /* == ARW_DOWN */ - { - if (mm->iArrange & ARW_STARTTOP) - { - pos->y += height + mm->iVertGap; - if ((next = pos->y + height > parent->bottom)) - pos->y = parent->top + mm->iVertGap; - } - else - { - pos->y -= height + mm->iVertGap; - if ((next = pos->y < parent->top)) - pos->y = parent->bottom - mm->iVertGap - height; - } - - if (next) - { - if (mm->iArrange & ARW_STARTRIGHT) - pos->x -= width + mm->iHorzGap; - else - pos->x += width + mm->iHorzGap; - } - } - else - { - if (mm->iArrange & ARW_STARTRIGHT) - { - pos->x -= width + mm->iHorzGap; - if ((next = pos->x < parent->left)) - pos->x = parent->right - mm->iHorzGap - width; - } - else - { - pos->x += width + mm->iHorzGap; - if ((next = pos->x + width > parent->right)) - pos->x = parent->left + mm->iHorzGap; - } - - if (next) - { - if (mm->iArrange & ARW_STARTTOP) - pos->y += height + mm->iVertGap; - else - pos->y -= height + mm->iVertGap; - } - } -} - - /*********************************************************************** * GetInternalWindowPos (USER32.@) */ @@ -992,43 +907,7 @@ BOOL WINAPI EndDeferWindowPos( HDWP hdwp ) */ UINT WINAPI ArrangeIconicWindows( HWND parent ) { - int width, height, count = 0; - RECT rectParent; - HWND hwndChild; - POINT pt; - MINIMIZEDMETRICS metrics; - - metrics.cbSize = sizeof(metrics); - SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(metrics), &metrics, 0 ); - width = GetSystemMetrics( SM_CXMINIMIZED ); - height = GetSystemMetrics( SM_CYMINIMIZED ); - - if (parent == GetDesktopWindow()) - { - MONITORINFO mon_info; - HMONITOR monitor = MonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY ); - - mon_info.cbSize = sizeof( mon_info ); - GetMonitorInfoW( monitor, &mon_info ); - rectParent = mon_info.rcWork; - } - else GetClientRect( parent, &rectParent ); - - pt = get_first_minimized_child_pos( &rectParent, &metrics, width, height ); - - hwndChild = GetWindow( parent, GW_CHILD ); - while (hwndChild) - { - if( IsIconic( hwndChild ) ) - { - NtUserSetWindowPos( hwndChild, 0, pt.x, pt.y, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); - get_next_minimized_child_pos( &rectParent, &metrics, width, height, &pt ); - count++; - } - hwndChild = GetWindow( hwndChild, GW_HWNDNEXT ); - } - return count; + return NtUserCallHwnd( parent, NtUserArrangeIconicWindows ); } diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 521523dc2b5..8c7a5950a78 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -3830,6 +3830,48 @@ static UINT window_min_maximize( HWND hwnd, UINT cmd, RECT *rect ) return swp_flags; } +/* see ArrangeIconicWindows */ +static UINT arrange_iconic_windows( HWND parent ) +{ + int width, height, count = 0; + MINIMIZEDMETRICS metrics; + RECT parent_rect; + HWND child; + POINT pt; + + metrics.cbSize = sizeof(metrics); + NtUserSystemParametersInfo( SPI_GETMINIMIZEDMETRICS, sizeof(metrics), &metrics, 0 ); + width = get_system_metrics( SM_CXMINIMIZED ); + height = get_system_metrics( SM_CYMINIMIZED ); + + if (parent == get_desktop_window()) + { + MONITORINFO mon_info; + HMONITOR monitor = monitor_from_window( 0, MONITOR_DEFAULTTOPRIMARY, get_thread_dpi() ); + + mon_info.cbSize = sizeof( mon_info ); + get_monitor_info( monitor, &mon_info ); + parent_rect = mon_info.rcWork; + } + else get_client_rect( parent, &parent_rect ); + + pt = get_first_minimized_child_pos( &parent_rect, &metrics, width, height ); + + child = get_window_relative( parent, GW_CHILD ); + while (child) + { + if (is_iconic( child )) + { + NtUserSetWindowPos( child, 0, pt.x, pt.y, 0, 0, + SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); + get_next_minimized_child_pos( &parent_rect, &metrics, width, height, &pt ); + count++; + } + child = get_window_relative( child, GW_HWNDNEXT ); + } + return count; +} + /******************************************************************* * update_window_state * @@ -4905,6 +4947,8 @@ ULONG_PTR WINAPI NtUserCallHwnd( HWND hwnd, DWORD code ) { switch (code) { + case NtUserArrangeIconicWindows: + return arrange_iconic_windows( hwnd ); case NtUserGetDpiForWindow: return get_dpi_for_window( hwnd ); case NtUserGetParent: diff --git a/include/ntuser.h b/include/ntuser.h index 03b48747665..b327dbc87f0 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -142,6 +142,7 @@ enum /* NtUserCallHwnd codes, not compatible with Windows */ enum { + NtUserArrangeIconicWindows, NtUserGetDpiForWindow, NtUserGetParent, NtUserGetWindowContextHelpId,