diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index afbfe0a3d..8da0377df 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -21,6 +21,8 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queuepushGui(new GuiMsgBox(mWindow, ss.str(), "OK", [&] { delete this; })); + + mIsProcessing = false; } std::vector GuiScraperMulti::getHelpPrompts() diff --git a/es-core/src/GuiComponent.cpp b/es-core/src/GuiComponent.cpp index 2b4fbe3c1..d079930de 100644 --- a/es-core/src/GuiComponent.cpp +++ b/es-core/src/GuiComponent.cpp @@ -6,7 +6,8 @@ #include "ThemeData.h" GuiComponent::GuiComponent(Window* window) : mWindow(window), mParent(NULL), mOpacity(255), - mPosition(Eigen::Vector3f::Zero()), mSize(Eigen::Vector2f::Zero()), mTransform(Eigen::Affine3f::Identity()) + mPosition(Eigen::Vector3f::Zero()), mSize(Eigen::Vector2f::Zero()), mTransform(Eigen::Affine3f::Identity()), + mIsProcessing(false) { for(unsigned char i = 0; i < MAX_ANIMATIONS; i++) mAnimationMap[i] = NULL; @@ -339,3 +340,8 @@ HelpStyle GuiComponent::getHelpStyle() { return HelpStyle(); } + +bool GuiComponent::isProcessing() const +{ + return mIsProcessing; +} diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index 0b8734a2f..566b2a615 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -90,6 +90,9 @@ public: virtual HelpStyle getHelpStyle(); + // Returns true if the component is busy doing background processing (e.g. HTTP downloads) + bool isProcessing() const; + protected: void renderChildren(const Eigen::Affine3f& transform) const; void updateSelf(int deltaTime); // updates animations @@ -104,6 +107,8 @@ protected: Eigen::Vector3f mPosition; Eigen::Vector2f mSize; + bool mIsProcessing; + public: const static unsigned char MAX_ANIMATIONS = 4; diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index d9dea2050..e5622e8ca 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -4,6 +4,7 @@ #include "AudioManager.h" #include "Log.h" #include "Settings.h" +#include #include #include "components/HelpComponent.h" #include "components/ImageComponent.h" @@ -202,11 +203,16 @@ void Window::render() } unsigned int screensaverTime = (unsigned int)Settings::getInstance()->getInt("ScreenSaverTime"); - if(mTimeSinceLastInput >= screensaverTime && screensaverTime != 0 && mAllowSleep) + if(mTimeSinceLastInput >= screensaverTime && screensaverTime != 0) { - // go to sleep - mSleeping = true; - onSleep(); + renderScreenSaver(); + + if (!isProcessing() && mAllowSleep) + { + // go to sleep + mSleeping = true; + onSleep(); + } } } @@ -326,12 +332,21 @@ void Window::setHelpPrompts(const std::vector& prompts, const HelpSt void Window::onSleep() { - Renderer::setMatrix(Eigen::Affine3f::Identity()); - unsigned char opacity = Settings::getInstance()->getString("ScreenSaverBehavior") == "dim" ? 0xA0 : 0xFF; - Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | opacity); } void Window::onWake() { } + +bool Window::isProcessing() +{ + return count_if(mGuiStack.begin(), mGuiStack.end(), [](GuiComponent* c) { return c->isProcessing(); }) > 0; +} + +void Window::renderScreenSaver() +{ + Renderer::setMatrix(Eigen::Affine3f::Identity()); + unsigned char opacity = Settings::getInstance()->getString("ScreenSaverBehavior") == "dim" ? 0xA0 : 0xFF; + Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | opacity); +} diff --git a/es-core/src/Window.h b/es-core/src/Window.h index 6576cb04a..5eee873a2 100644 --- a/es-core/src/Window.h +++ b/es-core/src/Window.h @@ -41,6 +41,10 @@ private: void onSleep(); void onWake(); + // Returns true if at least one component on the stack is processing + bool isProcessing(); + void renderScreenSaver(); + HelpComponent* mHelp; ImageComponent* mBackgroundOverlay;