Restored lost files and changes in version 1.3.1 to depot.

This commit is contained in:
crs
2007-06-17 11:19:18 +00:00
parent 73acb7860d
commit 52ae656411
199 changed files with 27622 additions and 13726 deletions

View File

@@ -17,6 +17,7 @@
#include "CKeyState.h"
#include "stdmap.h"
#include "stdvector.h"
#if X_DISPLAY_MISSING
# error X11 is required to build synergy
#else
@@ -26,6 +27,9 @@
# else
# error The XTest extension is required to build synergy
# endif
# if HAVE_XKB_EXTENSION
# include <X11/extensions/XKBstr.h>
# endif
#endif
//! X Windows key state
@@ -34,9 +38,35 @@ A key state for X Windows.
*/
class CXWindowsKeyState : public CKeyState {
public:
CXWindowsKeyState(Display*);
typedef std::vector<int> CKeycodeList;
enum {
kGroupPoll = -1,
kGroupPollAndSet = -2
};
CXWindowsKeyState(Display*, bool useXKB);
~CXWindowsKeyState();
//! @name modifiers
//@{
//! Set active group
/*!
Sets the active group to \p group. This is the group returned by
\c pollActiveGroup(). If \p group is \c kGroupPoll then
\c pollActiveGroup() will really poll, but that's a slow operation
on X11. If \p group is \c kGroupPollAndSet then this will poll the
active group now and use it for future calls to \c pollActiveGroup().
*/
void setActiveGroup(SInt32 group);
//! Set the auto-repeat state
/*!
Sets the auto-repeat state.
*/
void setAutoRepeat(const XKeyboardState&);
//@}
//! @name accessors
//@{
@@ -47,106 +77,79 @@ public:
*/
KeyModifierMask mapModifiersFromX(unsigned int state) const;
//! Convert synergy modifier mask to X mask
/*!
Converts the synergy modifier mask to the corresponding X modifier
mask. Returns \c true if successful and \c false if any modifier
could not be converted.
*/
bool mapModifiersToX(KeyModifierMask, unsigned int&) const;
//! Convert synergy key to all corresponding X keycodes
/*!
Converts the synergy key \p key to all of the keycodes that map to
that key.
*/
void mapKeyToKeycodes(KeyID key,
CKeycodeList& keycodes) const;
//@}
// IKeyState overrides
virtual bool fakeCtrlAltDel();
virtual const char* getKeyName(KeyButton) const;
virtual KeyModifierMask
pollActiveModifiers() const;
virtual SInt32 pollActiveGroup() const;
virtual void pollPressedKeys(KeyButtonSet& pressedKeys) const;
protected:
// IKeyState overrides
virtual void doUpdateKeys();
virtual void doFakeKeyEvent(KeyButton button,
bool press, bool isAutoRepeat);
virtual KeyButton mapKey(Keystrokes& keys, KeyID id,
KeyModifierMask desiredMask,
bool isAutoRepeat) const;
// CKeyState overrides
virtual void getKeyMap(CKeyMap& keyMap);
virtual void fakeKey(const Keystroke& keystroke);
private:
class KeyMapping {
void updateKeysymMap(CKeyMap&);
void updateKeysymMapXKB(CKeyMap&);
bool hasModifiersXKB() const;
int getEffectiveGroup(KeyCode, int group) const;
UInt32 getGroupFromState(unsigned int state) const;
static void remapKeyModifiers(KeyID, SInt32,
CKeyMap::KeyItem&, void*);
private:
struct XKBModifierInfo {
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
KeyModifierMask m_modifierMask;
// whether keysym is sensitive to caps and num lock
bool m_numLockSensitive;
bool m_capsLockSensitive;
unsigned char m_level;
UInt32 m_mask;
bool m_lock;
};
typedef std::map<KeySym, KeyMapping> KeySymMap;
typedef KeySymMap::const_iterator KeySymIndex;
// save the current keyboard mapping and note the modifiers
void updateKeysymMap();
typedef std::vector<KeyModifierMask> KeyModifierMaskList;
typedef std::map<KeyModifierMask, unsigned int> KeyModifierToXMask;
typedef std::multimap<KeyID, KeyCode> KeyToKeyCodeMap;
typedef std::map<KeyCode, unsigned int> NonXKBModifierMap;
typedef std::map<UInt32, XKBModifierInfo> XKBModifierMap;
// note interesting modifier KeySyms
void updateModifiers();
// map a modifier index and its KeySym to a modifier mask. also
// save the modifier mask in one of m_*Mask.
KeyModifierMask mapToModifierMask(unsigned int, KeySym);
// convert a KeyID to a KeySym
KeySym keyIDToKeySym(KeyID id, KeyModifierMask mask) const;
// map a KeySym into the keystrokes to produce it
KeyButton mapToKeystrokes(Keystrokes& keys,
KeySymIndex keyIndex,
bool isAutoRepeat,
bool pressAndRelease) const;
// map a decomposition into keystrokes to produce it. returns the
// last key added to keys iff successful and 0 otherwise.
KeyButton mapDecompositionToKeystrokes(Keystrokes& keys,
KeySym keysym, bool usingDeadKeys) const;
// choose the best set of modifiers to generate the KeySym
unsigned int findBestKeyIndex(KeySymIndex keyIndex,
KeyModifierMask currentMask) const;
// returns true if the sense of shift is inverted for KeySym
bool isShiftInverted(KeySymIndex keyIndex,
KeyModifierMask currentMask) const;
// returns the keystrokes to adjust the modifiers into the desired
// state the keystrokes to get back to the current state.
bool adjustModifiers(Keystrokes& keys,
Keystrokes& undo,
KeyModifierMask desiredMask) const;
// returns true if keysym is sensitive to the NumLock state
bool isNumLockSensitive(KeySym keysym) const;
// returns true if keysym is sensitive to the CapsLock state
bool isCapsLockSensitive(KeySym keysym) const;
private:
Display* m_display;
#if HAVE_XKB_EXTENSION
XkbDescPtr m_xkb;
#endif
SInt32 m_group;
XKBModifierMap m_lastGoodXKBModifiers;
NonXKBModifierMap m_lastGoodNonXKBModifiers;
// keysym to keycode mapping
KeySymMap m_keysymMap;
// X modifier (bit number) to synergy modifier (mask) mapping
KeyModifierMaskList m_modifierFromX;
// the keyboard control state the last time this screen was entered
XKeyboardState m_keyControl;
// synergy modifier (mask) to X modifier (mask)
KeyModifierToXMask m_modifierToX;
// modifier keysyms
KeySym m_modeSwitchKeysym;
// map KeyID to all keycodes that can synthesize that KeyID
KeyToKeyCodeMap m_keyCodeFromKey;
// modifier masks
unsigned int m_altMask;
unsigned int m_metaMask;
unsigned int m_superMask;
unsigned int m_modeSwitchMask;
unsigned int m_numLockMask;
unsigned int m_scrollLockMask;
// autorepeat state
XKeyboardState m_keyboardState;
};
#endif