Some minor changes to promote code sharing.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7124 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -58,6 +58,7 @@ bool ScreenSaverPrefs::parseSettings (BMessage *msg) {
|
|||||||
neverBlank=(arrowDirection)temp;
|
neverBlank=(arrowDirection)temp;
|
||||||
setOnValue(msg,"lockdelay",passwordTime);
|
setOnValue(msg,"lockdelay",passwordTime);
|
||||||
|
|
||||||
|
msg->FindRect("windowframe",&windowFrame);
|
||||||
msg->FindBool("lockenable",&lockenable);
|
msg->FindBool("lockenable",&lockenable);
|
||||||
msg->FindString("lockmethod",&strPtr);
|
msg->FindString("lockmethod",&strPtr);
|
||||||
isNetworkPWD=(strcmp("custom",strPtr));
|
isNetworkPWD=(strcmp("custom",strPtr));
|
||||||
@@ -78,12 +79,16 @@ bool ScreenSaverPrefs::parseSettings (BMessage *msg) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg->FindString("lockpassword",&strPtr);
|
msg->FindString("lockpassword",&strPtr);
|
||||||
strcpy(password,strPtr);
|
if (strPtr)
|
||||||
|
strncpy(password,strPtr,B_PATH_NAME_LENGTH-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (B_OK != msg->FindString("modulename",&strPtr))
|
if (B_OK != msg->FindString("modulename",&strPtr))
|
||||||
blankTime=-1; // If the module doesn't exist, never blank.
|
blankTime=-1; // If the module doesn't exist, never blank.
|
||||||
strcpy(moduleName,strPtr);
|
if (strPtr)
|
||||||
|
strncpy(moduleName,strPtr,B_PATH_NAME_LENGTH-1);
|
||||||
|
else
|
||||||
|
strcpy(moduleName,"Blackness");
|
||||||
BString stateMsgName("modulesettings_");
|
BString stateMsgName("modulesettings_");
|
||||||
stateMsgName+=moduleName;
|
stateMsgName+=moduleName;
|
||||||
msg->FindMessage(stateMsgName.String(),&stateMsg); // Doesn't matter if it fails - stateMsg would just continue to be empty
|
msg->FindMessage(stateMsgName.String(),&stateMsg); // Doesn't matter if it fails - stateMsg would just continue to be empty
|
||||||
|
|||||||
@@ -4,24 +4,18 @@
|
|||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
#include "ScreenSaver.h"
|
#include "ScreenSaver.h"
|
||||||
#include "ScreenSaverPrefs.h"
|
#include "ScreenSaverPrefs.h"
|
||||||
|
#include "FindDirectory.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
int32 threadFunc(void *data) {
|
int32 threadFunc(void *data) {
|
||||||
ScreenSaverThread *ss=(ScreenSaverThread *)data;
|
ScreenSaverThread *ss=(ScreenSaverThread *)data;
|
||||||
ss->thread();
|
ss->thread();
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenSaverThread::ScreenSaverThread(BScreenSaver *svr, BDirectWindow *wnd, BView *vw, ScreenSaverPrefs *p) :
|
ScreenSaverThread::ScreenSaverThread(BWindow *wnd, BView *vw, ScreenSaverPrefs *p) :
|
||||||
saver(svr),win(wnd),view(vw), pref(p), frame(0),snoozeCount(0) {
|
saver(NULL),win(wnd),view(vw), pref(p), frame(0),snoozeCount(0),addon_image(0) {
|
||||||
if (win) { // Running in full screen mode
|
dwin=reinterpret_cast<BDirectWindow *>(wnd);
|
||||||
saver->StartSaver(view,false);
|
|
||||||
win->SetFullScreen(true);
|
|
||||||
win->Show();
|
|
||||||
win->Lock();
|
|
||||||
view->SetViewColor(0,0,0);
|
|
||||||
view->SetLowColor(0,0,0);
|
|
||||||
win->Unlock();
|
|
||||||
win->Sync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSaverThread::quit(void) {
|
void ScreenSaverThread::quit(void) {
|
||||||
@@ -31,6 +25,11 @@ void ScreenSaverThread::quit(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSaverThread::thread() {
|
void ScreenSaverThread::thread() {
|
||||||
|
win->Lock();
|
||||||
|
view->SetViewColor(0,0,0);
|
||||||
|
view->SetLowColor(0,0,0);
|
||||||
|
saver->StartSaver(view,false);
|
||||||
|
win->Unlock();
|
||||||
while (1) {
|
while (1) {
|
||||||
snooze(saver->TickSize());
|
snooze(saver->TickSize());
|
||||||
if (snoozeCount) { // If we are sleeping, do nothing
|
if (snoozeCount) { // If we are sleeping, do nothing
|
||||||
@@ -41,17 +40,64 @@ void ScreenSaverThread::thread() {
|
|||||||
snoozeCount=saver->LoopOffCount();
|
snoozeCount=saver->LoopOffCount();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (win) {
|
win->Lock();
|
||||||
|
if (dwin)
|
||||||
saver->DirectDraw(frame);
|
saver->DirectDraw(frame);
|
||||||
win->Lock();
|
|
||||||
}
|
|
||||||
saver->Draw(view,frame);
|
saver->Draw(view,frame);
|
||||||
if (win) {
|
win->Unlock();
|
||||||
win->Unlock();
|
|
||||||
win->Sync();
|
|
||||||
}
|
|
||||||
frame++;
|
frame++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BScreenSaver *ScreenSaverThread::LoadAddOn() {
|
||||||
|
BScreenSaver *(*instantiate)(BMessage *, image_id );
|
||||||
|
if (addon_image) { // This is a new set of preferences. Free up what we did have
|
||||||
|
unload_add_on(addon_image);
|
||||||
|
}
|
||||||
|
char temp[B_PATH_NAME_LENGTH];
|
||||||
|
if (B_OK==find_directory(B_BEOS_ADDONS_DIRECTORY,NULL,false,temp,B_PATH_NAME_LENGTH)) {
|
||||||
|
sprintf (temp,"%s/Screen Savers/%s",temp,pref->ModuleName());
|
||||||
|
addon_image = load_add_on(temp);
|
||||||
|
}
|
||||||
|
if (addon_image<0) {
|
||||||
|
//printf ("Unable to open add-on: %s\n",temp);
|
||||||
|
sprintf (temp,"%s/Screen Savers/%s",temp,pref->ModuleName());
|
||||||
|
if (B_OK==find_directory(B_COMMON_ADDONS_DIRECTORY,NULL,false,temp,B_PATH_NAME_LENGTH)) {
|
||||||
|
sprintf (temp,"%s/Screen Savers/%s",temp,pref->ModuleName());
|
||||||
|
addon_image = load_add_on(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (addon_image<0) {
|
||||||
|
//printf ("Unable to open add-on: %s\n",temp);
|
||||||
|
if (B_OK==find_directory(B_USER_ADDONS_DIRECTORY,NULL,false,temp,B_PATH_NAME_LENGTH)) {
|
||||||
|
sprintf (temp,"%s/Screen Savers/%s",temp,pref->ModuleName());
|
||||||
|
addon_image = load_add_on(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (addon_image<0) {
|
||||||
|
printf ("Unable to open add-on: %s\n",temp);
|
||||||
|
printf ("add on image = %ld!\n",addon_image);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Look for the one C function that should exist.
|
||||||
|
status_t retVal;
|
||||||
|
if (B_OK != (retVal=get_image_symbol(addon_image, "instantiate_screen_saver", B_SYMBOL_TYPE_TEXT,(void **) &instantiate))) {
|
||||||
|
printf ("Unable to find the instantiator\n");
|
||||||
|
printf ("Error = %ld\n",retVal);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
saver=instantiate(pref->GetState(),addon_image);
|
||||||
|
if (B_OK!=saver->InitCheck()) {
|
||||||
|
printf ("InitCheck() Failed!\n");
|
||||||
|
unload_add_on(addon_image);
|
||||||
|
delete saver;
|
||||||
|
saver=NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return saver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user