From bd949d17153730efa4214443de69ba6ff4a04320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 16 Apr 2009 20:00:01 +0000 Subject: [PATCH] Patch by Obaro Ogbo (nastee) with small changes by myself: The check of the input_server filter if the screen saver should be run could be confused if additional option flags were turned on. I've removed the SAVER_DISABLED definition completely. Also, I renamed the confusing "fEnabled" member, which really means "saver already running". Thanks a lot! Fixes ticket #3474. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30207 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../screen_saver/ScreenSaverSettings.h | 1 - .../screen_saver/ScreenSaverFilter.cpp | 22 +++++++++++-------- .../filters/screen_saver/ScreenSaverFilter.h | 6 ++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/headers/private/screen_saver/ScreenSaverSettings.h b/headers/private/screen_saver/ScreenSaverSettings.h index a4e76ef644..916d160f12 100644 --- a/headers/private/screen_saver/ScreenSaverSettings.h +++ b/headers/private/screen_saver/ScreenSaverSettings.h @@ -22,7 +22,6 @@ enum screen_corner { // time flags enum { - SAVER_DISABLED = 0x00, ENABLE_SAVER = 0x01, ENABLE_DPMS_STAND_BY = 0x02, ENABLE_DPMS_SUSPEND = 0x04, diff --git a/src/add-ons/input_server/filters/screen_saver/ScreenSaverFilter.cpp b/src/add-ons/input_server/filters/screen_saver/ScreenSaverFilter.cpp index 1c31e9b9f2..8e13c05f84 100644 --- a/src/add-ons/input_server/filters/screen_saver/ScreenSaverFilter.cpp +++ b/src/add-ons/input_server/filters/screen_saver/ScreenSaverFilter.cpp @@ -67,7 +67,7 @@ ScreenSaverController::MessageReceived(BMessage *message) const char *signature; if (message->FindString("be:signature", &signature) == B_OK && strcasecmp(signature, SCREEN_BLANKER_SIG) == 0) { - fFilter->SetEnabled(message->what == B_SOME_APP_LAUNCHED); + fFilter->SetIsRunning(message->what == B_SOME_APP_LAUNCHED); } break; } @@ -100,7 +100,7 @@ ScreenSaverFilter::ScreenSaverFilter() fCornerRunner(NULL), fWatchingDirectory(false), fWatchingFile(false), - fEnabled(false) + fIsRunning(false) { fController = new (std::nothrow) ScreenSaverController(this); if (fController == NULL) @@ -173,13 +173,16 @@ void ScreenSaverFilter::_Invoke() { if (fCurrentCorner == fNeverBlankCorner && fNeverBlankCorner != NO_CORNER - || fSettings.TimeFlags() == SAVER_DISABLED - || fEnabled + || (fSettings.TimeFlags() & ENABLE_SAVER) == 0 + || fIsRunning || be_roster->IsRunning(SCREEN_BLANKER_SIG)) return; - if (be_roster->Launch(SCREEN_BLANKER_SIG) == B_OK) - fEnabled = true; + if (be_roster->Launch(SCREEN_BLANKER_SIG) == B_OK) { + // Already set the running state to avoid launching + // the blanker twice in any case. + fIsRunning = true; + } } @@ -224,10 +227,11 @@ ScreenSaverFilter::ReloadSettings() void -ScreenSaverFilter::SetEnabled(bool enabled) +ScreenSaverFilter::SetIsRunning(bool isRunning) { + // called from the controller BLooper BAutolock _(this); - fEnabled = enabled; + fIsRunning = isRunning; } @@ -247,7 +251,7 @@ ScreenSaverFilter::CheckTime() // snooze for blankTime. // Otherwise, there was an event in the middle of the last snooze, so snooze // for the remainder. - if (fEnabled || fLastEventTime + fBlankTime <= now) + if (fIsRunning || fLastEventTime + fBlankTime <= now) fSnoozeTime = fBlankTime; else fSnoozeTime = fLastEventTime + fBlankTime - now; diff --git a/src/add-ons/input_server/filters/screen_saver/ScreenSaverFilter.h b/src/add-ons/input_server/filters/screen_saver/ScreenSaverFilter.h index b98b1aaf89..53bb9431e1 100644 --- a/src/add-ons/input_server/filters/screen_saver/ScreenSaverFilter.h +++ b/src/add-ons/input_server/filters/screen_saver/ScreenSaverFilter.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2008, Haiku. + * Copyright 2003-2009, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -47,7 +47,7 @@ public: void CheckCornerInvoke(); void ReloadSettings(); - void SetEnabled(bool enabled); + void SetIsRunning(bool isRunning); private: uint32 _SnoozeTime() {return fSnoozeTime;} @@ -76,7 +76,7 @@ private: bool fWatchingDirectory; bool fWatchingFile; - bool fEnabled; + bool fIsRunning; }; #endif /* SCREEN_SAVER_FILTER_H */