https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1010f3796ec4c76a8b884…
commit 1010f3796ec4c76a8b88476319c52cba52907cef
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri May 31 17:02:47 2019 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri May 31 17:02:47 2019 +0900
[USER32] Fix behavior of Task Switcher (Alt+Tab) (#1591)
Task Switcher didn't correctly behave on the windows with WS_EX_APPWINDOW extended
style. CORE-15653
---
win32ss/user/user32/controls/appswitch.c | 55 +++++++++++++++-----------------
1 file changed, 25 insertions(+), 30 deletions(-)
diff --git a/win32ss/user/user32/controls/appswitch.c
b/win32ss/user/user32/controls/appswitch.c
index ecd48b47e7..ee9c10677c 100644
--- a/win32ss/user/user32/controls/appswitch.c
+++ b/win32ss/user/user32/controls/appswitch.c
@@ -209,41 +209,36 @@ BOOL CALLBACK EnumerateCallback(HWND window, LPARAM lParam)
return TRUE;
}
-// Function mostly compatible with the normal EnumChildWindows,
-// except it lists in Z-Order and it doesn't ensure consistency
-// if a window is removed while enumerating
-void EnumWindowsZOrder(WNDENUMPROC callback, LPARAM lParam)
+static BOOL CALLBACK
+EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
- HWND hwnd, hwndOwner;
+ HWND hwndOwner;
WCHAR szClass[64];
DWORD ExStyle;
- for (hwnd = GetTopWindow(NULL); hwnd; hwnd = GetWindow(hwnd, GW_HWNDNEXT))
- {
- if (!IsWindowVisible(hwnd))
- continue;
+ if (!IsWindowVisible(hwnd))
+ return TRUE;
- // check special windows
- if (!GetClassNameW(hwnd, szClass, _countof(szClass)) ||
- wcscmp(szClass, L"Shell_TrayWnd") == 0 ||
- wcscmp(szClass, L"Progman") == 0)
- {
- continue;
- }
+ // check special windows
+ if (!GetClassNameW(hwnd, szClass, _countof(szClass)) ||
+ wcscmp(szClass, L"Shell_TrayWnd") == 0 ||
+ wcscmp(szClass, L"Progman") == 0)
+ {
+ return TRUE;
+ }
- ExStyle = GetWindowLongPtrW(hwnd, GWL_EXSTYLE);
- if (ExStyle & WS_EX_TOOLWINDOW)
- continue;
+ ExStyle = GetWindowLongPtrW(hwnd, GWL_EXSTYLE);
+ if (ExStyle & WS_EX_TOOLWINDOW)
+ return TRUE;
- hwndOwner = GetWindow(hwnd, GW_OWNER);
- if ((ExStyle & WS_EX_APPWINDOW) || !IsWindowVisible(hwndOwner))
- {
- if (!callback(hwnd, lParam))
- break;
-
- continue;
- }
+ hwndOwner = GetWindow(hwnd, GW_OWNER);
+ if (!IsWindowVisible(hwndOwner) || (ExStyle & WS_EX_APPWINDOW))
+ {
+ if (!EnumerateCallback(hwnd, lParam))
+ return FALSE;
}
+
+ return TRUE;
}
void ProcessMouseMessage(UINT message, LPARAM lParam)
@@ -428,8 +423,8 @@ BOOL ProcessHotKey(VOID)
{
if (!isOpen)
{
- windowCount=0;
- EnumWindowsZOrder(EnumerateCallback, 0);
+ windowCount = 0;
+ EnumWindows(EnumWindowsProc, 0);
if (windowCount == 0)
return FALSE;
@@ -574,7 +569,7 @@ LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam )
Esc = TRUE;
windowCount = 0;
- EnumWindowsZOrder(EnumerateCallback, 0);
+ EnumWindows(EnumWindowsProc, 0);
if (windowCount < 2)
return 0;