From: Stephan Witt Date: Sat, 24 Oct 2015 19:03:01 +0000 (+0200) Subject: For Mac OS: Additional check for Control and Meta modifier swap state. X-Git-Tag: 2.2.0alpha1~174 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=2a3b54d57b82748ad164b9471917d33cd247a929;p=features.git For Mac OS: Additional check for Control and Meta modifier swap state. 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. --- diff --git a/src/frontends/qt4/GuiKeySymbol.cpp b/src/frontends/qt4/GuiKeySymbol.cpp index 54a4516674..d058bce50e 100644 --- a/src/frontends/qt4/GuiKeySymbol.cpp +++ b/src/frontends/qt4/GuiKeySymbol.cpp @@ -11,6 +11,7 @@ #include #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)