1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-29 03:33:48 +00:00

fix SDL 1.2 window focus handling

This commit is contained in:
fgenesis 2019-03-24 21:15:27 +01:00
parent 0f0d839fc7
commit 6704fd1ac6
2 changed files with 25 additions and 27 deletions

View file

@ -1063,7 +1063,6 @@ void Core::run(float runTime)
{
if (isWindowFocus())
{
_hasFocus = true;
if (wasInactive)
{
debugLog("WINDOW ACTIVE");
@ -1073,37 +1072,33 @@ void Core::run(float runTime)
}
else
{
if (_hasFocus)
if (!wasInactive)
debugLog("WINDOW INACTIVE");
wasInactive = true;
updateInputGrab();
sound->pause();
while (!isWindowFocus())
{
if (!wasInactive)
debugLog("WINDOW INACTIVE");
pollEvents(dt);
wasInactive = true;
_hasFocus = false;
updateInputGrab();
sound->pause();
while (!isWindowFocus())
{
pollEvents(dt);
onBackgroundUpdate();
resetTimer();
}
debugLog("app back in focus");
onBackgroundUpdate();
resetTimer();
sound->resume();
resetTimer();
SDL_ShowCursor(SDL_DISABLE);
continue;
}
debugLog("app back in focus");
resetTimer();
sound->resume();
resetTimer();
SDL_ShowCursor(SDL_DISABLE);
continue;
}
}
#endif

View file

@ -123,6 +123,9 @@ void Window::_onEventImpl(const SDL_Event& ev)
case SDL_VIDEORESIZE:
onResize(ev.resize.w, ev.resize.h);
break;
case SDL_ACTIVEEVENT:
_hasFocus = ev.active.state;
}
}