https://git.reactos.org/?p=reactos.git;a=commitdiff;h=545e1190f2caf714ff897…
commit 545e1190f2caf714ff897d909645adc04178e3a6
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Dec 16 09:57:40 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu Dec 16 09:57:40 2021 +0900
[TASKMGR] Avoid hangs as much as possible (#4166)
- Use ShowWindowAsync instead of ShowWindow.
- Use SwitchToThisWindow directly.
CORE-17894
---
base/applications/taskmgr/applpage.c | 32 ++++++--------------------------
1 file changed, 6 insertions(+), 26 deletions(-)
diff --git a/base/applications/taskmgr/applpage.c b/base/applications/taskmgr/applpage.c
index cf4c063f434..f3ad41c891a 100644
--- a/base/applications/taskmgr/applpage.c
+++ b/base/applications/taskmgr/applpage.c
@@ -5,6 +5,7 @@
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp(a)reactos.org>
* 2005 Klemens Friedl <frik85(a)reactos.at>
+ * 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -57,13 +58,6 @@ static HANDLE hApplicationThread = NULL;
static DWORD dwApplicationThread;
#endif
-#if 0
-void SwitchToThisWindow (
-HWND hWnd, /* Handle to the window that should be activated */
-BOOL bRestore /* Restore the window if it is minimized */
-);
-#endif
-
static INT
GetSystemColorDepth(VOID)
{
@@ -785,7 +779,7 @@ void ApplicationPage_OnWindowsMinimize(void)
if (item.state & LVIS_SELECTED) {
pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)item.lParam;
if (pAPLI) {
- ShowWindow(pAPLI->hWnd, SW_MINIMIZE);
+ ShowWindowAsync(pAPLI->hWnd, SW_MINIMIZE);
}
}
}
@@ -806,7 +800,7 @@ void ApplicationPage_OnWindowsMaximize(void)
if (item.state & LVIS_SELECTED) {
pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)item.lParam;
if (pAPLI) {
- ShowWindow(pAPLI->hWnd, SW_MAXIMIZE);
+ ShowWindowAsync(pAPLI->hWnd, SW_MAXIMIZE);
}
}
}
@@ -859,9 +853,7 @@ void ApplicationPage_OnWindowsBringToFront(void)
}
}
if (pAPLI) {
- if (IsIconic(pAPLI->hWnd))
- ShowWindow(pAPLI->hWnd, SW_RESTORE);
- BringWindowToTop(pAPLI->hWnd);
+ SwitchToThisWindow(pAPLI->hWnd, TRUE);
}
}
@@ -884,21 +876,9 @@ void ApplicationPage_OnSwitchTo(void)
}
}
if (pAPLI) {
- typedef void (WINAPI *PROCSWITCHTOTHISWINDOW) (HWND, BOOL);
- PROCSWITCHTOTHISWINDOW SwitchToThisWindow;
-
- HMODULE hUser32 = GetModuleHandleW(L"USER32");
- SwitchToThisWindow = (PROCSWITCHTOTHISWINDOW)GetProcAddress(hUser32,
"SwitchToThisWindow");
- if (SwitchToThisWindow) {
- SwitchToThisWindow(pAPLI->hWnd, TRUE);
- } else {
- if (IsIconic(pAPLI->hWnd))
- ShowWindow(pAPLI->hWnd, SW_RESTORE);
- BringWindowToTop(pAPLI->hWnd);
- SetForegroundWindow(pAPLI->hWnd);
- }
+ SwitchToThisWindow(pAPLI->hWnd, TRUE);
if (TaskManagerSettings.MinimizeOnUse)
- ShowWindow(hMainWnd, SW_MINIMIZE);
+ ShowWindowAsync(hMainWnd, SW_MINIMIZE);
}
}