Ticket #4628: ScreenSaverRunnerFix_4628.diff

File ScreenSaverRunnerFix_4628.diff, 1.7 KB (added by rogueeve, 12 years ago)
  • src/kits/screensaver/ScreenSaverRunner.cpp

     
    172172void
    173173ScreenSaverRunner::_Run()
    174174{
    175     const uint32 kTickBase = 50000;
     175static const uint32 kInitialTickRate = 50000;
     176
    176177    if (fWindow->Lock()) {
    177178        fView->SetViewColor(0, 0, 0);
    178179        fView->SetLowColor(0, 0, 0);
     
    181182        fWindow->Unlock();
    182183    }
    183184   
     185    uint32 TickBase = kInitialTickRate;
    184186    int32 snoozeCount = 0;
    185187    int32 frame = 0;
    186188    bigtime_t lastTickTime = 0;
    187     bigtime_t tick = fSaver ? fSaver->TickSize() : kTickBase;
     189    bigtime_t tick = fSaver ? fSaver->TickSize() : TickBase;
    188190
    189191    while (!fQuitting) {
    190192        // break the idle time up into ticks so that we can evaluate
     
    192194        // otherwise a screen saver that sets, say, a 30 second tick
    193195        // will result in the screen saver not responding to deactivation
    194196        // for that length of time
    195         snooze(kTickBase);
    196         if (system_time() - lastTickTime < tick)
     197        snooze(TickBase);
     198        if (system_time() - lastTickTime < tick) {
    197199            continue;
    198         else {
     200        } else {
    199201            // re-evaluate the tick time after each successful wakeup -
    200             // screensavers can adjust it on the fly and we must be
     202            // screensavers can adjust it on the fly, and we must be
    201203            // prepared to accomodate that
    202             tick = fSaver ? fSaver->TickSize() : kTickBase;
     204            tick = fSaver ? fSaver->TickSize() : TickBase;
     205           
     206            if (tick < TickBase) {
     207                if (tick < 0) tick = 0;
     208                TickBase = tick;
     209            }
     210            else if (TickBase < kInitialTickRate && tick >= kInitialTickRate) {
     211                TickBase = kInitialTickRate;
     212            }
     213           
    203214            lastTickTime = system_time();
    204215        }
    205216