From b061d03a6dbc6c31b42f1be248a38af4d6cb412b Mon Sep 17 00:00:00 2001 From: vanhofen Date: Fri, 25 May 2018 00:59:24 +0200 Subject: [PATCH] screensaver: allow to switch clock <-> picture while runtime Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/67184441e9cfe8412da639e5d99748611a9ad4eb Author: vanhofen Date: 2018-05-25 (Fri, 25 May 2018) Origin message was: ------------------ - screensaver: allow to switch clock <-> picture while runtime --- src/gui/screensaver.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gui/screensaver.cpp b/src/gui/screensaver.cpp index b3938153c..fa5406c60 100644 --- a/src/gui/screensaver.cpp +++ b/src/gui/screensaver.cpp @@ -169,13 +169,13 @@ void* CScreenSaver::ScreenSaverPrg(void* arg) CScreenSaver * PScreenSaver = static_cast(arg); - PScreenSaver->ReadDir(); //TODO kill Screensaver if false PScreenSaver->m_frameBuffer->Clear(); if (g_settings.screensaver_timeout) { while(PScreenSaver) { + PScreenSaver->ReadDir(); PScreenSaver->paint(); sleep(g_settings.screensaver_timeout); } @@ -256,8 +256,10 @@ bool CScreenSaver::ReadDir() if(!v_bg_files.empty()) ret = true; +#if 0 else dprintf(DEBUG_NORMAL, "[CScreenSaver] %s - %d : no picture found\n", __func__, __LINE__); +#endif return ret; } @@ -265,6 +267,14 @@ bool CScreenSaver::ReadDir() void CScreenSaver::paint() { + if (scr_clock) + { + scr_clock->Stop(); + scr_clock->kill(); + } + if (g_settings.screensaver_mode == SCR_MODE_IMAGE && v_bg_files.empty()) + m_frameBuffer->paintBackground(); + if (g_settings.screensaver_mode == SCR_MODE_IMAGE && !v_bg_files.empty()){ if( (index >= v_bg_files.size()) || (access(v_bg_files.at(index).c_str(), F_OK)) ) @@ -294,10 +304,7 @@ void CScreenSaver::paint() scr_clock->disableSaveBg(); scr_clock->doPaintBg(false); } - if (scr_clock->isPainted()) - scr_clock->Stop(); - scr_clock->kill(); scr_clock->setTextColor(clr.i_color); //check position and size use only possible available screen size