2002-08-02 19:57:46 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2001-11-19 00:33:36 +00:00
|
|
|
#ifndef CMSWINDOWSSECONDARYSCREEN_H
|
|
|
|
#define CMSWINDOWSSECONDARYSCREEN_H
|
|
|
|
|
2002-06-20 11:13:37 +00:00
|
|
|
// ensure that we get SendInput()
|
|
|
|
#if _WIN32_WINNT <= 0x400
|
|
|
|
#undef _WIN32_WINNT
|
|
|
|
#define _WIN32_WINNT 0x401
|
|
|
|
#endif
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
#include "CSecondaryScreen.h"
|
|
|
|
#include "IMSWindowsScreenEventHandler.h"
|
2002-06-08 21:48:00 +00:00
|
|
|
#include "CMutex.h"
|
|
|
|
#include "CString.h"
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
class CMSWindowsScreen;
|
2002-07-11 13:13:37 +00:00
|
|
|
class IScreenReceiver;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Microsoft windows secondary screen implementation
|
2002-07-15 15:01:36 +00:00
|
|
|
class CMSWindowsSecondaryScreen :
|
|
|
|
public CSecondaryScreen, public IMSWindowsScreenEventHandler {
|
2002-04-29 14:40:01 +00:00
|
|
|
public:
|
2002-07-11 13:13:37 +00:00
|
|
|
CMSWindowsSecondaryScreen(IScreenReceiver*);
|
2001-11-19 00:33:36 +00:00
|
|
|
virtual ~CMSWindowsSecondaryScreen();
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// CSecondaryScreen overrides
|
|
|
|
virtual IScreen* getScreen() const;
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// IMSWindowsScreenEventHandler overrides
|
|
|
|
virtual void onScreensaver(bool activated);
|
2002-07-12 20:41:23 +00:00
|
|
|
virtual bool onPreDispatch(const CEvent* event);
|
|
|
|
virtual bool onEvent(CEvent* event);
|
2003-03-12 22:34:07 +00:00
|
|
|
virtual void onOneShotTimerExpired(UInt32 id);
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual void postCreateWindow(HWND);
|
|
|
|
virtual void preDestroyWindow(HWND);
|
2003-05-17 20:58:27 +00:00
|
|
|
virtual void onAccessibleDesktop();
|
2002-07-15 15:01:36 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// CSecondaryScreen overrides
|
2002-07-30 15:17:44 +00:00
|
|
|
virtual void onPreMainLoop();
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual void onPreOpen();
|
|
|
|
virtual void onPreEnter();
|
|
|
|
virtual void onPreLeave();
|
|
|
|
virtual void createWindow();
|
|
|
|
virtual void destroyWindow();
|
2003-05-03 13:50:06 +00:00
|
|
|
virtual void showWindow(SInt32 x, SInt32 y);
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual void hideWindow();
|
2003-07-26 13:41:41 +00:00
|
|
|
virtual void updateKeys(KeyState* sysKeyStates);
|
|
|
|
virtual KeyModifierMask getModifiers() const;
|
|
|
|
|
|
|
|
virtual SysKeyID getUnhanded(SysKeyID) const;
|
|
|
|
virtual SysKeyID getOtherHanded(SysKeyID) const;
|
|
|
|
virtual bool isAutoRepeating(SysKeyID) const;
|
|
|
|
virtual KeyModifierMask getModifierKeyMask(SysKeyID) const;
|
|
|
|
virtual bool isModifierActive(SysKeyID) const;
|
|
|
|
virtual SysKeyID getToggleSysKey(KeyID keyID) const;
|
|
|
|
virtual bool synthesizeCtrlAltDel(EKeyAction);
|
|
|
|
virtual void sync() const;
|
|
|
|
virtual KeyModifierMask
|
|
|
|
mapKey(Keystrokes&, SysKeyID& sysKeyID, KeyID,
|
|
|
|
KeyModifierMask, KeyModifierMask, EKeyAction) const;
|
|
|
|
virtual void fakeKeyEvent(SysKeyID, bool press) const;
|
|
|
|
virtual void fakeMouseButton(ButtonID, bool press) const;
|
|
|
|
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
|
|
|
|
virtual void fakeMouseWheel(SInt32 delta) const;
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2003-07-05 17:04:26 +00:00
|
|
|
class CModifierInfo {
|
|
|
|
public:
|
|
|
|
KeyModifierMask m_mask;
|
|
|
|
UINT m_virtualKey;
|
|
|
|
UINT m_virtualKey2;
|
|
|
|
bool m_isToggle;
|
|
|
|
};
|
2002-06-08 21:48:00 +00:00
|
|
|
|
|
|
|
// open/close desktop (for windows 95/98/me)
|
|
|
|
bool openDesktop();
|
|
|
|
void closeDesktop();
|
|
|
|
|
|
|
|
// make desk the thread desktop (for windows NT/2000/XP)
|
|
|
|
bool switchDesktop(HDESK desk);
|
|
|
|
|
2002-06-20 11:13:37 +00:00
|
|
|
// returns true iff there appear to be multiple monitors
|
|
|
|
bool isMultimon() const;
|
|
|
|
|
2002-06-08 21:48:00 +00:00
|
|
|
// key and button queries and operations
|
2003-05-04 21:40:42 +00:00
|
|
|
DWORD mapButton(ButtonID button,
|
|
|
|
bool press, DWORD* data) const;
|
2003-05-20 19:15:58 +00:00
|
|
|
UINT mapCharacter(Keystrokes& keys,
|
|
|
|
char c, HKL hkl,
|
|
|
|
KeyModifierMask currentMask,
|
|
|
|
KeyModifierMask desiredMask,
|
|
|
|
EKeyAction action) const;
|
|
|
|
KeyModifierMask mapToKeystrokes(Keystrokes& keys,
|
|
|
|
UINT virtualKey,
|
|
|
|
KeyModifierMask currentMask,
|
|
|
|
KeyModifierMask desiredMask,
|
|
|
|
EKeyAction action) const;
|
2003-07-05 17:04:26 +00:00
|
|
|
const CModifierInfo* getModifierInfo(UINT virtualKey) const;
|
2002-04-30 16:23:03 +00:00
|
|
|
|
2003-07-26 13:41:41 +00:00
|
|
|
KeyState getKeyState(UINT virtualKey) const;
|
2002-08-18 17:35:10 +00:00
|
|
|
UINT virtualKeyToScanCode(UINT& virtualKey) const;
|
|
|
|
bool isExtendedKey(UINT virtualKey) const;
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2003-05-20 19:15:58 +00:00
|
|
|
UINT getCodePageFromLangID(LANGID) const;
|
|
|
|
|
2003-06-08 22:12:12 +00:00
|
|
|
// thread that generates fake ctrl+alt+del
|
|
|
|
static void ctrlAltDelThread(void*);
|
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2002-06-08 21:48:00 +00:00
|
|
|
CMutex m_mutex;
|
2002-07-15 15:01:36 +00:00
|
|
|
CMSWindowsScreen* m_screen;
|
2002-06-08 21:48:00 +00:00
|
|
|
|
|
|
|
// true if windows 95/98/me
|
|
|
|
bool m_is95Family;
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// our window
|
2001-11-19 00:33:36 +00:00
|
|
|
HWND m_window;
|
2002-06-08 21:48:00 +00:00
|
|
|
|
2003-07-05 17:04:26 +00:00
|
|
|
// modifier table
|
|
|
|
static const CModifierInfo s_modifier[];
|
2001-11-19 00:33:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|