xref: /haiku/src/bin/screen_blanker/ScreenSaverWindow.cpp (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
1 /*
2  * Copyright 2003-2006, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Michael Phipps
7  *		Jérôme Duval, jerome.duval@free.fr
8  */
9 
10 
11 #include "ScreenSaverWindow.h"
12 
13 #include <WindowPrivate.h>
14 
15 #include <Application.h>
16 #include <View.h>
17 
18 
19 /*!
20 	This is the BDirectWindow subclass that rendering occurs in.
21 	A view is added to it so that BView based screensavers will work.
22 */
23 ScreenSaverWindow::ScreenSaverWindow(BRect frame)
24 	: BDirectWindow(frame, "ScreenSaver Window",
25 		B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_ZOOMABLE),
26 	fSaver(NULL)
27 {
28 	frame.OffsetTo(0, 0);
29 	fTopView = new BView(frame, "ScreenSaver View", B_FOLLOW_ALL, B_WILL_DRAW);
30 	fTopView->SetViewColor(0, 0, 0);
31 	AddChild(fTopView);
32 }
33 
34 
35 ScreenSaverWindow::~ScreenSaverWindow()
36 {
37 	Hide();
38 }
39 
40 
41 void
42 ScreenSaverWindow::SetSaver(BScreenSaver *saver)
43 {
44 	fSaver = saver;
45 }
46 
47 
48 bool
49 ScreenSaverWindow::QuitRequested()
50 {
51 	be_app->PostMessage(B_QUIT_REQUESTED);
52 	return true;
53 }
54 
55 
56 void
57 ScreenSaverWindow::DirectConnected(direct_buffer_info *info)
58 {
59 	if (fSaver)
60 		fSaver->DirectConnected(info);
61 }
62 
63