From 178b7cc6731af5bca62c9e811b3670722456289b Mon Sep 17 00:00:00 2001 From: "Jerry (Xinyu Hou)" Date: Tue, 16 Aug 2016 14:45:00 +0100 Subject: [PATCH] #2765 Made sure required modifiers already down when map command keys --- src/lib/synergy/KeyMap.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lib/synergy/KeyMap.cpp b/src/lib/synergy/KeyMap.cpp index b4e10e2f..656434ca 100644 --- a/src/lib/synergy/KeyMap.cpp +++ b/src/lib/synergy/KeyMap.cpp @@ -535,14 +535,17 @@ KeyMap::mapCommandKey(Keystrokes& keys, KeyID id, SInt32 group, continue; } - // only match based on shift; we're after the right button - // not the right character. we'll use desiredMask as-is, - // overriding the key's required modifiers, when synthesizing - // this button. + // match based on shift and make sure all required modifiers, + // except shift, are already in the desired mask; we're + // after the right button not the right character. + // we'll use desiredMask as-is, overriding the key's required + // modifiers, when synthesizing this button. const KeyItem& item = entryList[i].back(); - if ((item.m_required & KeyModifierShift & desiredMask) == - (item.m_sensitive & KeyModifierShift & desiredMask)) { - LOG((CLOG_DEBUG1 "found key in group %d", effectiveGroup)); + KeyModifierMask desiredShiftMask = KeyModifierShift & desiredMask; + KeyModifierMask requiredIgnoreShiftMask = item.m_required & ~KeyModifierShift; + if ((item.m_required & desiredShiftMask) == (item.m_sensitive & desiredShiftMask) && + ((requiredIgnoreShiftMask & desiredMask) == requiredIgnoreShiftMask)) { + LOG((CLOG_INFO "found key in group %d", effectiveGroup)); keyItem = &item; break; }