Break up the screen saver update interval into 50 msec ticks. This lets us quickly evaluate if it's time to exit the screen saver, which would previously have blocked until the tick interval was up. This fixes ticket #2339.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28777 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2008-12-04 23:52:28 +00:00
parent 8acabe5a2b
commit 4f07e62e33
+13 -2
View File
@@ -173,6 +173,7 @@ ScreenSaverRunner::_CleanUp()
void
ScreenSaverRunner::_Run()
{
const uint32 kTickBase = 50000;
if (fWindow->Lock()) {
fView->SetViewColor(0, 0, 0);
fView->SetLowColor(0, 0, 0);
@@ -183,10 +184,20 @@ ScreenSaverRunner::_Run()
int32 snoozeCount = 0;
int32 frame = 0;
int32 tickCounter = 0;
bigtime_t tick = fSaver ? fSaver->TickSize() : kTickBase;
while (!fQuitting) {
bigtime_t tick = fSaver ? fSaver->TickSize() : 50000;
snooze(tick);
// break the idle time up into ticks so that we can evaluate
// the quit condition with greater responsiveness
// otherwise a screen saver that sets, say, a 30 second tick
// will result in the screen saver not responding to deactivation
// for that length of time
snooze(kTickBase);
if (++tickCounter * kTickBase < tick)
continue;
else
tickCounter = 0;
if (snoozeCount) {
// if we are sleeping, do nothing