* Big time cleanup of the screen saver stuff, not yet finished yet, though.

Renamed lots of things, like ScreenSaverThread to ScreenSaverRunner,
  refactored code, etc. Much cleaner interfaces and code.
* Fixed a couple of bugs and in the add-on handling, especially some settings
  related bugs (ie. testing a screen saver will now use its latest settings,
  etc.).
* Correctly implemented DPMS support in ScreenSaverPrefs and the ScreenSaver
  preferences application - screen_blanker still ignores them, though.
* It's not yet font sensitive either.
* Changed the input_server add-on to not switch to the screen blanker immediately
  when it's in the "blank corner" - doesn't seem to work yet, though (only tested
  under Qemu).
* Correctly implemented the "preview" function (before, a screen saver would
  never know it rendered a preview).
* Evaluates the return value of BScreenSaver::StartSaver().
* The screen saver thread is no longer killed without notice - it's now
  always shut down properly.
* Made the code more robust against failure.
* Introduced some new bugs as well (the screen saver list view doesn't jump to
  the selection anymore, for some reason), those will be fixed later (as the
  remaining issues).
* Probably some more I forgot about.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17731 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-06-06 08:16:46 +00:00
parent ef1974cb9d
commit 7cae4a1ee0
23 changed files with 1478 additions and 1211 deletions
+50 -57
View File
@@ -1,82 +1,75 @@
#if ! defined _SCREENSAVER_H
/*
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SCREENSAVER_H
#define _SCREENSAVER_H
#include <BeBuild.h>
#include <DirectWindow.h> // for direct_buffer_info
#include <DirectWindow.h>
#include <image.h>
#include <Message.h>
class BView;
class BScreenSaver
{
public:
BScreenSaver(BMessage *archive, image_id);
virtual ~BScreenSaver();
// Return an error if something goes wrong or if you don't
// like the running environment (lack of 3D acceleration,
// lack of sound, ...).
virtual status_t InitCheck();
class BScreenSaver {
public:
BScreenSaver(BMessage* archive, image_id thisImage);
virtual ~BScreenSaver();
// Animation start and stop. The view is not yet visible when
// StartSaver is called.
virtual status_t StartSaver(BView *view, bool preview);
virtual void StopSaver();
virtual status_t InitCheck();
// This hook is called periodically, you should
// override it to do the drawing. Notice that you
// should clear the screen when frame == 0 if you
// don't want to paint over the desktop.
virtual void Draw(BView *view, int32 frame);
virtual status_t StartSaver(BView* view, bool preview);
virtual void StopSaver();
// These hooks are for direct screen access, the first is
// called every time the settings change, the second is
// the equivalent of Draw to be called to access the screen
// directly. Draw and DirectDraw can be used at the same time.
virtual void DirectConnected(direct_buffer_info *info);
virtual void DirectDraw(int32 frame);
virtual void Draw(BView* view, int32 frame);
// configuration dialog methods
virtual void StartConfig(BView *configView);
virtual void StopConfig();
// direct screen access
virtual void DirectConnected(direct_buffer_info* info);
virtual void DirectDraw(int32 frame);
// Module should fill this in with metadata
// example: randomizable = true
virtual void SupplyInfo(BMessage *info) const;
// configuration dialog methods
virtual void StartConfig(BView* configView);
virtual void StopConfig();
// Send all the metadata info to the module
virtual void ModulesChanged(const BMessage *info);
// Module should fill this in with metadata
// example: randomizable = true
virtual void SupplyInfo(BMessage* info) const;
// BArchivable like parameter saver method
virtual status_t SaveState(BMessage *into) const;
// Send all the metadata info to the module
virtual void ModulesChanged(const BMessage* info);
// These methods can be used to control drawing frequency.
void SetTickSize(bigtime_t ts);
bigtime_t TickSize() const;
// BArchivable like parameter saver method
virtual status_t SaveState(BMessage* into) const;
// These methods can be used to control animation loop cycles
void SetLoop(int32 on_count, int32 off_count);
int32 LoopOnCount() const;
int32 LoopOffCount() const;
// These methods can be used to control drawing frequency.
void SetTickSize(bigtime_t tickSize);
bigtime_t TickSize() const;
private:
virtual void _ReservedScreenSaver1();
virtual void _ReservedScreenSaver2();
virtual void _ReservedScreenSaver3();
virtual void _ReservedScreenSaver4();
virtual void _ReservedScreenSaver5();
virtual void _ReservedScreenSaver6();
virtual void _ReservedScreenSaver7();
virtual void _ReservedScreenSaver8();
// These methods can be used to control animation loop cycles
void SetLoop(int32 onCount, int32 offCount);
int32 LoopOnCount() const;
int32 LoopOffCount() const;
bigtime_t ticksize;
int32 looponcount;
int32 loopoffcount;
private:
virtual void _ReservedScreenSaver1();
virtual void _ReservedScreenSaver2();
virtual void _ReservedScreenSaver3();
virtual void _ReservedScreenSaver4();
virtual void _ReservedScreenSaver5();
virtual void _ReservedScreenSaver6();
virtual void _ReservedScreenSaver7();
virtual void _ReservedScreenSaver8();
uint32 _reservedScreenSaver[6];
bigtime_t fTickSize;
int32 fLoopOnCount;
int32 fLoopOffCount;
uint32 _reserved[6];
};
extern "C" _EXPORT BScreenSaver *instantiate_screen_saver(BMessage *msg, image_id id);
#endif
#endif // _SCREENSAVER_H
+80 -65
View File
@@ -1,15 +1,17 @@
/*
* Copyright 2003, Michael Phipps. All rights reserved.
* Copyright 2003-2006, Michael Phipps. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef SCREEN_SAVER_PREFS_H
#define SCREEN_SAVER_PREFS_H
#include <Message.h>
#include <Path.h>
#include <String.h>
enum arrowDirection {
enum screen_corner {
NONE = -1,
UPLEFT,
UPRIGHT,
@@ -18,69 +20,82 @@ enum arrowDirection {
CENTER
};
#define SCREEN_BLANKER_SIG "application/x-vnd.Haiku.screenblanker"
// time flags
enum {
SAVER_DISABLED = 0x00,
ENABLE_SAVER = 0x01,
ENABLE_DPMS_STAND_BY = 0x02,
ENABLE_DPMS_SUSPEND = 0x04,
ENABLE_DPMS_OFF = 0x08,
class ScreenSaverPrefs
{
public:
ScreenSaverPrefs();
bool LoadSettings();
void Defaults();
BPath & GetPath() { return fSSPath;}
BRect WindowFrame() {return fWindowFrame;}
int32 WindowTab() {return fWindowTab;}
int32 TimeFlags() {return fTimeFlags;}
bigtime_t BlankTime() {return fBlankTime;}
bigtime_t StandbyTime() {return fStandByTime;}
bigtime_t SuspendTime() {return fSuspendTime;}
bigtime_t OffTime() {return fOffTime;}
arrowDirection GetBlankCorner() {return fBlankCorner;}
arrowDirection GetNeverBlankCorner() {return fNeverBlankCorner;}
bool LockEnable() {return fLockEnabled;}
bigtime_t PasswordTime() {return fPasswordTime;}
const char *Password() { return fPassword.String(); }
const char *LockMethod() { return fLockMethod.String(); }
bool IsNetworkPassword() {return (strcmp(fLockMethod.String(), "custom") != 0);}
const char *ModuleName() {return fModuleName.String();}
status_t GetState(const char *name, BMessage *stateMsg);
void SetWindowFrame(const BRect &fr) { fWindowFrame = fr;}
void SetWindowTab(int32 tab) { fWindowTab = tab;}
void SetTimeFlags(int32 tf) {fTimeFlags = tf;}
void SetBlankTime(bigtime_t bt) {fBlankTime = bt;}
void SetStandbyTime(bigtime_t time) {fStandByTime = time;}
void SetSuspendTime(bigtime_t time) {fSuspendTime = time;}
void SetOffTime(bigtime_t intime) {fOffTime = intime;}
void SetBlankCorner(arrowDirection in) {fBlankCorner = in;}
void SetNeverBlankCorner(arrowDirection in) {fNeverBlankCorner = in;}
void SetLockEnable(bool en) {fLockEnabled = en;}
void SetPasswordTime(bigtime_t pt) {fPasswordTime = pt;}
void SetPassword(const char *pw) {fPassword = pw;} // Can not set network password from here.
void SetLockMethod(const char *method) {fLockMethod = method;}
void SetModuleName(const char *mn) {fModuleName = mn;}
void SetState(const char *name, BMessage *stateMsg);
void SaveSettings();
BMessage & GetSettings();
private:
BRect fWindowFrame;
int32 fWindowTab;
int32 fTimeFlags;
bigtime_t fBlankTime;
bigtime_t fStandByTime;
bigtime_t fSuspendTime;
bigtime_t fOffTime;
arrowDirection fBlankCorner;
arrowDirection fNeverBlankCorner;
bool fLockEnabled;
bigtime_t fPasswordTime;
BString fPassword;
BString fModuleName;
BString fLockMethod;
BMessage fSettings;
BPath fSSPath, fNetworkPath;
ENABLE_DPMS_MASK = ENABLE_DPMS_STAND_BY | ENABLE_DPMS_SUSPEND | ENABLE_DPMS_OFF
};
#define SCREEN_BLANKER_SIG "application/x-vnd.Haiku.screenblanker"
#endif //SCREEN_SAVER_PREFS_H
class ScreenSaverPrefs {
public:
ScreenSaverPrefs();
bool LoadSettings();
void Defaults();
BPath& Path() { return fSettingsPath; }
BRect WindowFrame() { return fWindowFrame; }
int32 WindowTab() { return fWindowTab; }
int32 TimeFlags() { return fTimeFlags; }
bigtime_t BlankTime() { return fBlankTime; }
bigtime_t StandbyTime() { return fStandByTime; }
bigtime_t SuspendTime() { return fSuspendTime; }
bigtime_t OffTime() { return fOffTime; }
screen_corner GetBlankCorner() { return fBlankCorner; }
screen_corner GetNeverBlankCorner() { return fNeverBlankCorner; }
bool LockEnable() { return fLockEnabled; }
bigtime_t PasswordTime() { return fPasswordTime; }
const char *Password() { return fPassword.String(); }
const char *LockMethod() { return fLockMethod.String(); }
bool IsNetworkPassword() { return strcmp(fLockMethod.String(), "custom") != 0; }
const char *ModuleName() { return fModuleName.String(); }
status_t GetState(const char *name, BMessage *stateMsg);
void SetWindowFrame(const BRect &fr) { fWindowFrame = fr; }
void SetWindowTab(int32 tab) { fWindowTab = tab; }
void SetTimeFlags(int32 tf) { fTimeFlags = tf; }
void SetBlankTime(bigtime_t bt) { fBlankTime = bt; }
void SetStandbyTime(bigtime_t time) { fStandByTime = time; }
void SetSuspendTime(bigtime_t time) { fSuspendTime = time; }
void SetOffTime(bigtime_t intime) { fOffTime = intime; }
void SetBlankCorner(screen_corner in) { fBlankCorner = in; }
void SetNeverBlankCorner(screen_corner in) { fNeverBlankCorner = in; }
void SetLockEnable(bool en) { fLockEnabled = en; }
void SetPasswordTime(bigtime_t pt) { fPasswordTime = pt; }
void SetPassword(const char *pw) { fPassword = pw; }
// Cannot set network password from here.
void SetLockMethod(const char *method) { fLockMethod = method; }
void SetModuleName(const char *mn) { fModuleName = mn; }
void SetState(const char *name, BMessage *stateMsg);
void SaveSettings();
BMessage& GetSettings();
private:
BRect fWindowFrame;
int32 fWindowTab;
int32 fTimeFlags;
bigtime_t fBlankTime;
bigtime_t fStandByTime;
bigtime_t fSuspendTime;
bigtime_t fOffTime;
screen_corner fBlankCorner;
screen_corner fNeverBlankCorner;
bool fLockEnabled;
bigtime_t fPasswordTime;
BString fPassword;
BString fModuleName;
BString fLockMethod;
BMessage fSettings;
BPath fSettingsPath, fNetworkPath;
};
#endif // SCREEN_SAVER_PREFS_H
@@ -0,0 +1,56 @@
/*
* Copyright 2003-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Michael Phipps
* Jérôme Duval, [email protected]
* Axel Dörfler, [email protected]
*/
#ifndef SCREEN_SAVER_RUNNER_H
#define SCREEN_SAVER_RUNNER_H
#include <SupportDefs.h>
#include <DirectWindow.h>
class BScreenSaver;
class BView;
class ScreenSaverPrefs;
class ScreenSaverRunner {
public:
ScreenSaverRunner(BWindow* window, BView* view,
bool preview, ScreenSaverPrefs& prefs);
~ScreenSaverRunner();
BScreenSaver* ScreenSaver() const;
bool HasStarted() const;
status_t Run();
void Quit();
void Suspend();
void Resume();
private:
void _LoadAddOn();
void _CleanUp();
static status_t _ThreadFunc(void* data);
void _Run();
BScreenSaver* fSaver;
BWindow* fWindow;
BDirectWindow* fDirectWindow;
BView* fView;
ScreenSaverPrefs& fPrefs;
bool fPreview;
bool fHasStarted;
image_id fAddonImage;
thread_id fThread;
volatile bool fQuitting;
};
#endif //SCREEN_SAVER_THREAD_H
@@ -1,43 +0,0 @@
/*
* Copyright 2003, Michael Phipps. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef SCREEN_SAVER_THREAD_H
#define SCREEN_SAVER_THREAD_H
#include <SupportDefs.h>
#include <DirectWindow.h>
class BScreenSaver;
class BView;
class ScreenSaverPrefs;
class ScreenSaverThread {
public:
ScreenSaverThread(BWindow* window,
BView* view,
ScreenSaverPrefs* prefs);
~ScreenSaverThread();
void Thread();
BScreenSaver* LoadAddOn();
void Quit(thread_id thread);
static int32 ThreadFunc(void* data);
private:
void _CleanUp();
BScreenSaver* fSaver;
BWindow* fWin;
BDirectWindow* fDWin;
BView* fView;
ScreenSaverPrefs* fPref;
long fFrame;
int fSnoozeCount;
image_id fAddonImage;
volatile bool fQuitting;
};
#endif //SCREEN_SAVER_THREAD_H