Add guard against render event when in the background
This commit is contained in:
@@ -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,25 +114,32 @@ namespace lime {
|
|||||||
|
|
||||||
case SDL_USEREVENT:
|
case SDL_USEREVENT:
|
||||||
|
|
||||||
currentUpdate = SDL_GetTicks ();
|
if (!suspendRender) {
|
||||||
applicationEvent.type = UPDATE;
|
|
||||||
applicationEvent.deltaTime = currentUpdate - lastUpdate;
|
|
||||||
lastUpdate = currentUpdate;
|
|
||||||
|
|
||||||
nextUpdate += framePeriod;
|
currentUpdate = SDL_GetTicks ();
|
||||||
|
applicationEvent.type = UPDATE;
|
||||||
while (nextUpdate <= currentUpdate) {
|
applicationEvent.deltaTime = currentUpdate - lastUpdate;
|
||||||
|
lastUpdate = currentUpdate;
|
||||||
|
|
||||||
nextUpdate += framePeriod;
|
nextUpdate += framePeriod;
|
||||||
|
|
||||||
|
while (nextUpdate <= currentUpdate) {
|
||||||
|
|
||||||
|
nextUpdate += framePeriod;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplicationEvent::Dispatch (&applicationEvent);
|
||||||
|
RenderEvent::Dispatch (&renderEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationEvent::Dispatch (&applicationEvent);
|
|
||||||
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:
|
||||||
|
|
||||||
RenderEvent::Dispatch (&renderEvent);
|
if (!suspendRender) {
|
||||||
|
|
||||||
|
RenderEvent::Dispatch (&renderEvent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
|
|
||||||
ProcessWindowEvent (event);
|
ProcessWindowEvent (event);
|
||||||
RenderEvent::Dispatch (&renderEvent);
|
|
||||||
|
if (!suspendRender) {
|
||||||
|
|
||||||
|
RenderEvent::Dispatch (&renderEvent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_CLOSE:
|
case SDL_WINDOWEVENT_CLOSE:
|
||||||
|
|||||||
Reference in New Issue
Block a user