From 40bf320a4607dd1774433ee71fc0917534dab970 Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Mon, 3 Sep 2018 17:00:20 +0100 Subject: [PATCH] Linux: Fixed an issue detecting alt as a modifier key --- .../native/juce_linux_X11_Windowing.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp index ba1eb571aa..6361900cf8 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp @@ -2459,12 +2459,17 @@ private: if (auto* mapping = XGetModifierMapping (display)) { - for (int i = 0; i < 8; i++) + for (int modifierIdx = 0; modifierIdx < 8; ++modifierIdx) { - if (mapping->modifiermap [i << 1] == altLeftCode) - Keys::AltMask = 1 << i; - else if (mapping->modifiermap [i << 1] == numLockCode) - Keys::NumLockMask = 1 << i; + for (int keyIndex = 0; keyIndex < mapping->max_keypermod; ++keyIndex) + { + auto key = mapping->modifiermap[(modifierIdx * mapping->max_keypermod) + keyIndex]; + + if (key == altLeftCode) + Keys::AltMask = 1 << modifierIdx; + else if (key == numLockCode) + Keys::NumLockMask = 1 << modifierIdx; + } } XFreeModifiermap (mapping);