- neutrino: move screensaver members to screensaver's code

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2017-11-25 09:58:55 +01:00
committed by Thilo Graf
parent 962bcae745
commit 74bc2e88d5
5 changed files with 25 additions and 34 deletions

View File

@@ -59,6 +59,7 @@ CScreenSaver::CScreenSaver()
scr_clock = NULL; scr_clock = NULL;
clr.i_color = COL_DARK_GRAY; clr.i_color = COL_DARK_GRAY;
pip_channel_id = 0; pip_channel_id = 0;
idletime = time(NULL);
} }
CScreenSaver::~CScreenSaver() CScreenSaver::~CScreenSaver()
@@ -126,6 +127,7 @@ void CScreenSaver::Stop()
pthread_cancel(thrScreenSaver); pthread_cancel(thrScreenSaver);
thrScreenSaver = 0; thrScreenSaver = 0;
} }
resetIdleTime();
if (scr_clock){ if (scr_clock){
scr_clock->Stop(); scr_clock->Stop();
@@ -312,7 +314,7 @@ void CScreenSaver::paint()
} }
} }
bool CScreenSaver::IsRun() bool CScreenSaver::isActive()
{ {
if(thrScreenSaver) if(thrScreenSaver)
return true; return true;

View File

@@ -47,6 +47,8 @@ class CScreenSaver : public sigc::trackable
bool ReadDir(); bool ReadDir();
void paint(); void paint();
time_t idletime;
union u_color { union u_color {
struct s_color { struct s_color {
uint8_t b, g, r, a; uint8_t b, g, r, a;
@@ -66,11 +68,14 @@ class CScreenSaver : public sigc::trackable
CScreenSaver(); CScreenSaver();
~CScreenSaver(); ~CScreenSaver();
static CScreenSaver* getInstance(); static CScreenSaver* getInstance();
bool IsRun(); bool isActive();
void Start(); void Start();
void Stop(); void Stop();
sigc::signal<void> OnBeforeStart; sigc::signal<void> OnBeforeStart;
sigc::signal<void> OnAfterStop; sigc::signal<void> OnAfterStop;
void resetIdleTime() { idletime = time(NULL); }
time_t getIdleTime() { return idletime; }
}; };
#endif // __CSCREENSAVER_H__ #endif // __CSCREENSAVER_H__

View File

@@ -102,7 +102,7 @@ void CTimeOSD::initTimeString()
void CTimeOSD::show(time_t time_show, bool force) void CTimeOSD::show(time_t time_show, bool force)
{ {
time_show /= 1000; 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; return;
m_time_show = time_show; 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() void CNeutrinoApp::RealRun()
{ {
mainMenu = &personalize.getWidget(MENU_MAIN); mainMenu = &personalize.getWidget(MENU_MAIN);
@@ -2599,8 +2583,7 @@ void CNeutrinoApp::RealRun()
} }
g_RCInput->clearRCMsg(); g_RCInput->clearRCMsg();
m_idletime = time(NULL); CScreenSaver::getInstance()->resetIdleTime();
m_screensaver = false;
while( true ) { while( true ) {
#ifdef ENABLE_LUA #ifdef ENABLE_LUA
@@ -2612,6 +2595,9 @@ void CNeutrinoApp::RealRun()
continue; continue;
#endif #endif
if (msg <= CRCInput::RC_MaxRC)
CScreenSaver::getInstance()->resetIdleTime();
if (mode == NeutrinoModes::mode_radio || mode == NeutrinoModes::mode_webradio) if (mode == NeutrinoModes::mode_radio || mode == NeutrinoModes::mode_webradio)
{ {
bool ignored_msg = ( bool ignored_msg = (
@@ -2625,25 +2611,27 @@ void CNeutrinoApp::RealRun()
|| msg == NeutrinoMessages::EVT_ZAP_GOTAPIDS || msg == NeutrinoMessages::EVT_ZAP_GOTAPIDS
|| msg == NeutrinoMessages::EVT_ZAP_GOTPIDS || 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; time_t delay = time(NULL) - CScreenSaver::getInstance()->getIdleTime();
int screensaver_delay = g_settings.screensaver_delay; if (g_settings.screensaver_delay && delay > g_settings.screensaver_delay*60 && !CScreenSaver::getInstance()->isActive())
if (screensaver_delay !=0 && delay > screensaver_delay*60 && !m_screensaver) {
screensaver(true); CInfoClock::getInstance()->block();
CScreenSaver::getInstance()->Start();
}
} }
else if (!ignored_msg) else if (!ignored_msg)
{ {
m_idletime = time(NULL); if (CScreenSaver::getInstance()->isActive())
if (m_screensaver)
{ {
printf("[neutrino] CScreenSaver stop; msg: %lX\n", msg); printf("[neutrino] CScreenSaver stop; msg: %lX\n", msg);
screensaver(false); CScreenSaver::getInstance()->Stop();
frameBuffer->stopFrame(); frameBuffer->stopFrame();
frameBuffer->showFrame("radiomode.jpg"); frameBuffer->showFrame("radiomode.jpg");
if (msg <= CRCInput::RC_MaxRC) { if (msg <= CRCInput::RC_MaxRC)
{
// ignore first keypress - just quit the screensaver // ignore first keypress - just quit the screensaver
g_RCInput->clearRCMsg(); g_RCInput->clearRCMsg();
continue; continue;

View File

@@ -86,9 +86,6 @@ private:
int network_dhcp; int network_dhcp;
int network_automatic_start; int network_automatic_start;
int m_idletime;
bool m_screensaver;
int mode; int mode;
int lastMode; int lastMode;
bool softupdate; bool softupdate;
@@ -229,7 +226,6 @@ public:
void lockPlayBack(bool blank = true); void lockPlayBack(bool blank = true);
void stopPlayBack(bool lock = false); void stopPlayBack(bool lock = false);
bool adjustToChannelID(const t_channel_id channel_id); bool adjustToChannelID(const t_channel_id channel_id);
void screensaver(bool);
//signal/event handler before restart of neutrino gui //signal/event handler before restart of neutrino gui
sigc::signal<bool> OnBeforeRestart; sigc::signal<bool> OnBeforeRestart;
sigc::signal<void> OnAfterSetupFonts; sigc::signal<void> OnAfterSetupFonts;