From 08acfc091152302332b94e1a86454bb7ae383b31 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sun, 18 Dec 2016 01:22:24 +0100 Subject: [PATCH] screensaver: fix clock positions Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/7e077bb7eefa72cc6b309263abafa1d494ce9e09 Author: vanhofen Date: 2016-12-18 (Sun, 18 Dec 2016) Origin message was: ------------------ - screensaver: fix clock positions --- src/gui/screensaver.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/gui/screensaver.cpp b/src/gui/screensaver.cpp index 5082fec27..1ded487eb 100644 --- a/src/gui/screensaver.cpp +++ b/src/gui/screensaver.cpp @@ -283,14 +283,10 @@ void CScreenSaver::paint() //check position and size use only possible available screen size int x_cl, y_cl, w_cl, h_cl; - scr_clock->getDimensions( &x_cl, &y_cl, &w_cl, &h_cl); - bool unchecked = true; - while(unchecked){ - scr_clock->setPosP(uint8_t(rand() % 100),uint8_t(rand() % 100)); - scr_clock->getDimensions( &x_cl, &y_cl, &w_cl, &h_cl); - if (x_cl+w_cl < g_settings.screen_EndX && y_cl+h_cl < g_settings.screen_EndY) - unchecked = false; - } + scr_clock->getDimensions(&x_cl, &y_cl, &w_cl, &h_cl); + int x_random = rand() % ((g_settings.screen_EndX - w_cl - g_settings.screen_StartX) + 1) + g_settings.screen_StartX; + int y_random = rand() % ((g_settings.screen_EndY - h_cl - g_settings.screen_StartY) + 1) + g_settings.screen_StartY; + scr_clock->setPos(x_random, y_random); scr_clock->Start(); if (g_settings.screensaver_mode == SCR_MODE_CLOCK_COLOR) {