[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
This commit is contained in:
Katayama Hirofumi MZ 2019-05-31 17:02:47 +09:00 committed by GitHub
parent 8d38373fd2
commit 1010f3796e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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))
return TRUE;
// check special windows
if (!GetClassNameW(hwnd, szClass, _countof(szClass)) ||
wcscmp(szClass, L"Shell_TrayWnd") == 0 ||
wcscmp(szClass, L"Progman") == 0)
{
if (!IsWindowVisible(hwnd))
continue;
// check special windows
if (!GetClassNameW(hwnd, szClass, _countof(szClass)) ||
wcscmp(szClass, L"Shell_TrayWnd") == 0 ||
wcscmp(szClass, L"Progman") == 0)
{
continue;
}
ExStyle = GetWindowLongPtrW(hwnd, GWL_EXSTYLE);
if (ExStyle & WS_EX_TOOLWINDOW)
continue;
hwndOwner = GetWindow(hwnd, GW_OWNER);
if ((ExStyle & WS_EX_APPWINDOW) || !IsWindowVisible(hwndOwner))
{
if (!callback(hwnd, lParam))
break;
continue;
}
return TRUE;
}
ExStyle = GetWindowLongPtrW(hwnd, GWL_EXSTYLE);
if (ExStyle & WS_EX_TOOLWINDOW)
return TRUE;
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;