Author: jimtabor
Date: Sun Jun 1 22:32:24 2014
New Revision: 63531
URL:
http://svn.reactos.org/svn/reactos?rev=63531&view=rev
Log:
[User32]
- Fix recursive loops during Alt+Esc and Tab. Dedicated to Hermès Bélusca-Maïto.
Modified:
trunk/reactos/win32ss/user/user32/controls/appswitch.c
Modified: trunk/reactos/win32ss/user/user32/controls/appswitch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/contro…
==============================================================================
--- trunk/reactos/win32ss/user/user32/controls/appswitch.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/controls/appswitch.c [iso-8859-1] Sun Jun 1
22:32:24 2014
@@ -17,7 +17,7 @@
#define MAX_WINDOWS 120
// Global variables
-HWND switchdialog;
+HWND switchdialog = NULL;
HFONT dialogFont;
int selectedWindow = 0;
BOOL isOpen = FALSE;
@@ -334,19 +334,26 @@
LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam )
{
- HWND hwnd;
+ HWND hwnd, hwndActive;
MSG msg;
BOOL Esc = FALSE;
INT Count = 0;
WCHAR Text[1024];
- switchdialog = NULL;
+ // Already in the loop.
+ if (switchdialog) return 0;
+
+ hwndActive = GetActiveWindow();
+ // Nothing is active so exit.
+ if (!hwndActive) return 0;
+ // Capture current active window.
+ SetCapture( hwndActive );
switch (lParam)
{
case VK_TAB:
- if( !CreateSwitcherWindow(User32Instance) ) return 0;
- if( !GetDialogFont() ) return 0;
+ if( !CreateSwitcherWindow(User32Instance) ) goto Exit;
+ if( !GetDialogFont() ) goto Exit;
ProcessHotKey();
break;
@@ -354,7 +361,7 @@
windowCount = 0;
Count = 0;
EnumWindowsZOrder(EnumerateCallback, 0);
- if (windowCount < 2) return 0;
+ if (windowCount < 2) goto Exit;
if (wParam == SC_NEXTWINDOW)
Count = 1;
else
@@ -373,7 +380,7 @@
break;
default:
- return 0;
+ goto Exit;
}
// Main message loop:
while (1)
@@ -471,6 +478,7 @@
}
}
Exit:
+ ReleaseCapture();
if (switchdialog) DestroyWindow(switchdialog);
switchdialog = NULL;
selectedWindow = 0;