Merge branch 'pr-jpmcmu-macosx-sticky-key-fix'

This commit is contained in:
XinyuHou 2015-05-06 13:20:54 +01:00
commit 68edff43cd
4 changed files with 42 additions and 0 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ src/gui/gui.pro.user*
src/gui/.qmake.stash
src/gui/.rnd
src/setup/win32/synergy.suo
*.smbdelete*

View File

@ -390,6 +390,34 @@ OSXKeyState::fakeCtrlAltDel()
return false;
}
CGEventFlags
OSXKeyState::getModifierStateAsOSXFlags()
{
CGEventFlags modifiers = 0;
if (m_shiftPressed) {
modifiers |= kCGEventFlagMaskShift;
}
if (m_controlPressed) {
modifiers |= kCGEventFlagMaskControl;
}
if (m_altPressed) {
modifiers |= kCGEventFlagMaskAlternate;
}
if (m_superPressed) {
modifiers |= kCGEventFlagMaskCommand;
}
if (m_capsPressed) {
modifiers |= kCGEventFlagMaskAlphaShift;
}
return modifiers;
}
KeyModifierMask
OSXKeyState::pollActiveModifiers() const
{

View File

@ -100,6 +100,7 @@ public:
virtual SInt32 pollActiveGroup() const;
virtual void pollPressedKeys(KeyButtonSet& pressedKeys) const;
CGEventFlags getModifierStateAsOSXFlags();
protected:
// KeyState overrides
virtual void getKeyMap(synergy::KeyMap& keyMap);

View File

@ -528,6 +528,10 @@ OSXScreen::postMouseEvent(CGPoint& pos) const
// Dragging events also need the click state
CGEventSetIntegerValueField(event, kCGMouseEventClickState, m_clickState);
// Fix for sticky keys
CGEventFlags modifiers = m_keyState->getModifierStateAsOSXFlags();
CGEventSetFlags(event, modifiers);
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
@ -595,6 +599,10 @@ OSXScreen::fakeMouseButton(ButtonID id, bool press)
CGEventSetIntegerValueField(event, kCGMouseEventClickState, m_clickState);
// Fix for sticky keys
CGEventFlags modifiers = m_keyState->getModifierStateAsOSXFlags();
CGEventSetFlags(event, modifiers);
m_buttonState.set(index, state);
CGEventPost(kCGHIDEventTap, event);
@ -705,6 +713,10 @@ OSXScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const
mapScrollWheelFromSynergy(yDelta),
-mapScrollWheelFromSynergy(xDelta));
// Fix for sticky keys
CGEventFlags modifiers = m_keyState->getModifierStateAsOSXFlags();
CGEventSetFlags(scrollEvent, modifiers);
CGEventPost(kCGHIDEventTap, scrollEvent);
CFRelease(scrollEvent);
#else