- Fix recursive loops during Alt+Esc and Tab. Dedicated to Hermès Bélusca-Maïto.

svn path=/trunk/; revision=63531
This commit is contained in:
James Tabor 2014-06-01 22:32:24 +00:00
parent ac7d530c44
commit 958cc23088

View file

@ -17,7 +17,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32);
#define MAX_WINDOWS 120 #define MAX_WINDOWS 120
// Global variables // Global variables
HWND switchdialog; HWND switchdialog = NULL;
HFONT dialogFont; HFONT dialogFont;
int selectedWindow = 0; int selectedWindow = 0;
BOOL isOpen = FALSE; BOOL isOpen = FALSE;
@ -334,19 +334,26 @@ void ProcessHotKey()
LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam ) LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam )
{ {
HWND hwnd; HWND hwnd, hwndActive;
MSG msg; MSG msg;
BOOL Esc = FALSE; BOOL Esc = FALSE;
INT Count = 0; INT Count = 0;
WCHAR Text[1024]; 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) switch (lParam)
{ {
case VK_TAB: case VK_TAB:
if( !CreateSwitcherWindow(User32Instance) ) return 0; if( !CreateSwitcherWindow(User32Instance) ) goto Exit;
if( !GetDialogFont() ) return 0; if( !GetDialogFont() ) goto Exit;
ProcessHotKey(); ProcessHotKey();
break; break;
@ -354,7 +361,7 @@ LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam )
windowCount = 0; windowCount = 0;
Count = 0; Count = 0;
EnumWindowsZOrder(EnumerateCallback, 0); EnumWindowsZOrder(EnumerateCallback, 0);
if (windowCount < 2) return 0; if (windowCount < 2) goto Exit;
if (wParam == SC_NEXTWINDOW) if (wParam == SC_NEXTWINDOW)
Count = 1; Count = 1;
else else
@ -373,7 +380,7 @@ LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam )
break; break;
default: default:
return 0; goto Exit;
} }
// Main message loop: // Main message loop:
while (1) while (1)
@ -471,6 +478,7 @@ LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam )
} }
} }
Exit: Exit:
ReleaseCapture();
if (switchdialog) DestroyWindow(switchdialog); if (switchdialog) DestroyWindow(switchdialog);
switchdialog = NULL; switchdialog = NULL;
selectedWindow = 0; selectedWindow = 0;