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-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-30 14:59:36 +00:00
|
|
|
//! X11 secondary screen implementation
|
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
|
2002-12-23 13:55:21 +00:00
|
|
|
virtual void resetOptions();
|
|
|
|
virtual void setOptions(const COptionsList& options);
|
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 onScreensaver(bool activated);
|
2002-07-12 20:41:23 +00:00
|
|
|
virtual bool onPreDispatch(const CEvent* event);
|
|
|
|
virtual bool onEvent(CEvent* event);
|
2003-02-22 21:53:25 +00:00
|
|
|
virtual void onOneShotTimerExpired(UInt32 id);
|
2002-07-13 22:00:38 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// CSecondaryScreen overrides
|
2002-07-30 15:17:44 +00:00
|
|
|
virtual void onPreMainLoop();
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void onPreOpen();
|
|
|
|
virtual void onPostOpen();
|
2003-05-03 13:57:52 +00:00
|
|
|
virtual void onPreClose();
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void onPreEnter();
|
2003-05-03 13:28:21 +00:00
|
|
|
virtual void onPostEnter();
|
2002-07-13 22:00:38 +00:00
|
|
|
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-13 22:00:38 +00:00
|
|
|
virtual void hideWindow();
|
2003-07-26 13:41:41 +00:00
|
|
|
virtual void updateKeys(KeyState* sysKeyStates);
|
|
|
|
virtual KeyModifierMask getModifiers() const;
|
|
|
|
|
|
|
|
virtual bool isAutoRepeating(SysKeyID) const;
|
|
|
|
virtual KeyModifierMask getModifierKeyMask(SysKeyID) const;
|
|
|
|
virtual bool isModifierActive(SysKeyID) const;
|
|
|
|
virtual SysKeyID getToggleSysKey(KeyID keyID) const;
|
|
|
|
virtual void flush();
|
|
|
|
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-11 21:15:30 +00:00
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2003-07-01 19:35:28 +00:00
|
|
|
typedef unsigned int ModifierIndex;
|
|
|
|
class KeyMapping {
|
|
|
|
public:
|
|
|
|
KeyMapping();
|
|
|
|
|
|
|
|
public:
|
|
|
|
// KeyCode to generate keysym and whether keycode[i] is
|
|
|
|
// sensitive to shift and mode switch.
|
|
|
|
KeyCode m_keycode[4];
|
|
|
|
bool m_shiftSensitive[4];
|
|
|
|
bool m_modeSwitchSensitive[4];
|
|
|
|
|
|
|
|
// the modifier mask of keysym or 0 if not a modifier
|
2003-07-26 13:41:41 +00:00
|
|
|
KeyModifierMask m_modifierMask;
|
2003-07-01 19:35:28 +00:00
|
|
|
|
|
|
|
// whether keysym is sensitive to caps and num lock
|
|
|
|
bool m_numLockSensitive;
|
|
|
|
bool m_capsLockSensitive;
|
|
|
|
};
|
|
|
|
|
2002-04-26 17:38:01 +00:00
|
|
|
typedef std::vector<KeyCode> KeyCodes;
|
2003-07-01 19:35:28 +00:00
|
|
|
typedef std::map<KeyCode, ModifierIndex> KeyCodeToModifierMap;
|
|
|
|
typedef std::map<KeySym, KeyMapping> KeySymMap;
|
|
|
|
typedef KeySymMap::const_iterator KeySymIndex;
|
|
|
|
typedef std::vector<KeySym> KeySyms;
|
|
|
|
typedef std::map<KeySym, KeySyms> KeySymsMap;
|
2003-07-13 16:57:08 +00:00
|
|
|
|
2001-10-08 19:24:46 +00:00
|
|
|
unsigned int mapButton(ButtonID button) const;
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
bool mapToKeystrokes(Keystrokes& keys,
|
2003-07-26 13:41:41 +00:00
|
|
|
SysKeyID& keycode,
|
|
|
|
KeyModifierMask& finalMask,
|
2003-07-01 19:35:28 +00:00
|
|
|
KeySymIndex keyIndex,
|
2003-07-26 13:41:41 +00:00
|
|
|
KeyModifierMask currentMask,
|
|
|
|
EKeyAction action,
|
|
|
|
bool isHalfDuplex) const;
|
2003-07-01 19:35:28 +00:00
|
|
|
bool adjustModifiers(Keystrokes& keys,
|
|
|
|
Keystrokes& undo,
|
2003-07-26 13:41:41 +00:00
|
|
|
KeyModifierMask& inOutMask,
|
|
|
|
KeyModifierMask desiredMask) const;
|
2003-07-01 19:35:28 +00:00
|
|
|
bool adjustModifier(Keystrokes& keys,
|
|
|
|
Keystrokes& undo,
|
|
|
|
KeySym keysym,
|
|
|
|
bool desireActive) const;
|
2003-07-26 13:41:41 +00:00
|
|
|
KeyModifierMask mapToModifierMask(ModifierIndex, KeySym) const;
|
2003-07-01 19:35:28 +00:00
|
|
|
|
|
|
|
unsigned int findBestKeyIndex(KeySymIndex keyIndex,
|
2003-07-26 13:41:41 +00:00
|
|
|
KeyModifierMask currentMask) const;
|
2003-07-01 19:35:28 +00:00
|
|
|
bool isShiftInverted(KeySymIndex keyIndex,
|
2003-07-26 13:41:41 +00:00
|
|
|
KeyModifierMask currentMask) const;
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2003-03-16 17:40:56 +00:00
|
|
|
void doUpdateKeys(Display*);
|
2003-07-01 19:35:28 +00:00
|
|
|
void updateKeysymMap(Display* display);
|
2002-04-26 17:38:01 +00:00
|
|
|
void updateModifiers(Display* display);
|
2003-07-01 19:35:28 +00:00
|
|
|
ModifierIndex keySymToModifierIndex(KeySym) const;
|
2002-04-26 17:38:01 +00:00
|
|
|
static bool isToggleKeysym(KeySym);
|
|
|
|
|
2003-07-26 13:41:41 +00:00
|
|
|
KeySym keyIDToKeySym(KeyID id, KeyModifierMask mask) const;
|
2002-09-14 12:07:02 +00:00
|
|
|
bool adjustForNumLock(KeySym) const;
|
|
|
|
bool adjustForCapsLock(KeySym) const;
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
bool decomposeKeySym(KeySym keysym,
|
|
|
|
KeySyms& decomposed) const;
|
|
|
|
static const KeySymsMap& getDecomposedKeySymTable();
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +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-08-18 17:31:48 +00:00
|
|
|
// logical to physical button mapping. m_buttons[i] gives the
|
|
|
|
// physical button for logical button i+1.
|
2002-12-15 22:39:59 +00:00
|
|
|
std::vector<unsigned char> m_buttons;
|
2002-08-18 17:31:48 +00:00
|
|
|
|
2002-04-26 17:38:01 +00:00
|
|
|
// the modifiers that have keys bound to them
|
2003-07-26 13:41:41 +00:00
|
|
|
KeyModifierMask m_modifierMask;
|
2002-04-26 17:38:01 +00:00
|
|
|
|
|
|
|
// set bits indicate modifiers that toggle (e.g. caps-lock)
|
2003-07-26 13:41:41 +00:00
|
|
|
KeyModifierMask m_toggleModifierMask;
|
2003-07-01 19:35:28 +00:00
|
|
|
|
|
|
|
// keysym to keycode mapping
|
|
|
|
KeySymMap m_keysymMap;
|
|
|
|
|
|
|
|
// modifier index to keycodes
|
|
|
|
KeyCodes m_modifierKeycodes[8];
|
|
|
|
|
2003-07-26 13:41:41 +00:00
|
|
|
// modifier index to modifier mask
|
|
|
|
KeyModifierMask m_modifierIndexToMask[8];
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// keycode to modifier index
|
|
|
|
KeyCodeToModifierMap m_keycodeToModifier;
|
|
|
|
|
|
|
|
// modifier keysyms
|
|
|
|
KeySym m_shiftKeysym;
|
|
|
|
KeySym m_ctrlKeysym;
|
|
|
|
KeySym m_altKeysym;
|
|
|
|
KeySym m_metaKeysym;
|
|
|
|
KeySym m_superKeysym;
|
|
|
|
KeySym m_modeSwitchKeysym;
|
|
|
|
KeySym m_numLockKeysym;
|
|
|
|
KeySym m_capsLockKeysym;
|
|
|
|
KeySym m_scrollLockKeysym;
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2003-05-03 13:28:21 +00:00
|
|
|
// the keyboard control state the last time this screen was entered
|
|
|
|
XKeyboardState m_keyControl;
|
2003-05-17 13:44:24 +00:00
|
|
|
|
|
|
|
// stuff to workaround xtest being xinerama unaware. attempting
|
2003-05-17 14:03:32 +00:00
|
|
|
// to fake a mouse motion under xinerama may behave strangely,
|
|
|
|
// especially if screen 0 is not at 0,0 or if faking a motion on
|
|
|
|
// a screen other than screen 0.
|
2003-05-17 13:44:24 +00:00
|
|
|
bool m_xtestIsXineramaUnaware;
|
|
|
|
bool m_xinerama;
|
2003-07-01 19:35:28 +00:00
|
|
|
|
|
|
|
// a table of keysym decompositions
|
|
|
|
static KeySymsMap s_decomposedKeySyms;
|
2001-10-08 19:24:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|