From 893f5bfd233a5f89fcc62811596d4fc31e2e6f29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Aum=C3=BCller?= <aumuell@reserv.at>
Date: Tue, 26 Oct 2010 10:56:32 +0200
Subject: [PATCH] fakevim: don't swap cmd and ctrl keys on os x

qt reversed the mapping of cmd and ctrl internally, this should be re-reversed in vi

Merge-request: 190
Reviewed-by: hjk <qtc-committer@nokia.com>
---
 src/plugins/fakevim/fakevimhandler.cpp | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 96f4598bab2..aa71acb9e93 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -405,8 +405,13 @@ public:
 
     bool isControl(int c) const
     {
-        return m_modifiers == Qt::ControlModifier &&
-            (m_xkey == c || m_xkey + 32 == c || m_xkey + 64 == c || m_xkey + 96 == c);
+        return m_modifiers ==
+#ifdef Q_WS_MAC
+            Qt::MetaModifier
+#else
+            Qt::ControlModifier
+#endif
+            && (m_xkey == c || m_xkey + 32 == c || m_xkey + 64 == c || m_xkey + 96 == c);
     }
 
     bool isShift(int c) const
@@ -1026,7 +1031,12 @@ bool FakeVimHandler::Private::wantsOverride(QKeyEvent *ev)
     }
 
     // We are interested in overriding most Ctrl key combinations
-    if (mods == Qt::ControlModifier
+    if (mods ==
+#ifdef Q_WS_MAC
+            Qt::MetaModifier
+#else
+            Qt::ControlModifier
+#endif
             && !config(ConfigPassControlKey).toBool()
             && ((key >= Key_A && key <= Key_Z && key != Key_K)
                 || key == Key_BracketLeft || key == Key_BracketRight)) {
@@ -1220,7 +1230,13 @@ void FakeVimHandler::Private::importSelection()
         // Import new selection.
         Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
         if (cursor().hasSelection()) {
-            if (mods & Qt::ControlModifier)
+            if (mods &
+#ifdef Q_WS_MAC
+                    Qt::MetaModifier
+#else
+                    Qt::ControlModifier
+#endif
+                    )
                 m_visualMode = VisualBlockMode;
             else if (mods & Qt::AltModifier)
                 m_visualMode = VisualBlockMode;
-- 
GitLab