Created
June 19, 2012 18:47
-
-
Save ehabkost/2955837 to your computer and use it in GitHub Desktop.
Fix for synergy bug #3250
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/lib/platform/COSXKeyState.cpp | |
=================================================================== | |
--- src/lib/platform/COSXKeyState.cpp (revision 1471) | |
+++ src/lib/platform/COSXKeyState.cpp (working copy) | |
@@ -243,6 +243,35 @@ | |
} | |
KeyModifierMask | |
+COSXKeyState::mapModifiersFromCarbon(UInt32 mask) const | |
+{ | |
+ LOG((CLOG_DEBUG1 "mask: %04x", mask)); | |
+ | |
+ KeyModifierMask outMask = 0; | |
+ if ((mask & shiftKey) != 0) { | |
+ outMask |= KeyModifierShift; | |
+ } | |
+ if ((mask & controlKey) != 0) { | |
+ outMask |= KeyModifierControl; | |
+ } | |
+ if ((mask & optionKey) != 0) { | |
+ outMask |= KeyModifierAlt; | |
+ } | |
+ if ((mask & cmdKey) != 0) { | |
+ outMask |= KeyModifierSuper; | |
+ } | |
+ if ((mask & alphaLock) != 0) { | |
+ outMask |= KeyModifierCapsLock; | |
+ } | |
+ | |
+ UInt32 unsupported = mask & ~(shiftKey|controlKey|optionKey|cmdKey|alphaLock); | |
+ if (unsupported) | |
+ LOG((CLOG_WARN "unsupported modifier bits: %04x", unsupported)); | |
+ | |
+ return outMask; | |
+} | |
+ | |
+KeyModifierMask | |
COSXKeyState::mapModifiersToCarbon(UInt32 mask) const | |
{ | |
KeyModifierMask outMask = 0; | |
@@ -677,10 +706,10 @@ | |
} | |
// now add a key entry for each key/required modifier pair. | |
- item.m_sensitive = mapModifiersFromOSX(sensitive << 8); | |
+ item.m_sensitive = mapModifiersFromCarbon(sensitive << 8); | |
for (std::set<UInt32>::iterator k = required.begin(); | |
k != required.end(); ++k) { | |
- item.m_required = mapModifiersFromOSX(*k << 8); | |
+ item.m_required = mapModifiersFromCarbon(*k << 8); | |
keyMap.addKeyEntry(item); | |
} | |
} | |
Index: src/lib/platform/COSXKeyState.h | |
=================================================================== | |
--- src/lib/platform/COSXKeyState.h (revision 1471) | |
+++ src/lib/platform/COSXKeyState.h (working copy) | |
@@ -64,6 +64,13 @@ | |
*/ | |
KeyModifierMask mapModifiersFromOSX(UInt32 mask) const; | |
+ //! Convert Legacy Carbon modifier mask to synergy mask | |
+ /*! | |
+ Returns the synergy modifier mask corresponding to the Carbon (Event Manager) modifier | |
+ mask in \p mask. | |
+ */ | |
+ KeyModifierMask mapModifiersFromCarbon(UInt32 mask) const; | |
+ | |
//! Convert CG flags-style modifier mask to old-style Carbon | |
/*! | |
Still required in a few places for translation calls. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment