neutrino: move screensaver members to screensaver's code

Signed-off-by: Thilo Graf <dbt@novatux.de>


Origin commit data
------------------
Branch: ni/coolstream
Commit: 74bc2e88d5
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-11-25 (Sat, 25 Nov 2017)

Origin message was:
------------------
- neutrino: move screensaver members to screensaver's code

Signed-off-by: Thilo Graf <dbt@novatux.de>


------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2017-11-25 09:58:55 +01:00
committed by Thilo Graf
parent 7567d4e27d
commit 6dba4ae47d
5 changed files with 25 additions and 34 deletions

View File

@@ -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;

View File

@@ -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<void> OnBeforeStart;
sigc::signal<void> OnAfterStop;
void resetIdleTime() { idletime = time(NULL); }
time_t getIdleTime() { return idletime; }
};
#endif // __CSCREENSAVER_H__

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<bool> OnBeforeRestart;
sigc::signal<void> OnAfterSetupFonts;