2001-10-08 19:24:46 +00:00
|
|
|
#ifndef CXWINDOWSSECONDARYSCREEN_H
|
|
|
|
#define CXWINDOWSSECONDARYSCREEN_H
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
#include "CSecondaryScreen.h"
|
|
|
|
#include "IScreenEventHandler.h"
|
2002-06-01 19:26:11 +00:00
|
|
|
#include "stdmap.h"
|
|
|
|
#include "stdvector.h"
|
2002-07-13 22:00:38 +00:00
|
|
|
#if defined(X_DISPLAY_MISSING)
|
|
|
|
# error X11 is required to build synergy
|
|
|
|
#else
|
|
|
|
# include <X11/Xlib.h>
|
|
|
|
#endif
|
2001-10-08 19:24:46 +00:00
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
class CXWindowsScreen;
|
2002-07-10 21:22:28 +00:00
|
|
|
class IScreenReceiver;
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
class CXWindowsSecondaryScreen :
|
|
|
|
public CSecondaryScreen, public IScreenEventHandler {
|
2002-04-29 14:40:01 +00:00
|
|
|
public:
|
2002-07-10 21:22:28 +00:00
|
|
|
CXWindowsSecondaryScreen(IScreenReceiver*);
|
2001-10-08 19:24:46 +00:00
|
|
|
virtual ~CXWindowsSecondaryScreen();
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
// CSecondaryScreen overrides
|
2001-10-25 21:40:29 +00:00
|
|
|
virtual void keyDown(KeyID, KeyModifierMask);
|
|
|
|
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count);
|
|
|
|
virtual void keyUp(KeyID, KeyModifierMask);
|
|
|
|
virtual void mouseDown(ButtonID);
|
|
|
|
virtual void mouseUp(ButtonID);
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void mouseMove(SInt32 x, SInt32 y);
|
2001-10-25 21:40:29 +00:00
|
|
|
virtual void mouseWheel(SInt32 delta);
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual IScreen* getScreen() const;
|
2001-10-08 19:24:46 +00:00
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
// IScreenEventHandler overrides
|
|
|
|
virtual void onError();
|
|
|
|
virtual void onScreensaver(bool activated);
|
2002-07-12 20:41:23 +00:00
|
|
|
virtual bool onPreDispatch(const CEvent* event);
|
|
|
|
virtual bool onEvent(CEvent* event);
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual SInt32 getJumpZoneSize() const;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// CSecondaryScreen overrides
|
|
|
|
virtual void onPreRun();
|
|
|
|
virtual void onPreOpen();
|
|
|
|
virtual void onPostOpen();
|
|
|
|
virtual void onPreEnter();
|
|
|
|
virtual void onPreLeave();
|
|
|
|
virtual void createWindow();
|
|
|
|
virtual void destroyWindow();
|
|
|
|
virtual void showWindow();
|
|
|
|
virtual void hideWindow();
|
|
|
|
virtual void warpCursor(SInt32 x, SInt32 y);
|
|
|
|
virtual void updateKeys();
|
|
|
|
virtual void setToggleState(KeyModifierMask);
|
2001-11-11 21:15:30 +00:00
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2002-05-03 11:26:44 +00:00
|
|
|
enum EKeyAction { kPress, kRelease, kRepeat };
|
|
|
|
class KeyCodeMask {
|
2002-04-26 17:38:01 +00:00
|
|
|
public:
|
2002-05-03 11:26:44 +00:00
|
|
|
KeyCode m_keycode;
|
|
|
|
unsigned int m_keyMask;
|
|
|
|
unsigned int m_keyMaskMask;
|
|
|
|
};
|
|
|
|
class Keystroke {
|
|
|
|
public:
|
|
|
|
KeyCode m_keycode;
|
|
|
|
Bool m_press;
|
|
|
|
bool m_repeat;
|
2002-04-26 17:38:01 +00:00
|
|
|
};
|
|
|
|
typedef std::vector<Keystroke> Keystrokes;
|
|
|
|
typedef std::vector<KeyCode> KeyCodes;
|
|
|
|
typedef std::map<KeyID, KeyCodeMask> KeyCodeMap;
|
|
|
|
typedef std::map<KeyCode, unsigned int> ModifierMap;
|
|
|
|
|
2001-10-08 19:24:46 +00:00
|
|
|
unsigned int mapButton(ButtonID button) const;
|
|
|
|
|
2002-04-26 17:38:01 +00:00
|
|
|
unsigned int mapKey(Keystrokes&, KeyCode&, KeyID,
|
2002-06-10 22:06:45 +00:00
|
|
|
KeyModifierMask, EKeyAction) const;
|
2002-04-26 17:38:01 +00:00
|
|
|
bool findKeyCode(KeyCode&, unsigned int&,
|
2002-06-10 22:06:45 +00:00
|
|
|
KeyID id, unsigned int) const;
|
2002-05-03 11:26:44 +00:00
|
|
|
void doKeystrokes(const Keystrokes&, SInt32 count);
|
2002-04-26 17:38:01 +00:00
|
|
|
unsigned int maskToX(KeyModifierMask) const;
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
void releaseKeys(Display*);
|
2002-04-26 17:38:01 +00:00
|
|
|
void updateKeycodeMap(Display* display);
|
|
|
|
void updateModifiers(Display* display);
|
|
|
|
void updateModifierMap(Display* display);
|
2002-04-30 17:48:11 +00:00
|
|
|
void toggleKey(Display*, KeySym, unsigned int mask);
|
2002-04-26 17:38:01 +00:00
|
|
|
static bool isToggleKeysym(KeySym);
|
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2002-07-13 22:00:38 +00:00
|
|
|
CXWindowsScreen* m_screen;
|
2001-10-08 19:24:46 +00:00
|
|
|
Window m_window;
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2002-05-04 18:31:54 +00:00
|
|
|
// note toggle keys that toggles on up/down (false) or on
|
2002-04-30 16:25:29 +00:00
|
|
|
// transition (true)
|
2002-05-04 18:31:54 +00:00
|
|
|
bool m_numLockHalfDuplex;
|
2002-04-30 16:25:29 +00:00
|
|
|
bool m_capsLockHalfDuplex;
|
|
|
|
|
2002-04-26 17:38:01 +00:00
|
|
|
// set entries indicate keys that are pressed. indexed by keycode.
|
|
|
|
bool m_keys[256];
|
|
|
|
|
|
|
|
// current active modifiers (X key masks)
|
|
|
|
unsigned int m_mask;
|
|
|
|
|
|
|
|
// maps key IDs to X keycodes and the X modifier key mask needed
|
|
|
|
// to generate the right keysym
|
|
|
|
KeyCodeMap m_keycodeMap;
|
|
|
|
|
|
|
|
// the modifiers that have keys bound to them
|
|
|
|
unsigned int m_modifierMask;
|
|
|
|
|
|
|
|
// set bits indicate modifiers that toggle (e.g. caps-lock)
|
|
|
|
unsigned int m_toggleModifierMask;
|
|
|
|
|
2002-04-30 17:48:11 +00:00
|
|
|
// masks that indicate which modifier bits are for toggle keys
|
2002-04-26 17:38:01 +00:00
|
|
|
unsigned int m_numLockMask;
|
|
|
|
unsigned int m_capsLockMask;
|
2002-04-30 17:48:11 +00:00
|
|
|
unsigned int m_scrollLockMask;
|
2002-04-26 17:38:01 +00:00
|
|
|
|
|
|
|
// map X modifier key indices to the key codes bound to them
|
|
|
|
unsigned int m_keysPerModifier;
|
|
|
|
KeyCodes m_modifierToKeycode;
|
|
|
|
|
|
|
|
// maps keycodes to modifier indices
|
|
|
|
ModifierMap m_keycodeToModifier;
|
2001-10-08 19:24:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|