neutrino: move screensaver members to screensaver's code

Origin commit data
------------------
Commit: 8a08024e9c
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-11-25 (Sat, 25 Nov 2017)

Origin message was:
------------------
- neutrino: move screensaver members to screensaver's code
This commit is contained in:
vanhofen
2017-11-25 09:58:55 +01:00
parent 86e6a34a2e
commit 02dffb9d98
5 changed files with 25 additions and 34 deletions

View File

@@ -64,6 +64,7 @@ CScreenSaver::CScreenSaver()
scr_clock = NULL;
clr.i_color = COL_DARK_GRAY;
pip_channel_id = 0;
idletime = time(NULL);
}
CScreenSaver::~CScreenSaver()
@@ -135,6 +136,7 @@ void CScreenSaver::Stop()
pthread_cancel(thrScreenSaver);
thrScreenSaver = 0;
}
resetIdleTime();
if (scr_clock){
scr_clock->Stop();
@@ -322,7 +324,7 @@ void CScreenSaver::paint()
}
}
bool CScreenSaver::IsRun()
bool CScreenSaver::isActive()
{
if(thrScreenSaver)
return true;

View File

@@ -48,6 +48,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;
@@ -67,11 +69,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

@@ -106,7 +106,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

@@ -2744,22 +2744,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);
@@ -2782,8 +2766,7 @@ void CNeutrinoApp::RealRun()
}
g_RCInput->clearRCMsg();
m_idletime = time(NULL);
m_screensaver = false;
CScreenSaver::getInstance()->resetIdleTime();
while( true ) {
#ifdef ENABLE_LUA
@@ -2795,6 +2778,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 = (
@@ -2810,23 +2796,25 @@ void CNeutrinoApp::RealRun()
);
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;
@@ -231,7 +228,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;