mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 23:16:20 +02:00
Refactor if..else into a switch.
Also support the hidden and suspended states.
This commit is contained in:
parent
292f37154b
commit
d580f177a3
1 changed files with 21 additions and 8 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue