From 72de78bb83176566ac8ad7646d373030e2d05f90 Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Wed, 17 Nov 2021 01:25:57 -0600 Subject: [PATCH] =?UTF-8?q?Reduce=20material=20editor=20update=20interval?= =?UTF-8?q?=20when=20inactive=20Reduce=20the=20application=20update=20inte?= =?UTF-8?q?rval=20when=20it=E2=80=99s=20not=20in=20focus=20to=20reduce=20p?= =?UTF-8?q?ower=20consumption=20and=20interference=20with=20other=20applic?= =?UTF-8?q?ations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guthrie Adams --- .../Code/Source/Application/AtomToolsApplication.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Application/AtomToolsApplication.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Application/AtomToolsApplication.cpp index ba3bfe4718..5c5eb834c6 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Application/AtomToolsApplication.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Application/AtomToolsApplication.cpp @@ -79,12 +79,18 @@ namespace AtomToolsFramework m_styleManager.reset(new AzQtComponents::StyleManager(this)); m_styleManager->initialize(this, engineRootPath); - connect(&m_timer, &QTimer::timeout, this, [&]() + m_timer.setInterval(1); + connect(&m_timer, &QTimer::timeout, this, [this]() { this->PumpSystemEventLoopUntilEmpty(); this->Tick(); }); + connect(this, &QGuiApplication::applicationStateChanged, this, [this]() + { + // Limit the update interval when not in focus to reduce power consumption and interference with other applications + this->m_timer.setInterval((applicationState() & Qt::ApplicationActive) ? 1 : 32); + }); } AtomToolsApplication ::~AtomToolsApplication()