https://git.reactos.org/?p=reactos.git;a=commitdiff;h=22ab8c812ae85c6341ea2…
commit 22ab8c812ae85c6341ea25730b2759ab52103a1b
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri Jul 14 18:03:15 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Jul 14 18:03:15 2023 +0900
[EXPLORER] Improve the minimize-condition on Win+D (#5423)
- Add CanBeMinimized helper function to determine whether the window should be
minimized.
- Use them in FindEffectiveProc and MinimizeWindowsProc functions.
- Improve the Minimize code.
CORE-18427
---
base/shell/explorer/traywnd.cpp | 43 ++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/base/shell/explorer/traywnd.cpp b/base/shell/explorer/traywnd.cpp
index 542c71c1dd5..576630a3359 100644
--- a/base/shell/explorer/traywnd.cpp
+++ b/base/shell/explorer/traywnd.cpp
@@ -99,6 +99,20 @@ VOID RestoreWindowPos()
g_WindowPosBackup.RemoveAll();
}
+BOOL CanBeMinimized(HWND hwnd)
+{
+ if (::IsWindowVisible(hwnd) && !::IsIconic(hwnd) &&
::IsWindowEnabled(hwnd))
+ {
+ if (::GetClassLongPtrW(hwnd, GCW_ATOM) == (ULONG_PTR)WC_DIALOG)
+ return TRUE;
+
+ DWORD exstyle = (DWORD)::GetWindowLongPtrW(hwnd, GWL_EXSTYLE);
+ if (!(exstyle & WS_EX_TOPMOST))
+ return TRUE;
+ }
+ return FALSE;
+}
+
struct EFFECTIVE_INFO
{
HWND hwndFound;
@@ -113,7 +127,7 @@ FindEffectiveProc(HWND hwnd, LPARAM lParam)
{
EFFECTIVE_INFO *pei = (EFFECTIVE_INFO *)lParam;
- if (!IsWindowVisible(hwnd) || IsIconic(hwnd))
+ if (!CanBeMinimized(hwnd))
return TRUE; // continue
if (pei->hTrayWnd == hwnd || pei->hwndDesktop == hwnd ||
@@ -159,13 +173,6 @@ IsThereAnyEffectiveWindow(BOOL bMustBeInMonitor)
ei.bMustBeInMonitor = bMustBeInMonitor;
EnumWindows(FindEffectiveProc, (LPARAM)&ei);
- if (ei.hwndFound && FALSE)
- {
- WCHAR szClass[64], szText[64];
- GetClassNameW(ei.hwndFound, szClass, _countof(szClass));
- GetWindowTextW(ei.hwndFound, szText, _countof(szText));
- MessageBoxW(NULL, szText, szClass, 0);
- }
return ei.hwndFound != NULL;
}
@@ -2689,7 +2696,7 @@ ChangePos:
LRESULT OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
- COPYDATASTRUCT *pCopyData = reinterpret_cast<COPYDATASTRUCT *>(lParam);
+ COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT *)lParam;
switch (pCopyData->dwData)
{
case TABDMC_APPBAR:
@@ -3262,16 +3269,14 @@ HandleTrayContextMenu:
return TRUE;
}
- if (::IsWindowVisible(hwnd) && !::IsIconic(hwnd))
+ if (CanBeMinimized(hwnd))
{
- MINWNDPOS mwp;
- mwp.hwnd = hwnd;
- mwp.wndpl.length = sizeof(mwp.wndpl);
- ::GetWindowPlacement(hwnd, &mwp.wndpl); // Save the position and status
-
- info->pMinimizedAll->Add(mwp);
-
- ::ShowWindowAsync(hwnd, SW_MINIMIZE);
+ MINWNDPOS mwp = { hwnd, { sizeof(mwp.wndpl) } };
+ if (::GetWindowPlacement(hwnd, &mwp.wndpl) && // Save the
position and status
+ ::ShowWindowAsync(hwnd, SW_SHOWMINNOACTIVE)) // Minimize
+ {
+ info->pMinimizedAll->Add(mwp);
+ }
}
return TRUE;
@@ -3309,9 +3314,7 @@ HandleTrayContextMenu:
{
HWND hwnd = g_MinimizedAll[i].hwnd;
if (::IsWindowVisible(hwnd) && ::IsIconic(hwnd))
- {
::SetWindowPlacement(hwnd, &g_MinimizedAll[i].wndpl);
- }
}
g_MinimizedAll.RemoveAll();