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:
parent
0f0d839fc7
commit
6704fd1ac6
2 changed files with 25 additions and 27 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue