mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:10:25 +02:00
continue idling while minimized
This commit is contained in:
parent
20051b970a
commit
7f6a1be2c7
2 changed files with 19 additions and 0 deletions
|
@ -2530,6 +2530,11 @@ bool Application::event(QEvent* event) {
|
||||||
|
|
||||||
isPaintingThrottled = false;
|
isPaintingThrottled = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else if ((int)event->type() == (int)Idle) {
|
||||||
|
float nsecsElapsed = (float)_lastTimeUpdated.nsecsElapsed();
|
||||||
|
idle(nsecsElapsed);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6499,10 +6504,22 @@ void Application::activeChanged(Qt::ApplicationState state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::windowMinimizedChanged(bool minimized) {
|
void Application::windowMinimizedChanged(bool minimized) {
|
||||||
|
// initialize the _minimizedWindowTimer
|
||||||
|
static std::once_flag once;
|
||||||
|
std::call_once(once, [&] {
|
||||||
|
connect(&_minimizedWindowTimer, &QTimer::timeout, this, [] {
|
||||||
|
QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(static_cast<QEvent::Type>(Idle)), Qt::HighEventPriority);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// avoid rendering to the display plugin but continue posting Idle events,
|
||||||
|
// so that physics continues to simulate and the deadlock watchdog knows we're alive
|
||||||
if (!minimized && !getActiveDisplayPlugin()->isActive()) {
|
if (!minimized && !getActiveDisplayPlugin()->isActive()) {
|
||||||
|
_minimizedWindowTimer.stop();
|
||||||
getActiveDisplayPlugin()->activate();
|
getActiveDisplayPlugin()->activate();
|
||||||
} else if (minimized && getActiveDisplayPlugin()->isActive()) {
|
} else if (minimized && getActiveDisplayPlugin()->isActive()) {
|
||||||
getActiveDisplayPlugin()->deactivate();
|
getActiveDisplayPlugin()->deactivate();
|
||||||
|
_minimizedWindowTimer.start(THROTTLED_SIM_FRAME_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,7 @@ public:
|
||||||
enum Event {
|
enum Event {
|
||||||
Present = DisplayPlugin::Present,
|
Present = DisplayPlugin::Present,
|
||||||
Paint = Present + 1,
|
Paint = Present + 1,
|
||||||
|
Idle = Paint + 1,
|
||||||
Lambda = Paint + 1
|
Lambda = Paint + 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -536,6 +537,7 @@ private:
|
||||||
RateCounter<> _avatarSimCounter;
|
RateCounter<> _avatarSimCounter;
|
||||||
RateCounter<> _simCounter;
|
RateCounter<> _simCounter;
|
||||||
|
|
||||||
|
QTimer _minimizedWindowTimer;
|
||||||
QElapsedTimer _timerStart;
|
QElapsedTimer _timerStart;
|
||||||
QElapsedTimer _lastTimeUpdated;
|
QElapsedTimer _lastTimeUpdated;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue