https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c17a8770a31ab3c9fbbc2a96bae6d55c057bd8b9

commit c17a8770a31ab3c9fbbc2a96bae6d55c057bd8b9
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Sun Jul 7 09:05:10 2019 +0900
Commit:     GitHub <[email protected]>
CommitDate: Sun Jul 7 09:05:10 2019 +0900

    [USER32] Switch to only one window (Alt+Tab) (#1718)
    
    Fix app switcher (Alt+Tab)'s behavior when there is only one app window. 
CORE-16176
---
 win32ss/user/user32/controls/appswitch.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/win32ss/user/user32/controls/appswitch.c 
b/win32ss/user/user32/controls/appswitch.c
index 737663a17db..03531acfe85 100644
--- a/win32ss/user/user32/controls/appswitch.c
+++ b/win32ss/user/user32/controls/appswitch.c
@@ -481,11 +481,13 @@ BOOL ProcessHotKey(VOID)
 
       if (windowCount == 1)
       {
-         selectedWindow = 0;
-         CompleteSwitch(TRUE);
-         return TRUE;
+         MakeWindowActive(windowList[0]);
+         return FALSE;
       }
 
+      if (!CreateSwitcherWindow(User32Instance))
+         return FALSE;
+
       selectedWindow = 1;
 
       TRACE("[ATbot] HotKey Received. Opening window.\n");
@@ -610,10 +612,6 @@ LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam )
    // Already in the loop.
    if (switchdialog || Esc) return 0;
 
-   hwndActive = GetActiveWindow();
-   // Nothing is active so exit.
-   if (!hwndActive) return 0;
-
    if (lParam == VK_ESCAPE)
    {
       Esc = TRUE;
@@ -636,14 +634,15 @@ LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam )
    }
 
    // Capture current active window.
-   SetCapture( hwndActive );
+   hwndActive = GetActiveWindow();
+   if (hwndActive)
+       SetCapture(hwndActive);
 
    switch (lParam)
    {
       case VK_TAB:
-         if( !CreateSwitcherWindow(User32Instance) ) goto Exit;
-         if( !GetDialogFont() ) goto Exit;
-         if( !ProcessHotKey() ) goto Exit;
+         if (!GetDialogFont() || !ProcessHotKey())
+             goto Exit;
          break;
 
       case VK_ESCAPE:
@@ -652,6 +651,10 @@ LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam )
       default:
          goto Exit;
    }
+
+   if (!hwndActive)
+       goto Exit;
+
    // Main message loop:
    while (1)
    {

Reply via email to