moved screensaver server to screen_blanker bin

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13875 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2005-08-02 09:21:22 +00:00
parent 4bf7f3047f
commit 143f3a8060
11 changed files with 126 additions and 93 deletions

View File

@ -128,6 +128,7 @@ SubInclude OBOS_TOP src bin patch ;
SubInclude OBOS_TOP src bin pc ;
SubInclude OBOS_TOP src bin playsound ;
SubInclude OBOS_TOP src bin rmd160 ;
SubInclude OBOS_TOP src bin screen_blanker ;
SubInclude OBOS_TOP src bin sed ;
SubInclude OBOS_TOP src bin sharutils ;
SubInclude OBOS_TOP src bin strace ;

View File

@ -0,0 +1,11 @@
SubDir OBOS_TOP src bin screen_blanker ;
UsePrivateHeaders screen_saver ;
BinCommand screen_blanker :
ScreenSaverApp.cpp
SSAwindow.cpp
pwWindow.cpp
: be game libscreensaver.so
;

View File

@ -1,18 +1,20 @@
/*
* Copyright 2003, Michael Phipps. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "SSAwindow.h"
#include "Locker.h"
#include "View.h"
#include <memory.h>
#include <stdlib.h>
#include <stdio.h>
#include <View.h>
// This is the BDirectWindow subclass that rendering occurs in.
// A view is added to it so that BView based screensavers will work.
SSAwindow::SSAwindow(BRect frame) : BDirectWindow(frame, "ScreenSaver Window",
B_BORDERED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) , fSaver(NULL)
SSAwindow::SSAwindow(BRect frame)
: BDirectWindow(frame, "ScreenSaver Window",
B_BORDERED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) , fSaver(NULL)
{
frame.OffsetTo(0,0);
fView=new BView(frame,"ScreenSaver View",B_FOLLOW_ALL,B_WILL_DRAW);
AddChild (fView);
fView = new BView(frame,"ScreenSaver View",B_FOLLOW_ALL,B_WILL_DRAW);
AddChild(fView);
}
@ -29,9 +31,11 @@ SSAwindow::QuitRequested(void)
return true;
}
void
SSAwindow::DirectConnected(direct_buffer_info *info)
{
if (fSaver)
fSaver->DirectConnected(info);
}

View File

@ -1,4 +1,9 @@
#include "DirectWindow.h"
/*
* Copyright 2003, Michael Phipps. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <DirectWindow.h>
#include "ScreenSaver.h"
class SSAwindow : public BDirectWindow {
@ -7,9 +12,10 @@ public:
~SSAwindow();
virtual bool QuitRequested();
virtual void DirectConnected(direct_buffer_info *info);
void SetSaver(BScreenSaver *s) {fSaver=s;}
void SetSaver(BScreenSaver *s) {fSaver = s;}
BView *fView;
private:
BScreenSaver *fSaver;
};

View File

@ -1,16 +1,20 @@
#ifndef SCREEN_SAVER_H
#include "ScreenSaverApp.h"
#endif
/*
* Copyright 2003, Michael Phipps. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <stdio.h>
#include "Screen.h"
#include "image.h"
#include "StorageDefs.h"
#include "FindDirectory.h"
#include "SupportDefs.h"
#include "File.h"
#include "Path.h"
#include "string.h"
#include "Beep.h"
#include <Screen.h>
#include <image.h>
#include <StorageDefs.h>
#include <FindDirectory.h>
#include <SupportDefs.h>
#include <File.h>
#include <Path.h>
#include <string.h>
#include <Beep.h>
#include <ScreenSaverApp.h>
// Start the server application. Set pulse to fire once per second.
@ -23,9 +27,11 @@ int main(int, char**)
}
// Construct the server app. Doesn't do much, at this point.
ScreenSaverApp::ScreenSaverApp() : BApplication("application/x-vnd.OBOS-ScreenSaverApp"),fWin(NULL)
ScreenSaverApp::ScreenSaverApp()
: BApplication("application/x-vnd.OBOS-ScreenSaverApp"),
fWin(NULL)
{
fBlankTime=real_time_clock();
fBlankTime = system_time();
}
@ -36,35 +42,35 @@ ScreenSaverApp::ReadyToRun(void)
exit(1);
else { // If everything works OK, create a BDirectWindow and start the render thread.
BScreen theScreen(B_MAIN_SCREEN_ID);
fWin=new SSAwindow(theScreen.Frame());
fPww=new pwWindow();
fThrd=new ScreenSaverThread(fWin,fWin->fView,&fPref);
fWin = new SSAwindow(theScreen.Frame());
fPww = new PasswordWindow();
fThrd = new ScreenSaverThread(fWin,fWin->fView,&fPref);
fSaver=fThrd->LoadAddOn();
fSaver = fThrd->LoadAddOn();
if (!fSaver)
exit(1);
fWin->SetSaver(fSaver);
fWin->SetFullScreen(true);
fWin->Show();
fThreadID=spawn_thread(threadFunc,"ScreenSaverRenderer",0,fThrd);
fThreadID = spawn_thread(ScreenSaverThread::ThreadFunc,"ScreenSaverRenderer",0,fThrd);
resume_thread(fThreadID);
HideCursor();
}
}
}
void
ScreenSaverApp::ShowPW(void)
{
fWin->Lock();
suspend_thread(fThreadID);
if (B_OK==fWin->SetFullScreen(false)) {
fWin->Sync();
ShowCursor();
fPww->Show();
fPww->Sync();
}
fWin->Unlock();
fWin->Lock();
suspend_thread(fThreadID);
if (B_OK==fWin->SetFullScreen(false)) {
fWin->Sync();
ShowCursor();
fPww->Show();
fPww->Sync();
}
fWin->Unlock();
}
@ -82,14 +88,14 @@ ScreenSaverApp::MessageReceived(BMessage *message)
}
else {
printf ("Quitting!\n");
shutdown();
Shutdown();
}
break;
case 'MOO1':
if (real_time_clock()-fBlankTime>fPref.PasswordTime())
ShowPW();
else
shutdown();
Shutdown();
break;
default:
BApplication::MessageReceived(message);
@ -99,7 +105,7 @@ ScreenSaverApp::MessageReceived(BMessage *message)
void
ScreenSaverApp::shutdown(void)
ScreenSaverApp::Shutdown(void)
{
if (fWin)
fWin->Hide();

View File

@ -1,9 +1,12 @@
#ifndef SCREEN_SAVER_H
#define SCREEN_SAVER_H
/*
* Copyright 2003, Michael Phipps. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef SCREEN_SAVER_APP_H
#define SCREEN_SAVER_APP_H
#ifndef _APPLICATION_H
#include <Application.h>
#endif
#include "SSAwindow.h"
#include "ScreenSaverPrefs.h"
#include "ScreenSaverThread.h"
@ -13,23 +16,23 @@ class ScreenSaverApp : public BApplication
{
public:
ScreenSaverApp();
bool LoadAddOn(void);
void ReadyToRun(void);
// bool QuitRequested(void);
// void Quit(void);
bool LoadAddOn();
void ReadyToRun();
// bool QuitRequested();
// void Quit();
virtual void MessageReceived(BMessage *message);
void ShowPW(void);
void ShowPW();
private:
ScreenSaverPrefs fPref;
SSAwindow *fWin;
BScreenSaver *fSaver;
ScreenSaverThread *fThrd;
pwWindow *fPww;
PasswordWindow *fPww;
thread_id fThreadID;
uint32 fBlankTime;
void shutdown(void);
void Shutdown();
};
#endif //SCREEN_SAVER_H
#endif //SCREEN_SAVER_APP_H

View File

@ -1,10 +1,15 @@
/*
* Copyright 2003, Michael Phipps. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <Application.h>
#include <Screen.h>
#include "pwWindow.h"
#include "Screen.h"
#include <stdio.h>
#include "Application.h"
void
pwWindow::setup(void)
PasswordWindow::Setup()
{
BScreen theScreen(B_MAIN_SCREEN_ID);
MoveTo((theScreen.Frame().IntegerWidth()-Bounds().IntegerWidth())/2,(theScreen.Frame().IntegerHeight()-Bounds().IntegerHeight())/2);
@ -20,7 +25,7 @@ pwWindow::setup(void)
fCustomBox->SetLabel("Unlock screen saver");
fBgd->AddChild(fCustomBox);
fPassword=new BTextControl(BRect(10,28,255,47),"pwdCntrl","Enter fPassword:",NULL,B_FOLLOW_NONE);
fPassword = new BTextControl(BRect(10,28,255,47),"pwdCntrl","Enter fPassword:",NULL,B_FOLLOW_NONE);
fPassword->SetDivider(100);
fCustomBox->AddChild(fPassword);

View File

@ -0,0 +1,30 @@
/*
* Copyright 2003, Michael Phipps. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef PASSWORDWINDOW_H
#define PASSWORDWINDOW_H
#include <Window.h>
#include <Box.h>
#include <TextControl.h>
#include <Button.h>
class PasswordWindow : public BWindow
{
public:
PasswordWindow() : 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), fDie(false) { Setup(); }
void Setup(void);
const char *GetPassword(void) {return fPassword->Text();}
bool fDie;
private:
BView *fBgd;
BBox *fCustomBox;
BTextControl *fPassword;
BButton *fUnlock;
};
#endif // PASSWORDWINDOW_H

View File

@ -11,5 +11,4 @@ SubInclude OBOS_TOP src servers midi ;
SubInclude OBOS_TOP src servers power ;
SubInclude OBOS_TOP src servers print ;
SubInclude OBOS_TOP src servers registrar ;
SubInclude OBOS_TOP src servers screensaver ;
SubInclude OBOS_TOP src servers syslog_daemon ;

View File

@ -1,10 +0,0 @@
SubDir OBOS_TOP src servers screensaver ;
UsePrivateHeaders screen_saver ;
Server OBOSscreensaver :
ScreenSaverApp.cpp
SSAwindow.cpp
pwWindow.cpp
;
LinkSharedOSLibs OBOSscreensaver : be game libscreensaver.so ;

View File

@ -1,22 +0,0 @@
#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), fDie(false) {setup();}
void setup(void);
const char *GetPassword(void) {return fPassword->Text();}
bool fDie;
private:
BView *fBgd;
BBox *fCustomBox;
BTextControl *fPassword;
BButton *fUnlock;
};