1 | /*
|
---|
2 | * synergy -- mouse and keyboard sharing utility
|
---|
3 | * Copyright (C) 2002 Chris Schoeneman
|
---|
4 | *
|
---|
5 | * This package is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU General Public License
|
---|
7 | * found in the file COPYING that should have accompanied this file.
|
---|
8 | *
|
---|
9 | * This package is distributed in the hope that it will be useful,
|
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | * GNU General Public License for more details.
|
---|
13 | */
|
---|
14 |
|
---|
15 | #ifndef CMSWINDOWSSCREENSAVER_H
|
---|
16 | #define CMSWINDOWSSCREENSAVER_H
|
---|
17 |
|
---|
18 | #include "IScreenSaver.h"
|
---|
19 | #include "CString.h"
|
---|
20 | #define WIN32_LEAN_AND_MEAN
|
---|
21 | #include <windows.h>
|
---|
22 |
|
---|
23 | class CThread;
|
---|
24 |
|
---|
25 | //! Microsoft windows screen saver implementation
|
---|
26 | class CMSWindowsScreenSaver : public IScreenSaver {
|
---|
27 | public:
|
---|
28 | CMSWindowsScreenSaver();
|
---|
29 | virtual ~CMSWindowsScreenSaver();
|
---|
30 |
|
---|
31 | //! @name manipulators
|
---|
32 | //@{
|
---|
33 |
|
---|
34 | //! Check if screen saver started
|
---|
35 | /*!
|
---|
36 | Check if the screen saver really started. Returns false if it
|
---|
37 | hasn't, true otherwise. When the screen saver stops, \c msg will
|
---|
38 | be posted to the current thread's message queue with the given
|
---|
39 | parameters.
|
---|
40 | */
|
---|
41 | bool checkStarted(UINT msg, WPARAM, LPARAM);
|
---|
42 |
|
---|
43 | //@}
|
---|
44 |
|
---|
45 | // IScreenSaver overrides
|
---|
46 | virtual void enable();
|
---|
47 | virtual void disable();
|
---|
48 | virtual void activate();
|
---|
49 | virtual void deactivate();
|
---|
50 | virtual bool isActive() const;
|
---|
51 |
|
---|
52 | private:
|
---|
53 | class CFindScreenSaverInfo {
|
---|
54 | public:
|
---|
55 | HDESK m_desktop;
|
---|
56 | HWND m_window;
|
---|
57 | };
|
---|
58 |
|
---|
59 | static BOOL CALLBACK findScreenSaverFunc(HWND hwnd, LPARAM lParam);
|
---|
60 | static BOOL CALLBACK killScreenSaverFunc(HWND hwnd, LPARAM lParam);
|
---|
61 |
|
---|
62 | DWORD findScreenSaver();
|
---|
63 | void watchDesktop();
|
---|
64 | void watchProcess(HANDLE process);
|
---|
65 | void unwatchProcess();
|
---|
66 | void watchDesktopThread(void*);
|
---|
67 | void watchProcessThread(void*);
|
---|
68 |
|
---|
69 | void setSecure(bool secure, bool saveSecureAsInt);
|
---|
70 | bool isSecure(bool* wasSecureAnInt) const;
|
---|
71 |
|
---|
72 | private:
|
---|
73 | bool m_is95Family;
|
---|
74 | bool m_is95;
|
---|
75 | bool m_isNT;
|
---|
76 | BOOL m_wasEnabled;
|
---|
77 | bool m_wasSecure;
|
---|
78 | bool m_wasSecureAnInt;
|
---|
79 |
|
---|
80 | HANDLE m_process;
|
---|
81 | CThread* m_watch;
|
---|
82 | DWORD m_threadID;
|
---|
83 | UINT m_msg;
|
---|
84 | WPARAM m_wParam;
|
---|
85 | LPARAM m_lParam;
|
---|
86 |
|
---|
87 | // checkActive state. true if the screen saver is being watched
|
---|
88 | // for deactivation (and is therefore active).
|
---|
89 | bool m_active;
|
---|
90 | };
|
---|
91 |
|
---|
92 | #endif
|
---|