2001-11-19 03:33:36 +03:00
|
|
|
#ifndef CMSWINDOWSSCREEN_H
|
|
|
|
#define CMSWINDOWSSCREEN_H
|
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
#include "IScreen.h"
|
|
|
|
#include "CSynergyHook.h"
|
2002-06-11 02:06:45 +04:00
|
|
|
#include "CMutex.h"
|
2002-06-12 00:09:59 +04:00
|
|
|
#include "CString.h"
|
2002-06-10 20:49:46 +04:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2001-11-19 03:33:36 +03:00
|
|
|
#include <windows.h>
|
|
|
|
|
2002-06-24 01:53:31 +04:00
|
|
|
class CMSWindowsScreenSaver;
|
2001-11-19 03:33:36 +03:00
|
|
|
class CThread;
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
class CEvent {
|
|
|
|
public:
|
|
|
|
MSG m_msg;
|
|
|
|
LRESULT m_result;
|
|
|
|
};
|
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
class IScreenReceiver;
|
|
|
|
class IMSWindowsScreenEventHandler;
|
|
|
|
|
|
|
|
class CMSWindowsScreen : public IScreen {
|
2002-04-29 18:40:01 +04:00
|
|
|
public:
|
2002-07-15 19:01:36 +04:00
|
|
|
CMSWindowsScreen(IScreenReceiver*, IMSWindowsScreenEventHandler*);
|
2001-11-19 03:33:36 +03:00
|
|
|
virtual ~CMSWindowsScreen();
|
|
|
|
|
|
|
|
// manipulators
|
|
|
|
|
|
|
|
static void init(HINSTANCE);
|
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// open the desktop and create and return the window. returns NULL
|
|
|
|
// on failure.
|
|
|
|
HWND openDesktop();
|
|
|
|
|
|
|
|
// close the window and desktop
|
|
|
|
void closeDesktop();
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// accessors
|
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// returns true iff the system appears to have multiple monitors
|
|
|
|
bool isMultimon() const;
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// get the application instance handle
|
|
|
|
static HINSTANCE getInstance();
|
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// IScreen overrides
|
|
|
|
// note -- this class expects the hook DLL to have been loaded
|
|
|
|
// and initialized before open() is called.
|
|
|
|
void open();
|
2002-07-13 00:41:23 +04:00
|
|
|
void mainLoop();
|
|
|
|
void exitMainLoop();
|
2002-07-15 19:01:36 +04:00
|
|
|
void close();
|
|
|
|
bool setClipboard(ClipboardID, const IClipboard*);
|
|
|
|
void checkClipboards();
|
|
|
|
void openScreensaver(bool notify);
|
|
|
|
void closeScreensaver();
|
|
|
|
void screensaver(bool activate);
|
|
|
|
void syncDesktop();
|
|
|
|
bool getClipboard(ClipboardID, IClipboard*) const;
|
|
|
|
void getShape(SInt32&, SInt32&, SInt32&, SInt32&) const;
|
|
|
|
void getCursorPos(SInt32&, SInt32&) const;
|
|
|
|
void getCursorCenter(SInt32&, SInt32&) const;
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
private:
|
2002-05-24 21:54:28 +04:00
|
|
|
// update screen size cache
|
2002-06-19 21:03:29 +04:00
|
|
|
void updateScreenShape();
|
2002-05-24 21:54:28 +04:00
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// internal pre-dispatch event processing
|
|
|
|
bool onPreDispatch(const CEvent* event);
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// internal (post-dispatch) event processing
|
|
|
|
bool onEvent(CEvent* event);
|
2002-07-11 22:58:49 +04:00
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// create the transparent cursor
|
|
|
|
void createBlankCursor();
|
|
|
|
|
|
|
|
// switch to the given desktop. this destroys the window and unhooks
|
|
|
|
// all hooks, switches the desktop, then creates the window and rehooks
|
|
|
|
// all hooks (because you can't switch the thread's desktop if it has
|
|
|
|
// any windows or hooks).
|
|
|
|
bool switchDesktop(HDESK desk);
|
2002-07-11 22:58:49 +04:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// get the input desktop. caller must CloseDesktop() the result.
|
|
|
|
// do not call under windows 95/98/me.
|
|
|
|
HDESK openInputDesktop() const;
|
|
|
|
|
|
|
|
// get the desktop's name. do not call under windows 95/98/me.
|
|
|
|
CString getDesktopName(HDESK) const;
|
|
|
|
|
|
|
|
// returns true iff desk is the current desk. do not call under
|
|
|
|
// windows 95/98/me.
|
|
|
|
bool isCurrentDesktop(HDESK desk) const;
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
// our window proc
|
2001-11-19 03:33:36 +03:00
|
|
|
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
private:
|
2001-11-19 03:33:36 +03:00
|
|
|
static HINSTANCE s_instance;
|
2002-07-15 19:01:36 +04:00
|
|
|
|
|
|
|
IScreenReceiver* m_receiver;
|
|
|
|
IMSWindowsScreenEventHandler* m_eventHandler;
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
ATOM m_class;
|
|
|
|
HICON m_icon;
|
|
|
|
HCURSOR m_cursor;
|
2002-07-15 19:01:36 +04:00
|
|
|
|
|
|
|
// true if windows 95/98/me
|
|
|
|
bool m_is95Family;
|
|
|
|
|
|
|
|
// our window
|
|
|
|
HWND m_window;
|
|
|
|
|
|
|
|
// screen shape
|
2002-06-19 21:03:29 +04:00
|
|
|
SInt32 m_x, m_y;
|
2001-11-19 03:33:36 +03:00
|
|
|
SInt32 m_w, m_h;
|
2002-07-15 19:01:36 +04:00
|
|
|
|
|
|
|
// true if system appears to have multiple monitors
|
|
|
|
bool m_multimon;
|
|
|
|
|
|
|
|
// the main loop's thread id
|
|
|
|
DWORD m_threadID;
|
|
|
|
|
|
|
|
// the thread id of the last attached thread
|
|
|
|
DWORD m_lastThreadID;
|
|
|
|
|
|
|
|
// clipboard stuff
|
|
|
|
HWND m_nextClipboardWindow;
|
|
|
|
HWND m_clipboardOwner;
|
|
|
|
|
|
|
|
// the timer used to check for desktop switching
|
|
|
|
UINT m_timer;
|
|
|
|
|
|
|
|
// the current desk and it's name
|
|
|
|
HDESK m_desk;
|
|
|
|
CString m_deskName;
|
|
|
|
|
|
|
|
// screen saver stuff
|
|
|
|
HINSTANCE m_hookLibrary;
|
|
|
|
InstallScreenSaverFunc m_installScreensaver;
|
|
|
|
UninstallScreenSaverFunc m_uninstallScreensaver;
|
|
|
|
CMSWindowsScreenSaver* m_screensaver;
|
|
|
|
bool m_screensaverNotify;
|
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
static CMSWindowsScreen* s_screen;
|
2001-11-19 03:33:36 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|