1
0
Fork 0

Add some more cases to the Alt-tab detection. It can still mess up, but this should help with a lot of cases. Thanks for testing eightbitbubsy.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3929
This commit is contained in:
Peter Veenstra 2015-08-17 14:07:01 +00:00
parent 64ad48ee52
commit a03d9faf91

View file

@ -212,6 +212,8 @@ struct SDL_Block {
Bitu num_joysticks;
#if defined (WIN32)
bool using_windib;
// Time when sdl regains focus (alt-tab) in windowed mode
Bit32u focus_ticks;
#endif
// state of alt-keys for certain special handlings
Bit8u laltstate;
@ -1505,6 +1507,9 @@ void GFX_Events() {
case SDL_ACTIVEEVENT:
if (event.active.state & SDL_APPINPUTFOCUS) {
if (event.active.gain) {
#ifdef WIN32
if (!sdl.desktop.fullscreen) sdl.focus_ticks = GetTicks();
#endif
if (sdl.desktop.fullscreen && !sdl.mouse.locked)
GFX_CaptureMouse();
SetPriority(sdl.priority.focus);
@ -1596,6 +1601,10 @@ void GFX_Events() {
if (event.key.keysym.sym==SDLK_RALT) sdl.raltstate = event.key.type;
if (((event.key.keysym.sym==SDLK_TAB)) &&
((sdl.laltstate==SDL_KEYDOWN) || (sdl.raltstate==SDL_KEYDOWN))) break;
// This can happen as well.
if (((event.key.keysym.sym == SDLK_TAB )) && (event.key.keysym.mod & KMOD_ALT)) break;
// ignore tab events that arrive just after regaining focus. (likely the result of alt-tab)
if ((event.key.keysym.sym == SDLK_TAB) && (GetTicks() - sdl.focus_ticks < 2)) break;
#endif
#if defined (MACOSX)
case SDL_KEYDOWN: