From 57950d39a308253652aa1b2b46d73299e92cfd7d Mon Sep 17 00:00:00 2001 From: "Jerry (Xinyu Hou)" Date: Thu, 11 Aug 2016 16:59:36 +0100 Subject: [PATCH] Revert "Revert "Used input source ID as the key in group map #2765"" This reverts commit a70cba80ea3c35afcde25997b81377aba504b977. --- src/lib/platform/OSXKeyState.cpp | 18 +++++++++++------- src/lib/platform/OSXKeyState.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/lib/platform/OSXKeyState.cpp b/src/lib/platform/OSXKeyState.cpp index 7646193d..78c794a8 100644 --- a/src/lib/platform/OSXKeyState.cpp +++ b/src/lib/platform/OSXKeyState.cpp @@ -392,15 +392,17 @@ OSXKeyState::pollActiveModifiers() const SInt32 OSXKeyState::pollActiveGroup() const { - bool layoutValid = true; TISInputSourceRef keyboardLayout = TISCopyCurrentKeyboardLayoutInputSource(); + CFDataRef id = (CFDataRef)TISGetInputSourceProperty( + keyboardLayout, kTISPropertyInputSourceID); - if (layoutValid) { - GroupMap::const_iterator i = m_groupMap.find(keyboardLayout); - if (i != m_groupMap.end()) { - return i->second; - } + GroupMap::const_iterator i = m_groupMap.find(id); + if (i != m_groupMap.end()) { + return i->second; } + + LOG((CLOG_DEBUG "can't get the active group, use the first group instead")); + return 0; } @@ -427,7 +429,9 @@ OSXKeyState::getKeyMap(synergy::KeyMap& keyMap) m_groupMap.clear(); SInt32 numGroups = (SInt32)m_groups.size(); for (SInt32 g = 0; g < numGroups; ++g) { - m_groupMap[m_groups[g]] = g; + CFDataRef id = (CFDataRef)TISGetInputSourceProperty( + m_groups[g], kTISPropertyInputSourceID); + m_groupMap[id] = g; } } diff --git a/src/lib/platform/OSXKeyState.h b/src/lib/platform/OSXKeyState.h index 2aaffc47..26050a28 100644 --- a/src/lib/platform/OSXKeyState.h +++ b/src/lib/platform/OSXKeyState.h @@ -159,7 +159,7 @@ private: KeyButtonOffset = 1 }; - typedef std::map GroupMap; + typedef std::map GroupMap; typedef std::map VirtualKeyMap; VirtualKeyMap m_virtualKeyMap;