Add guard against render event when in the background

This commit is contained in:
Joshua Granick
2016-11-18 14:49:45 -08:00
parent c9526b2e43
commit d9f5900685

View File

@@ -17,8 +17,10 @@ namespace lime {
AutoGCRoot* Application::callback = 0; AutoGCRoot* Application::callback = 0;
SDLApplication* SDLApplication::currentApplication = 0; SDLApplication* SDLApplication::currentApplication = 0;
const int analogAxisDeadZone = 1000; const int analogAxisDeadZone = 1000;
std::map<int, std::map<int, int> > gamepadsAxisMap; std::map<int, std::map<int, int> > gamepadsAxisMap;
bool suspendRender = false;
SDLApplication::SDLApplication () { SDLApplication::SDLApplication () {
@@ -112,6 +114,8 @@ namespace lime {
case SDL_USEREVENT: case SDL_USEREVENT:
if (!suspendRender) {
currentUpdate = SDL_GetTicks (); currentUpdate = SDL_GetTicks ();
applicationEvent.type = UPDATE; applicationEvent.type = UPDATE;
applicationEvent.deltaTime = currentUpdate - lastUpdate; applicationEvent.deltaTime = currentUpdate - lastUpdate;
@@ -127,10 +131,15 @@ namespace lime {
ApplicationEvent::Dispatch (&applicationEvent); ApplicationEvent::Dispatch (&applicationEvent);
RenderEvent::Dispatch (&renderEvent); RenderEvent::Dispatch (&renderEvent);
}
break; break;
case SDL_APP_WILLENTERBACKGROUND: case SDL_APP_WILLENTERBACKGROUND:
suspendRender = true;
windowEvent.type = WINDOW_DEACTIVATE; windowEvent.type = WINDOW_DEACTIVATE;
WindowEvent::Dispatch (&windowEvent); WindowEvent::Dispatch (&windowEvent);
break; break;
@@ -139,6 +148,8 @@ namespace lime {
windowEvent.type = WINDOW_ACTIVATE; windowEvent.type = WINDOW_ACTIVATE;
WindowEvent::Dispatch (&windowEvent); WindowEvent::Dispatch (&windowEvent);
suspendRender = false;
break; break;
case SDL_CONTROLLERAXISMOTION: case SDL_CONTROLLERAXISMOTION:
@@ -227,13 +238,24 @@ namespace lime {
case SDL_WINDOWEVENT_EXPOSED: case SDL_WINDOWEVENT_EXPOSED:
if (!suspendRender) {
RenderEvent::Dispatch (&renderEvent); RenderEvent::Dispatch (&renderEvent);
}
break; break;
case SDL_WINDOWEVENT_SIZE_CHANGED: case SDL_WINDOWEVENT_SIZE_CHANGED:
ProcessWindowEvent (event); ProcessWindowEvent (event);
if (!suspendRender) {
RenderEvent::Dispatch (&renderEvent); RenderEvent::Dispatch (&renderEvent);
}
break; break;
case SDL_WINDOWEVENT_CLOSE: case SDL_WINDOWEVENT_CLOSE: