Refactor if..else into a switch.

Also support the hidden and suspended states.
This commit is contained in:
Geenz 2014-03-12 21:17:54 -04:00
parent 292f37154b
commit d580f177a3

View file

@ -54,14 +54,27 @@ void GLCanvas::mouseReleaseEvent(QMouseEvent* event) {
} }
void GLCanvas::activeChanged() { void GLCanvas::activeChanged() {
if (Application::applicationState() != Qt::ApplicationActive) { switch (Application::applicationState()) {
if (!_throttleRendering) { case Qt::ApplicationActive:
_frameTimer.start(_idleRenderInterval); // If we're active, stop the frame timer and the throttle.
_throttleRendering = true; _frameTimer.stop();
} _throttleRendering = false;
} else { break;
_frameTimer.stop();
_throttleRendering = false; case Qt::ApplicationSuspended:
case Qt::ApplicationHidden:
// If we're hidden or are about to suspend, don't render anything.
_throttleRendering = false;
_frameTimer.stop();
break;
default:
// Otherwise, throttle.
if (!_throttleRendering) {
_frameTimer.start(_idleRenderInterval);
_throttleRendering = true;
}
break;
} }
} }