1 /* 2 * Copyright 2003, Michael Phipps. All rights reserved. 3 * Copyright 2014, Puck Meerburg. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef SCREEN_SAVER_WINDOW_H 7 #define SCREEN_SAVER_WINDOW_H 8 9 10 #include "ScreenSaver.h" 11 12 #include <DirectWindow.h> 13 #include <MessageFilter.h> 14 15 #include "ScreenSaverRunner.h" 16 17 18 const static uint32 kMsgEnableFilter = 'eflt'; 19 20 21 class ScreenSaverFilter : public BMessageFilter { 22 public: 23 ScreenSaverFilter(bool test) 24 : 25 BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), 26 fEnabled(true), 27 fTestMode(test) {} 28 29 virtual filter_result Filter(BMessage* message, BHandler** target); 30 31 void SetEnabled(bool enabled) 32 { fEnabled = enabled; }; 33 34 private: 35 bool fEnabled; 36 bool fTestMode; 37 }; 38 39 40 class ScreenSaverWindow : public BDirectWindow { 41 public: 42 ScreenSaverWindow(BRect frame, bool test); 43 ~ScreenSaverWindow(); 44 45 virtual void MessageReceived(BMessage* message); 46 virtual bool QuitRequested(); 47 virtual void DirectConnected(direct_buffer_info* info); 48 49 void SetSaverRunner(ScreenSaverRunner* runner); 50 BScreenSaver* _ScreenSaver(); 51 52 private: 53 BView* fTopView; 54 ScreenSaverRunner* fSaverRunner; 55 ScreenSaverFilter* fFilter; 56 }; 57 58 59 #endif // SCREEN_SAVER_WINDOW_H 60