2002-08-02 23:57:46 +04: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 03:33:36 +03:00
|
|
|
#ifndef CMSWINDOWSSECONDARYSCREEN_H
|
|
|
|
#define CMSWINDOWSSECONDARYSCREEN_H
|
|
|
|
|
2002-06-20 15:13:37 +04:00
|
|
|
// ensure that we get SendInput()
|
|
|
|
#if _WIN32_WINNT <= 0x400
|
|
|
|
#undef _WIN32_WINNT
|
|
|
|
#define _WIN32_WINNT 0x401
|
|
|
|
#endif
|
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
#include "CSecondaryScreen.h"
|
|
|
|
#include "IMSWindowsScreenEventHandler.h"
|
2002-06-09 01:48:00 +04:00
|
|
|
#include "CMutex.h"
|
|
|
|
#include "CString.h"
|
2003-04-27 22:05:32 +04:00
|
|
|
#include "stdmap.h"
|
2002-06-01 23:26:11 +04:00
|
|
|
#include "stdvector.h"
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
class CMSWindowsScreen;
|
2002-07-11 17:13:37 +04:00
|
|
|
class IScreenReceiver;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Microsoft windows secondary screen implementation
|
2002-07-15 19:01:36 +04:00
|
|
|
class CMSWindowsSecondaryScreen :
|
|
|
|
public CSecondaryScreen, public IMSWindowsScreenEventHandler {
|
2002-04-29 18:40:01 +04:00
|
|
|
public:
|
2002-07-11 17:13:37 +04:00
|
|
|
CMSWindowsSecondaryScreen(IScreenReceiver*);
|
2001-11-19 03:33:36 +03:00
|
|
|
virtual ~CMSWindowsSecondaryScreen();
|
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// CSecondaryScreen overrides
|
2003-04-27 21:01:14 +04:00
|
|
|
virtual void keyDown(KeyID, KeyModifierMask, KeyButton);
|
|
|
|
virtual void keyRepeat(KeyID, KeyModifierMask,
|
|
|
|
SInt32 count, KeyButton);
|
|
|
|
virtual void keyUp(KeyID, KeyModifierMask, KeyButton);
|
2001-11-19 03:33:36 +03:00
|
|
|
virtual void mouseDown(ButtonID);
|
|
|
|
virtual void mouseUp(ButtonID);
|
|
|
|
virtual void mouseMove(SInt32 xAbsolute, SInt32 yAbsolute);
|
|
|
|
virtual void mouseWheel(SInt32 delta);
|
2002-12-23 16:55:21 +03:00
|
|
|
virtual void resetOptions();
|
|
|
|
virtual void setOptions(const COptionsList& options);
|
2002-07-15 19:01:36 +04:00
|
|
|
virtual IScreen* getScreen() const;
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// IMSWindowsScreenEventHandler overrides
|
|
|
|
virtual void onScreensaver(bool activated);
|
2002-07-13 00:41:23 +04:00
|
|
|
virtual bool onPreDispatch(const CEvent* event);
|
|
|
|
virtual bool onEvent(CEvent* event);
|
2003-03-13 01:34:07 +03:00
|
|
|
virtual void onOneShotTimerExpired(UInt32 id);
|
2002-07-15 19:01:36 +04:00
|
|
|
virtual SInt32 getJumpZoneSize() const;
|
|
|
|
virtual void postCreateWindow(HWND);
|
|
|
|
virtual void preDestroyWindow(HWND);
|
2003-05-18 00:58:27 +04:00
|
|
|
virtual void onAccessibleDesktop();
|
2002-07-15 19:01:36 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// CSecondaryScreen overrides
|
2002-07-30 19:17:44 +04:00
|
|
|
virtual void onPreMainLoop();
|
2002-07-15 19:01:36 +04:00
|
|
|
virtual void onPreOpen();
|
|
|
|
virtual void onPreEnter();
|
|
|
|
virtual void onPreLeave();
|
|
|
|
virtual void createWindow();
|
|
|
|
virtual void destroyWindow();
|
2003-05-03 17:50:06 +04:00
|
|
|
virtual void showWindow(SInt32 x, SInt32 y);
|
2002-07-15 19:01:36 +04:00
|
|
|
virtual void hideWindow();
|
|
|
|
virtual void warpCursor(SInt32 x, SInt32 y);
|
|
|
|
virtual void updateKeys();
|
2003-03-13 01:34:07 +03:00
|
|
|
virtual void releaseKeys();
|
2002-07-15 19:01:36 +04:00
|
|
|
virtual void setToggleState(KeyModifierMask);
|
2002-12-16 01:14:49 +03:00
|
|
|
virtual KeyModifierMask getToggleState() const;
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
private:
|
2002-05-04 22:08:22 +04:00
|
|
|
enum EKeyAction { kPress, kRelease, kRepeat };
|
|
|
|
class Keystroke {
|
|
|
|
public:
|
|
|
|
UINT m_virtualKey;
|
|
|
|
bool m_press;
|
|
|
|
bool m_repeat;
|
|
|
|
};
|
2002-04-30 20:23:03 +04:00
|
|
|
typedef std::vector<Keystroke> Keystrokes;
|
2003-04-27 21:01:14 +04:00
|
|
|
typedef std::map<KeyButton, UINT> ServerKeyMap;
|
2002-06-09 01:48:00 +04: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 15:13:37 +04:00
|
|
|
// returns true iff there appear to be multiple monitors
|
|
|
|
bool isMultimon() const;
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// key and button queries and operations
|
2003-05-05 01:40:42 +04:00
|
|
|
DWORD mapButton(ButtonID button,
|
|
|
|
bool press, DWORD* data) const;
|
2002-04-30 20:23:03 +04:00
|
|
|
KeyModifierMask mapKey(Keystrokes&, UINT& virtualKey, KeyID,
|
2002-06-11 02:06:45 +04:00
|
|
|
KeyModifierMask, EKeyAction) const;
|
2003-05-20 23:15:58 +04: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;
|
2002-05-04 22:08:22 +04:00
|
|
|
void doKeystrokes(const Keystrokes&, SInt32 count);
|
2002-04-30 20:23:03 +04:00
|
|
|
|
2002-04-30 21:48:11 +04:00
|
|
|
void toggleKey(UINT virtualKey, KeyModifierMask mask);
|
2002-08-18 21:35:10 +04:00
|
|
|
UINT virtualKeyToScanCode(UINT& virtualKey) const;
|
|
|
|
bool isExtendedKey(UINT virtualKey) const;
|
2002-05-22 21:01:17 +04:00
|
|
|
void sendKeyEvent(UINT virtualKey, bool press);
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2003-05-20 23:15:58 +04:00
|
|
|
UINT getCodePageFromLangID(LANGID) const;
|
|
|
|
|
2003-06-09 02:12:12 +04:00
|
|
|
// generate a fake ctrl+alt+del
|
|
|
|
void synthesizeCtrlAltDel();
|
|
|
|
|
|
|
|
// thread that generates fake ctrl+alt+del
|
|
|
|
static void ctrlAltDelThread(void*);
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
private:
|
2002-06-09 01:48:00 +04:00
|
|
|
CMutex m_mutex;
|
2002-07-15 19:01:36 +04:00
|
|
|
CMSWindowsScreen* m_screen;
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// true if windows 95/98/me
|
|
|
|
bool m_is95Family;
|
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// our window
|
2001-11-19 03:33:36 +03:00
|
|
|
HWND m_window;
|
2002-06-09 01:48:00 +04:00
|
|
|
|
2003-03-16 20:40:56 +03:00
|
|
|
// virtual key states as set by us or the user
|
2002-04-30 20:23:03 +04:00
|
|
|
BYTE m_keys[256];
|
|
|
|
|
2003-03-16 20:40:56 +03:00
|
|
|
// virtual key states as set by us
|
|
|
|
BYTE m_fakeKeys[256];
|
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// current active modifiers
|
|
|
|
KeyModifierMask m_mask;
|
2003-04-27 21:01:14 +04:00
|
|
|
|
|
|
|
// map server key buttons to local virtual keys
|
|
|
|
ServerKeyMap m_serverKeyMap;
|
2001-11-19 03:33:36 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|