https://git.reactos.org/?p=reactos.git;a=commitdiff;h=55a1c29341bf452377fa9…
commit 55a1c29341bf452377fa9bab9b2773d813261c39
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Dec 13 08:14:33 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Dec 13 08:14:33 2021 +0900
[NTUSER][USER32] Simplify SwitchToThisWindow (#4153)
CORE-17894
---
win32ss/user/ntuser/simplecall.c | 29 +++++++++++++----------------
win32ss/user/user32/controls/appswitch.c | 31 +++++--------------------------
2 files changed, 18 insertions(+), 42 deletions(-)
diff --git a/win32ss/user/ntuser/simplecall.c b/win32ss/user/ntuser/simplecall.c
index ce190357db1..2a2c92ac0ec 100644
--- a/win32ss/user/ntuser/simplecall.c
+++ b/win32ss/user/ntuser/simplecall.c
@@ -512,28 +512,25 @@ NtUserCallTwoParam(
Ret = 0;
Window = UserGetWindowObject(hwnd);
if (!Window)
- {
break;
- }
- if (MsqIsHung(Window->head.pti, MSQ_HUNG))
- {
- // TODO: Make the window ghosted and activate.
- break;
- }
- if (fAltTab)
+
+ if (gpqForeground && !fAltTab)
{
- if (Window->style & WS_MINIMIZE)
+ PWND pwndActive = gpqForeground->spwndActive;
+ if (pwndActive && !(pwndActive->ExStyle & WS_EX_TOPMOST))
{
- UserPostMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
+ co_WinPosSetWindowPos(pwndActive, HWND_BOTTOM, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE |
+ SWP_NOSENDCHANGING | SWP_ASYNCWINDOWPOS);
}
- /* bring window to top and activate */
- co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0,
- SWP_NOSIZE | SWP_NOMOVE | SWP_NOSENDCHANGING |
- SWP_NOOWNERZORDER | SWP_ASYNCWINDOWPOS);
}
- else
+
+ UserSetActiveWindow(Window);
+
+ if (fAltTab && (Window->style & WS_MINIMIZE))
{
- UserSetActiveWindow(Window);
+ MSG msg = { Window->head.h, WM_SYSCOMMAND, SC_RESTORE, 0 };
+ MsqPostMessage(Window->head.pti, &msg, FALSE, QS_POSTMESSAGE, 0,
0);
}
break;
}
diff --git a/win32ss/user/user32/controls/appswitch.c
b/win32ss/user/user32/controls/appswitch.c
index 61dff7ab6f5..fa522be1c01 100644
--- a/win32ss/user/user32/controls/appswitch.c
+++ b/win32ss/user/user32/controls/appswitch.c
@@ -71,18 +71,6 @@ int CoolSwitchColumns = 7;
const DWORD Style = WS_POPUP | WS_BORDER | WS_DISABLED;
const DWORD ExStyle = WS_EX_TOPMOST | WS_EX_DLGMODALFRAME | WS_EX_TOOLWINDOW;
-DWORD wtodw(const WCHAR *psz)
-{
- const WCHAR *pch = psz;
- DWORD Value = 0;
- while ('0' <= *pch && *pch <= '9')
- {
- Value *= 10;
- Value += *pch - L'0';
- }
- return Value;
-}
-
BOOL LoadCoolSwitchSettings(void)
{
CoolSwitch = TRUE;
@@ -122,15 +110,6 @@ void ResizeAndCenter(HWND hwnd, int width, int height)
ptStart.y = y;
}
-void MakeWindowActive(HWND hwnd)
-{
- if (IsIconic(hwnd))
- PostMessageW(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
-
- // See also:
https://microsoft.public.win32.programmer.ui.narkive.com/RqOdKqZ8/bringwind…
- SwitchToThisWindow(hwnd, TRUE);
-}
-
void CompleteSwitch(BOOL doSwitch)
{
if (!isOpen)
@@ -155,7 +134,7 @@ void CompleteSwitch(BOOL doSwitch)
TRACE("[ATbot] CompleteSwitch Switching to 0x%08x (%ls)\n", hwnd,
windowText);
- MakeWindowActive(hwnd);
+ SwitchToThisWindow(hwnd, TRUE);
}
}
@@ -485,7 +464,7 @@ BOOL ProcessHotKey(VOID)
if (windowCount == 1)
{
- MakeWindowActive(windowList[0]);
+ SwitchToThisWindow(windowList[0], TRUE);
return FALSE;
}
@@ -496,7 +475,7 @@ BOOL ProcessHotKey(VOID)
TRACE("[ATbot] HotKey Received. Opening window.\n");
ShowWindowAsync(switchdialog, SW_SHOWNORMAL);
- MakeWindowActive(switchdialog);
+ SwitchToThisWindow(switchdialog, TRUE);
isOpen = TRUE;
}
else
@@ -525,7 +504,7 @@ void RotateTasks(BOOL bShift)
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE |
SWP_NOOWNERZORDER | SWP_NOREPOSITION | SWP_ASYNCWINDOWPOS);
- MakeWindowActive(hwndLast);
+ SwitchToThisWindow(hwndLast, TRUE);
Size = (windowCount - 1) * sizeof(HWND);
MoveMemory(&windowList[1], &windowList[0], Size);
@@ -537,7 +516,7 @@ void RotateTasks(BOOL bShift)
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE |
SWP_NOOWNERZORDER | SWP_NOREPOSITION | SWP_ASYNCWINDOWPOS);
- MakeWindowActive(windowList[1]);
+ SwitchToThisWindow(windowList[1], TRUE);
Size = (windowCount - 1) * sizeof(HWND);
MoveMemory(&windowList[0], &windowList[1], Size);