]> git.lyx.org Git - lyx.git/commitdiff
For Mac OS: Additional check for Control and Meta modifier swap state.
authorStephan Witt <switt@lyx.org>
Sat, 24 Oct 2015 19:03:01 +0000 (21:03 +0200)
committerStephan Witt <switt@lyx.org>
Sat, 24 Oct 2015 19:08:10 +0000 (21:08 +0200)
Starting with Qt 5 the modifiers aren't reported correctly for disabled swap.
Until this is fixed it is corrected by reverting the modifier mask to check for.

src/frontends/qt4/GuiKeySymbol.cpp

index 54a45166743f5afe59db0efb4e488fa3a358ec83..d058bce50e4050e8ca7e99755295b76a8ecc62c1 100644 (file)
@@ -11,6 +11,7 @@
 #include <config.h>
 
 #include "KeySymbol.h"
+#include "GuiApplication.h"
 
 #include "qt_helpers.h"
 
@@ -744,14 +745,24 @@ bool KeySymbol::operator==(KeySymbol const & ks) const
 KeyModifier q_key_state(Qt::KeyboardModifiers state)
 {
        KeyModifier k = NoModifier;
-       if (state & Qt::ControlModifier)
+#if defined(Q_OS_MAC) && QT_VERSION > 0x050000
+       /// Additional check for Control and Meta modifier swap state.
+       /// Starting with Qt 5 the modifiers aren't reported correctly.
+       /// Until this is fixed a correction is required.
+       const bool dontSwapCtrlAndMeta =
+               frontend::theGuiApp()->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
+#else
+       const bool dontSwapCtrlAndMeta = false;
+#endif
+
+       if (state & (dontSwapCtrlAndMeta ? Qt::MetaModifier : Qt::ControlModifier))
                k |= ControlModifier;
        if (state & Qt::ShiftModifier)
                k |= ShiftModifier;
        if (state & Qt::AltModifier)
                k |= AltModifier;
 #if defined(USE_MACOSX_PACKAGING) || defined(USE_META_KEYBINDING)
-       if (state & Qt::MetaModifier)
+       if (state & (dontSwapCtrlAndMeta ? Qt::ControlModifier : Qt::MetaModifier))
                k |= MetaModifier;
 #else
        if (state & Qt::MetaModifier)