More cleanup.
Get rid of unused fRtc variable. Added TODO about why the current solution doesn't work correctly (doesn't start the screen saver at exact times, but possibly almost twice fBlankTime too late). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14246 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -19,6 +19,10 @@
|
|||||||
#define CALLED() SERIAL_PRINT(("%s\n", __PRETTY_FUNCTION__))
|
#define CALLED() SERIAL_PRINT(("%s\n", __PRETTY_FUNCTION__))
|
||||||
|
|
||||||
|
|
||||||
|
const int CORNER_SIZE = 10;
|
||||||
|
const int32 SS_CHECK_TIME = 'SSCT';
|
||||||
|
|
||||||
|
|
||||||
extern "C" _EXPORT BInputServerFilter* instantiate_input_filter();
|
extern "C" _EXPORT BInputServerFilter* instantiate_input_filter();
|
||||||
|
|
||||||
|
|
||||||
@@ -47,6 +51,7 @@ SSController::MessageReceived(BMessage *msg)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
SERIAL_PRINT(("what %lx\n", msg->what));
|
SERIAL_PRINT(("what %lx\n", msg->what));
|
||||||
|
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case B_NODE_MONITOR:
|
case B_NODE_MONITOR:
|
||||||
fFilter->ReloadSettings();
|
fFilter->ReloadSettings();
|
||||||
@@ -78,7 +83,6 @@ SSInputFilter::SSInputFilter()
|
|||||||
: fLastEventTime(0),
|
: fLastEventTime(0),
|
||||||
fBlankTime(0),
|
fBlankTime(0),
|
||||||
fSnoozeTime(0),
|
fSnoozeTime(0),
|
||||||
fRtc(0),
|
|
||||||
fCurrent(NONE),
|
fCurrent(NONE),
|
||||||
fEnabled(false),
|
fEnabled(false),
|
||||||
fFrameNum(0),
|
fFrameNum(0),
|
||||||
@@ -100,9 +104,9 @@ SSInputFilter::~SSInputFilter()
|
|||||||
delete fRunner;
|
delete fRunner;
|
||||||
|
|
||||||
if (fWatchingFile)
|
if (fWatchingFile)
|
||||||
watch_node(&fPrefNodeRef, B_STOP_WATCHING, NULL);
|
watch_node(&fPrefsNodeRef, B_STOP_WATCHING, NULL);
|
||||||
if (fWatchingDirectory)
|
if (fWatchingDirectory)
|
||||||
watch_node(&fPrefDirNodeRef, B_STOP_WATCHING, NULL);
|
watch_node(&fPrefsDirNodeRef, B_STOP_WATCHING, NULL);
|
||||||
|
|
||||||
be_roster->StopWatching(fSSController);
|
be_roster->StopWatching(fSSController);
|
||||||
delete fSSController;
|
delete fSSController;
|
||||||
@@ -112,28 +116,28 @@ SSInputFilter::~SSInputFilter()
|
|||||||
void
|
void
|
||||||
SSInputFilter::WatchPreferences()
|
SSInputFilter::WatchPreferences()
|
||||||
{
|
{
|
||||||
BEntry entry(fPref.GetPath().Path());
|
BEntry entry(fPrefs.GetPath().Path());
|
||||||
if (entry.Exists()) {
|
if (entry.Exists()) {
|
||||||
if (fWatchingFile)
|
if (fWatchingFile)
|
||||||
return;
|
return;
|
||||||
if (fWatchingDirectory) {
|
if (fWatchingDirectory) {
|
||||||
watch_node(&fPrefDirNodeRef, B_STOP_WATCHING, NULL);
|
watch_node(&fPrefsDirNodeRef, B_STOP_WATCHING, NULL);
|
||||||
fWatchingDirectory = false;
|
fWatchingDirectory = false;
|
||||||
}
|
}
|
||||||
entry.GetNodeRef(&fPrefNodeRef);
|
entry.GetNodeRef(&fPrefsNodeRef);
|
||||||
watch_node(&fPrefNodeRef, B_WATCH_ALL, NULL, fSSController);
|
watch_node(&fPrefsNodeRef, B_WATCH_ALL, NULL, fSSController);
|
||||||
fWatchingFile = true;
|
fWatchingFile = true;
|
||||||
} else {
|
} else {
|
||||||
if (fWatchingDirectory)
|
if (fWatchingDirectory)
|
||||||
return;
|
return;
|
||||||
if (fWatchingFile) {
|
if (fWatchingFile) {
|
||||||
watch_node(&fPrefNodeRef, B_STOP_WATCHING, NULL);
|
watch_node(&fPrefsNodeRef, B_STOP_WATCHING, NULL);
|
||||||
fWatchingFile = false;
|
fWatchingFile = false;
|
||||||
}
|
}
|
||||||
BEntry dir;
|
BEntry dir;
|
||||||
entry.GetParent(&dir);
|
entry.GetParent(&dir);
|
||||||
dir.GetNodeRef(&fPrefDirNodeRef);
|
dir.GetNodeRef(&fPrefsDirNodeRef);
|
||||||
watch_node(&fPrefDirNodeRef, B_WATCH_ALL, NULL, fSSController);
|
watch_node(&fPrefsDirNodeRef, B_WATCH_ALL, NULL, fSSController);
|
||||||
fWatchingDirectory = true;
|
fWatchingDirectory = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +149,7 @@ SSInputFilter::Invoke()
|
|||||||
CALLED();
|
CALLED();
|
||||||
if ((fKeep != NONE && fCurrent == fKeep)
|
if ((fKeep != NONE && fCurrent == fKeep)
|
||||||
|| fEnabled
|
|| fEnabled
|
||||||
|| fPref.TimeFlags() != 1
|
|| fPrefs.TimeFlags() != 1
|
||||||
|| be_roster->IsRunning(SCREEN_BLANKER_SIG)) {
|
|| be_roster->IsRunning(SCREEN_BLANKER_SIG)) {
|
||||||
// If mouse is in this corner, never invoke.
|
// If mouse is in this corner, never invoke.
|
||||||
return;
|
return;
|
||||||
@@ -160,13 +164,13 @@ void
|
|||||||
SSInputFilter::ReloadSettings()
|
SSInputFilter::ReloadSettings()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (!fPref.LoadSettings()) {
|
if (!fPrefs.LoadSettings()) {
|
||||||
SERIAL_PRINT(("preferences loading failed: going to defaults\n"));
|
SERIAL_PRINT(("preferences loading failed: going to defaults\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
fBlank = fPref.GetBlankCorner();
|
fBlank = fPrefs.GetBlankCorner();
|
||||||
fKeep = fPref.GetNeverBlankCorner();
|
fKeep = fPrefs.GetNeverBlankCorner();
|
||||||
fBlankTime = fSnoozeTime = fPref.BlankTime();
|
fBlankTime = fSnoozeTime = fPrefs.BlankTime();
|
||||||
CheckTime();
|
CheckTime();
|
||||||
|
|
||||||
delete fRunner;
|
delete fRunner;
|
||||||
@@ -199,18 +203,21 @@ void
|
|||||||
SSInputFilter::CheckTime()
|
SSInputFilter::CheckTime()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
fRtc = system_time();
|
bigtime_t now = system_time();
|
||||||
if (fRtc >= fLastEventTime + fBlankTime)
|
if (now >= fLastEventTime + fBlankTime)
|
||||||
Invoke();
|
Invoke();
|
||||||
|
|
||||||
|
// TODO: this doesn't work correctly - since the BMessageRunner is not
|
||||||
|
// restarted, the next check will be too far away
|
||||||
|
|
||||||
// If the screen saver is on OR it was time to come on but it didn't (corner),
|
// If the screen saver is on OR it was time to come on but it didn't (corner),
|
||||||
// snooze for blankTime.
|
// snooze for blankTime.
|
||||||
// Otherwise, there was an event in the middle of the last snooze, so snooze
|
// Otherwise, there was an event in the middle of the last snooze, so snooze
|
||||||
// for the remainder.
|
// for the remainder.
|
||||||
if (fEnabled || fLastEventTime + fBlankTime <= fRtc)
|
if (fEnabled || fLastEventTime + fBlankTime <= now)
|
||||||
fSnoozeTime = fBlankTime;
|
fSnoozeTime = fBlankTime;
|
||||||
else
|
else
|
||||||
fSnoozeTime = fLastEventTime + fBlankTime - fRtc;
|
fSnoozeTime = fLastEventTime + fBlankTime - now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,10 @@
|
|||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Michael Phipps
|
* Michael Phipps
|
||||||
* Jérôme Duval, [email protected]
|
* Jérôme Duval, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <InputServerFilter.h>
|
#include <InputServerFilter.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
@@ -16,40 +17,42 @@
|
|||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include "ScreenSaverPrefs.h"
|
#include "ScreenSaverPrefs.h"
|
||||||
|
|
||||||
const int CORNER_SIZE = 10;
|
|
||||||
const int32 SS_CHECK_TIME = 'SSCT';
|
|
||||||
|
|
||||||
class SSInputFilter;
|
class SSInputFilter;
|
||||||
|
|
||||||
class SSController : public BLooper
|
class SSController : public BLooper {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
SSController(SSInputFilter *filter);
|
SSController(SSInputFilter *filter);
|
||||||
void MessageReceived(BMessage *msg);
|
void MessageReceived(BMessage *msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SSInputFilter* fFilter;
|
SSInputFilter* fFilter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SSInputFilter : public BInputServerFilter
|
class SSInputFilter : public BInputServerFilter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
SSInputFilter();
|
SSInputFilter();
|
||||||
virtual ~SSInputFilter();
|
virtual ~SSInputFilter();
|
||||||
virtual filter_result Filter(BMessage *msg, BList *outList);
|
virtual filter_result Filter(BMessage *msg, BList *outList);
|
||||||
void CheckTime();
|
void CheckTime();
|
||||||
uint32 GetSnoozeTime(void) {return fSnoozeTime;}
|
|
||||||
|
uint32 SnoozeTime() {return fSnoozeTime;}
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
void SetEnabled(bool enabled) { fEnabled = enabled; }
|
void SetEnabled(bool enabled) { fEnabled = enabled; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bigtime_t fLastEventTime, fBlankTime, fSnoozeTime, fRtc;
|
bigtime_t fLastEventTime, fBlankTime, fSnoozeTime;
|
||||||
arrowDirection fBlank, fKeep, fCurrent;
|
arrowDirection fBlank, fKeep, fCurrent;
|
||||||
bool fEnabled;
|
bool fEnabled;
|
||||||
BRect fTopLeft, fTopRight, fBottomLeft, fBottomRight;
|
BRect fTopLeft, fTopRight, fBottomLeft, fBottomRight;
|
||||||
ScreenSaverPrefs fPref;
|
ScreenSaverPrefs fPrefs;
|
||||||
uint32 fFrameNum; // Used so that we don't update the screen coord's so often
|
uint32 fFrameNum;
|
||||||
// Ideally, we would get a message when the screen changes. R5 doesn't do this.
|
// Used so that we don't update the screen coord's so often
|
||||||
|
// Ideally, we would get a message when the screen changes.
|
||||||
|
// R5 doesn't do this.
|
||||||
|
|
||||||
SSController *fSSController;
|
SSController *fSSController;
|
||||||
node_ref fPrefNodeRef, fPrefDirNodeRef;
|
node_ref fPrefsNodeRef, fPrefsDirNodeRef;
|
||||||
BMessageRunner *fRunner;
|
BMessageRunner *fRunner;
|
||||||
bool fWatchingDirectory, fWatchingFile;
|
bool fWatchingDirectory, fWatchingFile;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user