macOS: Clarify that QCocoaKeyMapper only computes 8 modifier states
Change-Id: Ie4a53bbc16cde7b4aa68172015bbfeaa9e316bcc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
865582bd7f
commit
8361c6252f
@ -49,27 +49,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*
|
||||
\internal
|
||||
A Mac KeyboardLayoutItem has 8 possible states:
|
||||
1. Unmodified
|
||||
2. Shift
|
||||
3. Control
|
||||
4. Control + Shift
|
||||
5. Alt
|
||||
6. Alt + Shift
|
||||
7. Alt + Control
|
||||
8. Alt + Control + Shift
|
||||
9. Meta
|
||||
10. Meta + Shift
|
||||
11. Meta + Control
|
||||
12. Meta + Control + Shift
|
||||
13. Meta + Alt
|
||||
14. Meta + Alt + Shift
|
||||
15. Meta + Alt + Control
|
||||
16. Meta + Alt + Control + Shift
|
||||
*/
|
||||
|
||||
class QCocoaKeyMapper
|
||||
{
|
||||
public:
|
||||
@ -83,8 +62,8 @@ public:
|
||||
static Qt::Key fromCocoaKey(QChar keyCode);
|
||||
|
||||
private:
|
||||
using VirtualKeyCode = unsigned short;
|
||||
struct KeyMap : std::array<char32_t, 16>
|
||||
static constexpr int kNumModifierCombinations = 16;
|
||||
struct KeyMap : std::array<char32_t, kNumModifierCombinations>
|
||||
{
|
||||
// Initialize first element to a sentinel that allows us
|
||||
// to distinguish an uninitialized map from an initialized.
|
||||
@ -94,6 +73,8 @@ private:
|
||||
};
|
||||
|
||||
bool updateKeyboard();
|
||||
|
||||
using VirtualKeyCode = unsigned short;
|
||||
const KeyMap &keyMapForKey(VirtualKeyCode virtualKey, QChar unicodeKey) const;
|
||||
|
||||
QCFType<TISInputSourceRef> m_currentInputSource = nullptr;
|
||||
|
@ -444,6 +444,8 @@ static constexpr Qt::KeyboardModifiers modifierCombinations[] = {
|
||||
*/
|
||||
const QCocoaKeyMapper::KeyMap &QCocoaKeyMapper::keyMapForKey(VirtualKeyCode virtualKey, QChar unicodeKey) const
|
||||
{
|
||||
static_assert(sizeof(modifierCombinations) / sizeof(Qt::KeyboardModifiers) == kNumModifierCombinations);
|
||||
|
||||
const_cast<QCocoaKeyMapper *>(this)->updateKeyboard();
|
||||
|
||||
auto &keyMap = m_keyMap[virtualKey];
|
||||
@ -452,7 +454,7 @@ const QCocoaKeyMapper::KeyMap &QCocoaKeyMapper::keyMapForKey(VirtualKeyCode virt
|
||||
|
||||
qCDebug(lcQpaKeyMapper, "Updating key map for virtual key = 0x%02x!", (uint)virtualKey);
|
||||
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
for (int i = 0; i < kNumModifierCombinations; ++i) {
|
||||
Q_ASSERT(!i || keyMap[i] == 0);
|
||||
|
||||
auto qtModifiers = modifierCombinations[i];
|
||||
@ -514,6 +516,7 @@ QList<int> QCocoaKeyMapper::possibleKeys(const QKeyEvent *event) const
|
||||
// is always valid, and the first priority.
|
||||
ret << int(unmodifiedKey + eventModifiers);
|
||||
|
||||
// FIXME: We only compute the first 8 combinations. Why?
|
||||
for (int i = 1; i < 8; ++i) {
|
||||
auto keyAfterApplyingModifiers = keyMap[i];
|
||||
if (keyAfterApplyingModifiers == unmodifiedKey)
|
||||
|
Loading…
Reference in New Issue
Block a user