From 6dba4ae47d22fa42745fb6e7d842d51690bd64d8 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sat, 25 Nov 2017 09:58:55 +0100 Subject: [PATCH] neutrino: move screensaver members to screensaver's code Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/74bc2e88d5944f2b033d17dc8af8623065afa9fe Author: vanhofen Date: 2017-11-25 (Sat, 25 Nov 2017) Origin message was: ------------------ - neutrino: move screensaver members to screensaver's code Signed-off-by: Thilo Graf ------------------ This commit was generated by Migit --- src/gui/screensaver.cpp | 4 +++- src/gui/screensaver.h | 7 ++++++- src/gui/timeosd.cpp | 2 +- src/neutrino.cpp | 42 +++++++++++++++-------------------------- src/neutrino.h | 4 ---- 5 files changed, 25 insertions(+), 34 deletions(-) diff --git a/src/gui/screensaver.cpp b/src/gui/screensaver.cpp index aecc3c6d9..f25068b7c 100644 --- a/src/gui/screensaver.cpp +++ b/src/gui/screensaver.cpp @@ -59,6 +59,7 @@ CScreenSaver::CScreenSaver() scr_clock = NULL; clr.i_color = COL_DARK_GRAY; pip_channel_id = 0; + idletime = time(NULL); } CScreenSaver::~CScreenSaver() @@ -126,6 +127,7 @@ void CScreenSaver::Stop() pthread_cancel(thrScreenSaver); thrScreenSaver = 0; } + resetIdleTime(); if (scr_clock){ scr_clock->Stop(); @@ -312,7 +314,7 @@ void CScreenSaver::paint() } } -bool CScreenSaver::IsRun() +bool CScreenSaver::isActive() { if(thrScreenSaver) return true; diff --git a/src/gui/screensaver.h b/src/gui/screensaver.h index 9dff31919..cf6467c62 100644 --- a/src/gui/screensaver.h +++ b/src/gui/screensaver.h @@ -47,6 +47,8 @@ class CScreenSaver : public sigc::trackable bool ReadDir(); void paint(); + time_t idletime; + union u_color { struct s_color { uint8_t b, g, r, a; @@ -66,11 +68,14 @@ class CScreenSaver : public sigc::trackable CScreenSaver(); ~CScreenSaver(); static CScreenSaver* getInstance(); - bool IsRun(); + bool isActive(); void Start(); void Stop(); sigc::signal OnBeforeStart; sigc::signal OnAfterStop; + + void resetIdleTime() { idletime = time(NULL); } + time_t getIdleTime() { return idletime; } }; #endif // __CSCREENSAVER_H__ diff --git a/src/gui/timeosd.cpp b/src/gui/timeosd.cpp index 32c025f0f..7e71f6133 100644 --- a/src/gui/timeosd.cpp +++ b/src/gui/timeosd.cpp @@ -102,7 +102,7 @@ void CTimeOSD::initTimeString() void CTimeOSD::show(time_t time_show, bool force) { time_show /= 1000; - if (!force && (m_mode == MODE_HIDE || m_time_show == time_show || CScreenSaver::getInstance()->IsRun())) + if (!force && (m_mode == MODE_HIDE || m_time_show == time_show || CScreenSaver::getInstance()->isActive())) return; m_time_show = time_show; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 66c69e2af..fbe16ec91 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2561,22 +2561,6 @@ void CNeutrinoApp::showMainMenu() } } -void CNeutrinoApp::screensaver(bool on) -{ - if (on) - { - m_screensaver = true; - CInfoClock::getInstance()->block(); - CScreenSaver::getInstance()->Start(); - } - else - { - CScreenSaver::getInstance()->Stop(); - m_screensaver = false; - m_idletime = time(NULL); - } -} - void CNeutrinoApp::RealRun() { mainMenu = &personalize.getWidget(MENU_MAIN); @@ -2599,8 +2583,7 @@ void CNeutrinoApp::RealRun() } g_RCInput->clearRCMsg(); - m_idletime = time(NULL); - m_screensaver = false; + CScreenSaver::getInstance()->resetIdleTime(); while( true ) { #ifdef ENABLE_LUA @@ -2612,6 +2595,9 @@ void CNeutrinoApp::RealRun() continue; #endif + if (msg <= CRCInput::RC_MaxRC) + CScreenSaver::getInstance()->resetIdleTime(); + if (mode == NeutrinoModes::mode_radio || mode == NeutrinoModes::mode_webradio) { bool ignored_msg = ( @@ -2625,25 +2611,27 @@ void CNeutrinoApp::RealRun() || msg == NeutrinoMessages::EVT_ZAP_GOTAPIDS || msg == NeutrinoMessages::EVT_ZAP_GOTPIDS ); - if ( msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER) + if (msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER) { - int delay = time(NULL) - m_idletime; - int screensaver_delay = g_settings.screensaver_delay; - if (screensaver_delay !=0 && delay > screensaver_delay*60 && !m_screensaver) - screensaver(true); + time_t delay = time(NULL) - CScreenSaver::getInstance()->getIdleTime(); + if (g_settings.screensaver_delay && delay > g_settings.screensaver_delay*60 && !CScreenSaver::getInstance()->isActive()) + { + CInfoClock::getInstance()->block(); + CScreenSaver::getInstance()->Start(); + } } else if (!ignored_msg) { - m_idletime = time(NULL); - if (m_screensaver) + if (CScreenSaver::getInstance()->isActive()) { printf("[neutrino] CScreenSaver stop; msg: %lX\n", msg); - screensaver(false); + CScreenSaver::getInstance()->Stop(); frameBuffer->stopFrame(); frameBuffer->showFrame("radiomode.jpg"); - if (msg <= CRCInput::RC_MaxRC) { + if (msg <= CRCInput::RC_MaxRC) + { // ignore first keypress - just quit the screensaver g_RCInput->clearRCMsg(); continue; diff --git a/src/neutrino.h b/src/neutrino.h index ee02dd4b5..360766b72 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -86,9 +86,6 @@ private: int network_dhcp; int network_automatic_start; - int m_idletime; - bool m_screensaver; - int mode; int lastMode; bool softupdate; @@ -229,7 +226,6 @@ public: void lockPlayBack(bool blank = true); void stopPlayBack(bool lock = false); bool adjustToChannelID(const t_channel_id channel_id); - void screensaver(bool); //signal/event handler before restart of neutrino gui sigc::signal OnBeforeRestart; sigc::signal OnAfterSetupFonts;