2004-01-17 21:34:54 +00:00
|
|
|
//
|
|
|
|
// Contributor(s):
|
2004-01-18 19:36:50 +00:00
|
|
|
// DirectX 8.1 Screen Saver Framework from Microsoft.
|
|
|
|
// Microsoft Knowledge Base Article - 79212
|
2004-01-17 21:34:54 +00:00
|
|
|
//
|
|
|
|
|
2007-08-14 17:23:30 +00:00
|
|
|
#ifndef _SCREENSAVER_WIN_H
|
|
|
|
#define _SCREENSAVER_WIN_H
|
2004-11-14 08:29:32 +00:00
|
|
|
|
2004-01-17 21:34:54 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Constants
|
|
|
|
//-----------------------------------------------------------------------------
|
2004-11-18 04:09:10 +00:00
|
|
|
#define MAX_DISPLAYS 9
|
|
|
|
#define NO_ADAPTER 0xffffffff
|
|
|
|
#define NO_MONITOR 0xffffffff
|
|
|
|
|
2006-04-12 02:28:50 +00:00
|
|
|
#define BSF_ALLOWSFW 0x00000080
|
2004-11-18 04:09:10 +00:00
|
|
|
|
2004-12-03 19:47:54 +00:00
|
|
|
#define BOINC_WINDOW_CLASS_NAME _T("BOINC_app")
|
2004-01-17 21:34:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
//***************************************************************************************
|
|
|
|
// Modes of operation for screensaver
|
|
|
|
enum SaverMode
|
|
|
|
{
|
|
|
|
sm_config, // Config dialog box
|
|
|
|
sm_preview, // Mini preview window in Display Properties dialog
|
|
|
|
sm_full, // Full-on screensaver mode
|
|
|
|
sm_test, // Test mode
|
|
|
|
sm_passwordchange // Change password
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Name: struct INTERNALMONITORINFO
|
|
|
|
// Desc: Structure for holding information about a monitor
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
struct INTERNALMONITORINFO
|
|
|
|
{
|
|
|
|
TCHAR strDeviceName[128];
|
|
|
|
TCHAR strMonitorName[128];
|
|
|
|
HMONITOR hMonitor;
|
|
|
|
RECT rcScreen;
|
|
|
|
HWND hWnd;
|
|
|
|
|
2006-07-25 10:19:27 +00:00
|
|
|
DWORD dwTimeLastUpdate;
|
|
|
|
|
2004-01-17 21:34:54 +00:00
|
|
|
// Error message state
|
|
|
|
FLOAT xError;
|
|
|
|
FLOAT yError;
|
|
|
|
FLOAT widthError;
|
|
|
|
FLOAT heightError;
|
|
|
|
FLOAT xVelError;
|
|
|
|
FLOAT yVelError;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-04-12 02:28:50 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Name: struct INTERNALMONITORINFO
|
|
|
|
// Desc: Use the following structure rather than DISPLAY_DEVICE, since some
|
|
|
|
// old versions of DISPLAY_DEVICE are missing the last two fields and
|
|
|
|
// this can cause problems with EnumDisplayDevices on Windows 2000.
|
|
|
|
//-----------------------------------------------------------------------------
|
2004-01-17 21:34:54 +00:00
|
|
|
struct DISPLAY_DEVICE_FULL
|
|
|
|
{
|
|
|
|
DWORD cb;
|
|
|
|
TCHAR DeviceName[32];
|
|
|
|
TCHAR DeviceString[128];
|
|
|
|
DWORD StateFlags;
|
|
|
|
TCHAR DeviceID[128];
|
|
|
|
TCHAR DeviceKey[128];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-14 13:10:49 +00:00
|
|
|
struct ss_periods
|
|
|
|
{
|
|
|
|
double GFXDefaultPeriod;
|
|
|
|
double GFXSciencePeriod;
|
|
|
|
double GFXChangePeriod;
|
|
|
|
bool Show_default_ss_first;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-01-17 21:34:54 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Name: class CScreensaver
|
|
|
|
// Desc: Screensaver class
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class CScreensaver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CScreensaver();
|
|
|
|
|
|
|
|
virtual HRESULT Create( HINSTANCE hInstance );
|
2009-02-23 06:09:16 +00:00
|
|
|
virtual HRESULT Run();
|
|
|
|
virtual HRESULT Cleanup();
|
2004-01-17 21:34:54 +00:00
|
|
|
HRESULT DisplayErrorMsg( HRESULT hr );
|
|
|
|
|
|
|
|
|
2005-04-05 10:23:15 +00:00
|
|
|
//
|
|
|
|
// Infrastructure layer
|
|
|
|
//
|
2004-01-17 21:34:54 +00:00
|
|
|
protected:
|
|
|
|
SaverMode ParseCommandLine( TCHAR* pstrCommandLine );
|
|
|
|
VOID EnumMonitors( VOID );
|
2004-01-19 19:45:52 +00:00
|
|
|
|
2009-02-23 06:09:16 +00:00
|
|
|
BOOL UtilGetRegKey(LPCTSTR name, DWORD& keyval);
|
|
|
|
BOOL UtilSetRegKey(LPCTSTR name, DWORD value);
|
|
|
|
BOOL UtilGetRegDirectoryStr(LPCTSTR name, std::string& strDirectory);
|
2005-04-05 10:23:15 +00:00
|
|
|
|
|
|
|
BOOL CreateInfrastructureMutexes();
|
|
|
|
|
|
|
|
BOOL GetError( BOOL& bErrorMode, HRESULT& hrError, TCHAR* pszError, size_t iErrorSize );
|
|
|
|
BOOL SetError( BOOL bErrorMode, HRESULT hrError );
|
|
|
|
VOID UpdateErrorBoxText();
|
|
|
|
virtual BOOL GetTextForError( HRESULT hr, TCHAR* pszError, DWORD dwNumChars );
|
|
|
|
|
|
|
|
|
|
|
|
// Variables for non-fatal error management
|
|
|
|
HANDLE m_hErrorManagementMutex;
|
|
|
|
BOOL m_bErrorMode; // Whether to display an error
|
|
|
|
HRESULT m_hrError; // Error code to display
|
|
|
|
TCHAR m_szError[400]; // Error message text
|
2009-12-16 19:55:09 +00:00
|
|
|
|
|
|
|
// Variables for configuration management
|
2005-04-05 10:23:15 +00:00
|
|
|
DWORD m_dwBlankScreen;
|
|
|
|
DWORD m_dwBlankTime;
|
2009-12-16 19:55:09 +00:00
|
|
|
DWORD m_dwDefaultTime;
|
|
|
|
DWORD m_dwRunTime;
|
|
|
|
DWORD m_dwSwitchTime;
|
2009-02-23 06:09:16 +00:00
|
|
|
std::string m_strBOINCInstallDirectory;
|
|
|
|
std::string m_strBOINCDataDirectory;
|
2005-04-05 10:23:15 +00:00
|
|
|
|
|
|
|
//
|
2009-02-23 06:09:16 +00:00
|
|
|
// Input Activity Detection
|
|
|
|
//
|
|
|
|
protected:
|
|
|
|
BOOL CreateInputActivityThread();
|
|
|
|
BOOL DestroyInputActivityThread();
|
|
|
|
|
|
|
|
DWORD WINAPI InputActivityProc();
|
|
|
|
static DWORD WINAPI InputActivityProcStub( LPVOID lpParam );
|
|
|
|
|
|
|
|
HANDLE m_hInputActivityThread;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Graphics Window Promotion
|
|
|
|
//
|
|
|
|
protected:
|
|
|
|
BOOL CreateGraphicsWindowPromotionThread();
|
|
|
|
BOOL DestroyGraphicsWindowPromotionThread();
|
|
|
|
|
|
|
|
DWORD WINAPI GraphicsWindowPromotionProc();
|
|
|
|
static DWORD WINAPI GraphicsWindowPromotionProcStub( LPVOID lpParam );
|
|
|
|
|
|
|
|
HANDLE m_hGraphicsWindowPromotionThread;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Data Management Layer
|
2005-04-05 10:23:15 +00:00
|
|
|
//
|
|
|
|
protected:
|
|
|
|
BOOL CreateDataManagementThread();
|
2007-10-09 10:01:27 +00:00
|
|
|
BOOL DestroyDataManagementThread();
|
2005-04-05 10:23:15 +00:00
|
|
|
|
|
|
|
DWORD WINAPI DataManagementProc();
|
|
|
|
static DWORD WINAPI DataManagementProcStub( LPVOID lpParam );
|
2008-08-14 19:09:01 +00:00
|
|
|
|
2009-04-15 08:28:51 +00:00
|
|
|
int terminate_v6_screensaver(HANDLE& graphics_application);
|
2007-10-05 13:28:11 +00:00
|
|
|
int terminate_screensaver(HANDLE& graphics_application, RESULT *worker_app);
|
2009-04-02 10:25:16 +00:00
|
|
|
int terminate_default_screensaver(HANDLE& graphics_application);
|
2007-10-05 13:28:11 +00:00
|
|
|
int launch_screensaver(RESULT* rp, HANDLE& graphics_application);
|
2009-02-05 12:32:16 +00:00
|
|
|
int launch_default_screensaver(char *dir_path, HANDLE& graphics_application);
|
2007-10-05 13:28:11 +00:00
|
|
|
void HandleRPCError(void);
|
2009-12-14 13:10:49 +00:00
|
|
|
void GetDefaultDisplayPeriods(struct ss_periods &periods);
|
2009-02-20 11:49:49 +00:00
|
|
|
BOOL HasProcessExited(HANDLE pid_handle, int &exitCode);
|
2009-02-05 12:32:16 +00:00
|
|
|
|
2009-02-23 06:09:16 +00:00
|
|
|
// Determine if two RESULT pointers refer to the same task
|
2007-10-05 13:28:11 +00:00
|
|
|
bool is_same_task(RESULT* taska, RESULT* taskb);
|
2005-04-05 10:23:15 +00:00
|
|
|
|
2009-02-23 06:09:16 +00:00
|
|
|
// Count the number of active graphics-capable apps
|
2007-10-05 13:28:11 +00:00
|
|
|
int count_active_graphic_apps(RESULTS& results, RESULT* exclude = NULL);
|
|
|
|
|
2009-02-23 06:09:16 +00:00
|
|
|
// Choose a ramdom graphics application from the vector that
|
|
|
|
// was passed in.
|
2007-10-05 13:28:11 +00:00
|
|
|
RESULT* get_random_graphics_app(RESULTS& results, RESULT* exclude = NULL);
|
|
|
|
|
|
|
|
RPC_CLIENT* rpc;
|
2005-04-05 10:23:15 +00:00
|
|
|
CC_STATE state;
|
2007-08-14 17:23:30 +00:00
|
|
|
RESULTS results;
|
2007-09-26 10:17:43 +00:00
|
|
|
RESULT m_running_result;
|
2005-04-05 10:23:15 +00:00
|
|
|
|
|
|
|
HANDLE m_hDataManagementThread;
|
2007-08-14 17:23:30 +00:00
|
|
|
HANDLE m_hGraphicsApplication;
|
2005-04-05 10:23:15 +00:00
|
|
|
BOOL m_bResetCoreState;
|
2009-02-23 23:06:03 +00:00
|
|
|
bool m_QuitDataManagementProc;
|
2008-01-30 02:47:06 +00:00
|
|
|
bool m_bV5_GFX_app_is_running;
|
2007-10-02 21:44:14 +00:00
|
|
|
int m_iLastResultShown;
|
|
|
|
time_t m_tLastResultChangeTime;
|
2007-10-05 13:28:11 +00:00
|
|
|
time_t m_tThreadCreateTime;
|
2005-04-05 10:23:15 +00:00
|
|
|
|
2009-02-06 11:17:13 +00:00
|
|
|
double m_fGFXDefaultPeriod;
|
2009-12-14 13:10:49 +00:00
|
|
|
double m_fGFXSciencePeriod;
|
2009-02-06 11:17:13 +00:00
|
|
|
double m_fGFXChangePeriod;
|
2009-05-29 08:36:42 +00:00
|
|
|
bool m_bShow_default_ss_first;
|
2009-02-06 11:17:13 +00:00
|
|
|
|
2009-02-10 12:35:12 +00:00
|
|
|
bool m_bScience_gfx_running;
|
|
|
|
bool m_bDefault_gfx_running;
|
2009-02-20 11:49:49 +00:00
|
|
|
BOOL m_bConnected;
|
2009-02-10 12:35:12 +00:00
|
|
|
|
2005-04-05 10:23:15 +00:00
|
|
|
//
|
|
|
|
// Presentation layer
|
|
|
|
//
|
|
|
|
protected:
|
2004-01-19 19:45:52 +00:00
|
|
|
HRESULT CreateSaverWindow();
|
|
|
|
VOID UpdateErrorBox();
|
2009-04-02 19:04:10 +00:00
|
|
|
VOID FireInterruptSaverEvent();
|
2004-01-19 19:45:52 +00:00
|
|
|
VOID InterruptSaver();
|
|
|
|
VOID ShutdownSaver();
|
2004-01-17 21:34:54 +00:00
|
|
|
|
2009-04-02 19:04:10 +00:00
|
|
|
|
2004-01-17 21:34:54 +00:00
|
|
|
VOID DoConfig();
|
|
|
|
HRESULT DoSaver();
|
2006-07-25 10:19:27 +00:00
|
|
|
VOID DoPaint( HWND hwnd, HDC hdc, LPPAINTSTRUCT lpps );
|
2005-03-23 00:16:58 +00:00
|
|
|
LRESULT SaverProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
2009-12-16 19:55:09 +00:00
|
|
|
|
|
|
|
DWORD ConvertSliderPositionToTime( DWORD dwPosition );
|
|
|
|
DWORD ConvertTimeToSliderPosition( DWORD dwMinutes );
|
|
|
|
VOID InitializeDefaultSlider( HWND hwndDlg, UINT uControl );
|
|
|
|
DWORD GetSliderPosition( HWND hwndDlg, UINT uControl );
|
|
|
|
VOID SetSliderPosition( HWND hwndDlg, UINT uControl, DWORD dwPosition );
|
2005-01-13 01:52:56 +00:00
|
|
|
INT_PTR ConfigureDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
2004-01-17 21:34:54 +00:00
|
|
|
|
2005-03-23 00:16:58 +00:00
|
|
|
static LRESULT CALLBACK SaverProcStub( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
2004-01-17 21:34:54 +00:00
|
|
|
static INT_PTR CALLBACK ConfigureDialogProcStub( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
SaverMode m_SaverMode; // sm_config, sm_full, sm_preview, etc.
|
|
|
|
BOOL m_bAllScreensSame; // If TRUE, show same image on all screens
|
|
|
|
HWND m_hWnd; // Focus window and device window on primary
|
|
|
|
HWND m_hWndParent;
|
|
|
|
HINSTANCE m_hInstance;
|
|
|
|
BOOL m_bWaitForInputIdle; // Used to pause when preview starts
|
|
|
|
DWORD m_dwSaverMouseMoveCount;
|
|
|
|
BOOL m_bWindowed;
|
2009-02-06 02:17:45 +00:00
|
|
|
BOOL m_bDefault_ss_exists;
|
2004-01-17 21:34:54 +00:00
|
|
|
|
|
|
|
INTERNALMONITORINFO m_Monitors[MAX_DISPLAYS];
|
|
|
|
DWORD m_dwNumMonitors;
|
|
|
|
RECT m_rcRenderTotal; // Rect of entire area to be rendered
|
|
|
|
RECT m_rcRenderCurDevice; // Rect of render area of current device
|
|
|
|
BOOL m_bPaintingInitialized;
|
|
|
|
|
|
|
|
TCHAR m_strWindowTitle[200]; // Title for the app's window
|
2005-04-05 10:23:15 +00:00
|
|
|
|
2006-04-12 02:28:50 +00:00
|
|
|
DWORD m_dwLastInputTimeAtStartup;
|
2004-01-17 21:34:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|