ScreenSaverRunner: Style fixes
Also update copyright info, add myself to authors list alphabetically.
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku.
|
* Copyright 2003-2013 Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Michael Phipps
|
|
||||||
* Jérôme Duval, [email protected]
|
|
||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
|
* Jérôme Duval, [email protected]
|
||||||
|
* Michael Phipps
|
||||||
|
* John Scipione, [email protected]
|
||||||
*/
|
*/
|
||||||
#ifndef SCREEN_SAVER_RUNNER_H
|
#ifndef SCREEN_SAVER_RUNNER_H
|
||||||
#define SCREEN_SAVER_RUNNER_H
|
#define SCREEN_SAVER_RUNNER_H
|
||||||
@@ -14,43 +15,45 @@
|
|||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#include <DirectWindow.h>
|
#include <DirectWindow.h>
|
||||||
|
|
||||||
|
|
||||||
class BScreenSaver;
|
class BScreenSaver;
|
||||||
class BView;
|
class BView;
|
||||||
class ScreenSaverSettings;
|
class ScreenSaverSettings;
|
||||||
|
|
||||||
|
|
||||||
class ScreenSaverRunner {
|
class ScreenSaverRunner {
|
||||||
public:
|
public:
|
||||||
ScreenSaverRunner(BWindow* window, BView* view,
|
ScreenSaverRunner(BWindow* window, BView* view,
|
||||||
bool preview, ScreenSaverSettings& settings);
|
bool preview,
|
||||||
~ScreenSaverRunner();
|
ScreenSaverSettings& settings);
|
||||||
|
~ScreenSaverRunner();
|
||||||
|
|
||||||
BScreenSaver* ScreenSaver() const;
|
BScreenSaver* ScreenSaver() const;
|
||||||
bool HasStarted() const;
|
bool HasStarted() const;
|
||||||
|
|
||||||
status_t Run();
|
status_t Run();
|
||||||
void Quit();
|
void Quit();
|
||||||
|
|
||||||
void Suspend();
|
void Suspend();
|
||||||
void Resume();
|
void Resume();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _LoadAddOn();
|
void _LoadAddOn();
|
||||||
void _CleanUp();
|
void _CleanUp();
|
||||||
static status_t _ThreadFunc(void* data);
|
static status_t _ThreadFunc(void* data);
|
||||||
void _Run();
|
void _Run();
|
||||||
|
|
||||||
BScreenSaver* fSaver;
|
BScreenSaver* fSaver;
|
||||||
BWindow* fWindow;
|
BWindow* fWindow;
|
||||||
BDirectWindow* fDirectWindow;
|
BDirectWindow* fDirectWindow;
|
||||||
BView* fView;
|
BView* fView;
|
||||||
ScreenSaverSettings& fSettings;
|
ScreenSaverSettings& fSettings;
|
||||||
bool fPreview;
|
bool fPreview;
|
||||||
bool fHasStarted;
|
bool fHasStarted;
|
||||||
|
|
||||||
image_id fAddonImage;
|
image_id fAddonImage;
|
||||||
thread_id fThread;
|
thread_id fThread;
|
||||||
volatile bool fQuitting;
|
volatile bool fQuitting;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCREEN_SAVER_RUNNER_H
|
#endif // SCREEN_SAVER_RUNNER_H
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku.
|
* Copyright 2003-2013, Haiku, Inc. All Rights Reserved
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Michael Phipps
|
|
||||||
* Jérôme Duval, [email protected]
|
|
||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
|
* Jérôme Duval, [email protected]
|
||||||
|
* Michael Phipps
|
||||||
|
* John Scipione, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
ScreenSaverRunner::ScreenSaverRunner(BWindow* window, BView* view,
|
ScreenSaverRunner::ScreenSaverRunner(BWindow* window, BView* view,
|
||||||
bool preview, ScreenSaverSettings& settings)
|
bool preview, ScreenSaverSettings& settings)
|
||||||
:
|
:
|
||||||
@@ -62,7 +64,8 @@ ScreenSaverRunner::HasStarted() const
|
|||||||
status_t
|
status_t
|
||||||
ScreenSaverRunner::Run()
|
ScreenSaverRunner::Run()
|
||||||
{
|
{
|
||||||
fThread = spawn_thread(&_ThreadFunc, "ScreenSaverRenderer", B_LOW_PRIORITY, this);
|
fThread = spawn_thread(&_ThreadFunc, "ScreenSaverRenderer", B_LOW_PRIORITY,
|
||||||
|
this);
|
||||||
Resume();
|
Resume();
|
||||||
|
|
||||||
return fThread >= B_OK ? B_OK : fThread;
|
return fThread >= B_OK ? B_OK : fThread;
|
||||||
@@ -108,7 +111,7 @@ ScreenSaverRunner::_LoadAddOn()
|
|||||||
}
|
}
|
||||||
_CleanUp();
|
_CleanUp();
|
||||||
|
|
||||||
if (!strcmp("", fSettings.ModuleName())) {
|
if (strcmp("", fSettings.ModuleName()) == 0) {
|
||||||
Resume();
|
Resume();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -137,7 +140,8 @@ ScreenSaverRunner::_LoadAddOn()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fAddonImage < B_OK) {
|
if (fAddonImage < B_OK) {
|
||||||
printf("Unable to open add-on: %s: %s\n", path.Path(), strerror(fAddonImage));
|
printf("Unable to open add-on: %s: %s\n", path.Path(),
|
||||||
|
strerror(fAddonImage));
|
||||||
} else {
|
} else {
|
||||||
// Look for the one C function that should exist.
|
// Look for the one C function that should exist.
|
||||||
if (get_image_symbol(fAddonImage, "instantiate_screen_saver",
|
if (get_image_symbol(fAddonImage, "instantiate_screen_saver",
|
||||||
@@ -150,7 +154,8 @@ ScreenSaverRunner::_LoadAddOn()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fSaver->InitCheck() != B_OK) {
|
if (fSaver->InitCheck() != B_OK) {
|
||||||
printf("ScreenSaver initialization failed: %s!\n", strerror(fSaver->InitCheck()));
|
printf("ScreenSaver initialization failed: %s!\n",
|
||||||
|
strerror(fSaver->InitCheck()));
|
||||||
_CleanUp();
|
_CleanUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,8 +185,9 @@ ScreenSaverRunner::_Run()
|
|||||||
if (fWindow->Lock()) {
|
if (fWindow->Lock()) {
|
||||||
fView->SetViewColor(0, 0, 0);
|
fView->SetViewColor(0, 0, 0);
|
||||||
fView->SetLowColor(0, 0, 0);
|
fView->SetLowColor(0, 0, 0);
|
||||||
if (fSaver)
|
if (fSaver != NULL)
|
||||||
fHasStarted = fSaver->StartSaver(fView, fPreview) == B_OK;
|
fHasStarted = fSaver->StartSaver(fView, fPreview) == B_OK;
|
||||||
|
|
||||||
fWindow->Unlock();
|
fWindow->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,10 +206,10 @@ ScreenSaverRunner::_Run()
|
|||||||
// will result in the screen saver not responding to deactivation
|
// will result in the screen saver not responding to deactivation
|
||||||
// for that length of time
|
// for that length of time
|
||||||
snooze(tickBase);
|
snooze(tickBase);
|
||||||
if (system_time() - lastTickTime < tick) {
|
if (system_time() - lastTickTime < tick)
|
||||||
continue;
|
continue;
|
||||||
} else {
|
else {
|
||||||
// re-evaluate the tick time after each successful wakeup -
|
// re-evaluate the tick time after each successful wakeup
|
||||||
// screensavers can adjust it on the fly, and we must be
|
// screensavers can adjust it on the fly, and we must be
|
||||||
// prepared to accomodate that
|
// prepared to accomodate that
|
||||||
tick = fSaver ? fSaver->TickSize() : tickBase;
|
tick = fSaver ? fSaver->TickSize() : tickBase;
|
||||||
@@ -212,9 +218,8 @@ ScreenSaverRunner::_Run()
|
|||||||
if (tick < 0)
|
if (tick < 0)
|
||||||
tick = 0;
|
tick = 0;
|
||||||
tickBase = tick;
|
tickBase = tick;
|
||||||
} else if (tickBase < kInitialTickRate && tick >= kInitialTickRate) {
|
} else if (tickBase < kInitialTickRate && tick >= kInitialTickRate)
|
||||||
tickBase = kInitialTickRate;
|
tickBase = kInitialTickRate;
|
||||||
}
|
|
||||||
|
|
||||||
lastTickTime = system_time();
|
lastTickTime = system_time();
|
||||||
}
|
}
|
||||||
@@ -243,7 +248,7 @@ ScreenSaverRunner::_Run()
|
|||||||
snoozeCount = 1000;
|
snoozeCount = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fSaver)
|
if (fSaver != NULL)
|
||||||
fSaver->StopSaver();
|
fSaver->StopSaver();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,4 +260,3 @@ ScreenSaverRunner::_ThreadFunc(void *data)
|
|||||||
runner->_Run();
|
runner->_Run();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user