[TASKMGR] Avoid hangs as much as possible (#4166)

- Use ShowWindowAsync instead of ShowWindow.
- Use SwitchToThisWindow directly.
CORE-17894
This commit is contained in:
Katayama Hirofumi MZ 2021-12-16 09:57:40 +09:00 committed by GitHub
parent 0b6f3eb8e4
commit 545e1190f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
* 2005 Klemens Friedl <frik85@reactos.at>
* 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@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);
}
}