Many changes and fixes. Includes the password window work. Everything now works in here AFAIK.

Some people have reported Jam issues - the build is trying to use Be's headers.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7005 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Phipps 2004-03-17 03:43:30 +00:00
parent a206c3746f
commit d9e07e352f
6 changed files with 106 additions and 5 deletions

View File

@ -2,8 +2,7 @@ SubDir OBOS_TOP src servers screensaver ;
Server OBOSscreensaver :
ScreenSaverApp.cpp
ScreenSaverPrefs.cpp
SSAwindow.cpp
ScreenSaverThread.cpp
pwWindow.cpp
;
LinkSharedOSLibs OBOSscreensaver : be game screensaver ;
LinkSharedOSLibs OBOSscreensaver : be game ../../../distro/x86.R1/beos/system/lib/libscreensaver.so ;

View File

@ -25,14 +25,16 @@ bool SSAwindow::QuitRequested(void) {
}
void SSAwindow::DirectConnected(direct_buffer_info *info) {
/*
int i=info->buffer_state;
/*
printf ("direct connected; bufState=%d; bits = %x, bpr=%d, bottom=%d\n",i,info->bits,info->bytes_per_row,info->window_bounds.bottom);
if (!(i&B_DIRECT_STOP)) {
printf ("ready to clear; bits = %x, bpr=%d, bottom=%d\n",info->bits,info->bytes_per_row,info->window_bounds.bottom);
memset(info->bits,0,info->bytes_per_row*info->window_bounds.bottom);
}
*/
// printf ("direct connected; bufState=%d; bits = %x, bpr=%d, bottom=%d\n",i,info->bits,info->bytes_per_row,info->window_bounds.bottom);
if (saver)
saver->DirectConnected(info);
// printf ("direct connected ending!\n");
}

View File

@ -10,7 +10,7 @@
#include "File.h"
#include "Path.h"
#include "string.h"
#include "Alert.h"
#include "Beep.h"
// Start the server application. Set pulse to fire once per second.
@ -23,6 +23,7 @@ int main(int, char**) {
// Construct the server app. Doesn't do much, at this point.
ScreenSaverApp::ScreenSaverApp() : BApplication("application/x-vnd.OBOS-ScreenSaverApp"),addon_image(0),win(NULL) {
blankTime=real_time_clock();
}
void ScreenSaverApp::ReadyToRun(void) {
@ -31,6 +32,10 @@ void ScreenSaverApp::ReadyToRun(void) {
else { // If everything works OK, create a BDirectWindow and start the render thread.
BScreen theScreen(B_MAIN_SCREEN_ID);
win=new SSAwindow(theScreen.Frame(),saver);
if (B_OK!=win->SetFullScreen(true)) {
exit(1);
}
pww=new pwWindow();
thrd=new ScreenSaverThread(saver,win,win->view,&pref);
threadID=spawn_thread(threadFunc,"ScreenSaverRenderer",0,thrd);
resume_thread(threadID);
@ -38,6 +43,45 @@ void ScreenSaverApp::ReadyToRun(void) {
}
}
void ScreenSaverApp::ShowPW(void) {
win->Lock();
suspend_thread(threadID);
if (B_OK==win->SetFullScreen(false)) {
win->Sync();
ShowCursor();
pww->Show();
pww->Sync();
}
win->Unlock();
pww->Lock();
pww->Unlock();
}
void ScreenSaverApp::MessageReceived(BMessage *message) {
switch(message->what) {
case 'DONE':
if (strcmp(pww->GetPassword(),pref.Password())) {
beep();
pww->Hide();
win->SetFullScreen(true);
resume_thread(threadID);
}
else {
printf ("Quitting!\n");
Quit();
}
break;
case 'MOO1':
if (real_time_clock()-blankTime>pref.PasswordTime())
ShowPW();
else
Quit();
break;
default:
BApplication::MessageReceived(message);
break;
}
}
bool ScreenSaverApp::QuitRequested(void) {
kill_thread(threadID);
delete thrd;

View File

@ -7,6 +7,7 @@
#include "SSAwindow.h"
#include "ScreenSaverPrefs.h"
#include "ScreenSaverThread.h"
#include "pwWindow.h"
class ScreenSaverApp : public BApplication
{
@ -15,14 +16,18 @@ public:
bool LoadAddOn(void);
void ReadyToRun(void);
bool QuitRequested(void);
virtual void MessageReceived(BMessage *message);
void ShowPW(void);
private:
ScreenSaverPrefs pref;
image_id addon_image;
SSAwindow *win;
BScreenSaver *saver;
ScreenSaverThread *thrd;
pwWindow *pww;
thread_id threadID;
uint32 blankTime;
};

View File

@ -0,0 +1,30 @@
#include "pwWindow.h"
#include "Screen.h"
#include <stdio.h>
#include "Application.h"
void pwWindow::setup(void) {
BScreen theScreen(B_MAIN_SCREEN_ID);
MoveTo((theScreen.Frame().IntegerWidth()-Bounds().IntegerWidth())/2,(theScreen.Frame().IntegerHeight()-Bounds().IntegerHeight())/2);
bgd=new BView (Bounds(),"bgdView",0,0);
bgd->SetHighColor(ui_color(B_MENU_BACKGROUND_COLOR));
bgd->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));
bgd->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
AddChild(bgd);
BRect bounds(bgd->Bounds());
bounds.InsetBy(5,5);
customBox=new BBox(bounds,"custBeBox",B_FOLLOW_NONE);
customBox->SetLabel("Unlock screen saver");
bgd->AddChild(customBox);
password=new BTextControl(BRect(10,28,255,47),"pwdCntrl","Enter password:",NULL,B_FOLLOW_NONE);
password->SetDivider(100);
customBox->AddChild(password);
unlock=new BButton(BRect(160,70,255,85),"unlock","Unlock",new BMessage ('DONE'),B_FOLLOW_NONE);
unlock->SetTarget(NULL,be_app);
customBox->AddChild(unlock);
unlock->MakeDefault(true);
}

View File

@ -0,0 +1,21 @@
#include "Window.h"
#include "Box.h"
#include "TextControl.h"
#include "Button.h"
class pwWindow : public BWindow
{
public:
pwWindow (void) : BWindow(BRect(100,100,400,230),"pwView",B_NO_BORDER_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL ,
B_NOT_MOVABLE | B_NOT_CLOSABLE |B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS ,
B_ALL_WORKSPACES), die(false) {setup();}
void setup(void);
bool die;
const char *GetPassword(void) {return password->Text();}
private:
BView *bgd;
BBox *customBox;
BTextControl *password;
BButton *unlock;
};