From 10351f8d91cbc0f1167d40f521c450d460cb357c Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sat, 25 Nov 2017 09:58:55 +0100 Subject: [PATCH] screensaver: move more repeatedly used code to screensaver's code Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/81b82668ac370cf8fbb9e6672477e51d6963cf08 Author: vanhofen Date: 2017-11-25 (Sat, 25 Nov 2017) Origin message was: ------------------ - screensaver: move more repeatedly used code to screensaver's code Signed-off-by: Thilo Graf ------------------ This commit was generated by Migit --- src/gui/movieplayer.cpp | 3 +-- src/gui/screensaver.cpp | 7 +++++++ src/gui/screensaver.h | 3 ++- src/neutrino.cpp | 3 +-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index fdd166556..604ff3f24 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -1671,8 +1671,7 @@ void CMoviePlayerGui::PlayFileLoop(void) if (playstate == CMoviePlayerGui::PAUSE && (msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER)) { - time_t delay = time(NULL) - CScreenSaver::getInstance()->getIdleTime(); - if (g_settings.screensaver_delay && delay > g_settings.screensaver_delay*60 && !CScreenSaver::getInstance()->isActive()) + if (CScreenSaver::getInstance()->canStart() && !CScreenSaver::getInstance()->isActive()) { videoDecoder->setBlank(true); CScreenSaver::getInstance()->Start(); diff --git a/src/gui/screensaver.cpp b/src/gui/screensaver.cpp index f25068b7c..df808fccd 100644 --- a/src/gui/screensaver.cpp +++ b/src/gui/screensaver.cpp @@ -314,6 +314,13 @@ void CScreenSaver::paint() } } +bool CScreenSaver::canStart() +{ + if (g_settings.screensaver_delay && (time(NULL) - idletime > g_settings.screensaver_delay*60)) + return true; + return false; +} + bool CScreenSaver::isActive() { if(thrScreenSaver) diff --git a/src/gui/screensaver.h b/src/gui/screensaver.h index cf6467c62..f8d51b9b1 100644 --- a/src/gui/screensaver.h +++ b/src/gui/screensaver.h @@ -53,7 +53,7 @@ class CScreenSaver : public sigc::trackable struct s_color { uint8_t b, g, r, a; } uc_color; - unsigned int i_color; + unsigned int i_color; }; u_color clr; @@ -68,6 +68,7 @@ class CScreenSaver : public sigc::trackable CScreenSaver(); ~CScreenSaver(); static CScreenSaver* getInstance(); + bool canStart(); bool isActive(); void Start(); void Stop(); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index fbe16ec91..9d67ad189 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2613,8 +2613,7 @@ void CNeutrinoApp::RealRun() ); if (msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER) { - time_t delay = time(NULL) - CScreenSaver::getInstance()->getIdleTime(); - if (g_settings.screensaver_delay && delay > g_settings.screensaver_delay*60 && !CScreenSaver::getInstance()->isActive()) + if (CScreenSaver::getInstance()->canStart() && !CScreenSaver::getInstance()->isActive()) { CInfoClock::getInstance()->block(); CScreenSaver::getInstance()->Start();