summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qkeymapper_mac.cpp
diff options
context:
space:
mode:
authorNorwegian Rock Cat <qt-info@nokia.com>2009-05-08 13:18:05 +0200
committerNorwegian Rock Cat <qt-info@nokia.com>2009-05-11 17:31:32 +0200
commit4af513212d9ca9ed88e18bddaabd90006aca8541 (patch)
treeb060ec6e251f3b2580c4791b55af0bc255eb35e5 /src/gui/kernel/qkeymapper_mac.cpp
parent66025048e22cda13ff0074b4bf26a898f7695e9e (diff)
Add a AA_MacDontSwapCtrlAndMeta application attribute.
This is to help undo the some magic that is in the Qt/Mac port. Qt automatically flips the Meta and Control keys on Mac. This is a "feature" that makes porting older programs that don't use standard shortcuts easier as Ctrl and Command usually map to the same shortcuts in the application. The upshot of this is that I need to strip the text() out of key events if they contain the Control or Meta modifier. This causes much headache for anyone writing a terminal emulator. Though they would still have to write special code because the keys are swapped anyway. This allows people to write the terminal emulator where hitting the Control key will really send a Control key modifier. We've also done the extra work to ensure that standard shortcuts work correctly regardless of what the value of the attribute is. That is, if you specify QKeySequence::Cut for a shortcut you can always hit Command+X and things will work.
Diffstat (limited to 'src/gui/kernel/qkeymapper_mac.cpp')
-rw-r--r--src/gui/kernel/qkeymapper_mac.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp
index 39abc5e0c7..01b2c13d8f 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/gui/kernel/qkeymapper_mac.cpp
@@ -161,6 +161,14 @@ Qt::KeyboardModifiers qt_mac_get_modifiers(int keys)
ret |= Qt::KeyboardModifier(qt_mac_modifier_symbols[i].qt_code);
}
}
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ Qt::KeyboardModifiers oldModifiers = ret;
+ ret &= ~(Qt::MetaModifier | Qt::ControlModifier);
+ if (oldModifiers & Qt::ControlModifier)
+ ret |= Qt::MetaModifier;
+ if (oldModifiers & Qt::MetaModifier)
+ ret |= Qt::ControlModifier;
+ }
return ret;
}
static int qt_mac_get_mac_modifiers(Qt::KeyboardModifiers keys)
@@ -177,6 +185,15 @@ static int qt_mac_get_mac_modifiers(Qt::KeyboardModifiers keys)
ret |= qt_mac_modifier_symbols[i].mac_code;
}
}
+
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ int oldModifiers = ret;
+ ret &= ~(controlKeyBit | cmdKeyBit);
+ if (oldModifiers & controlKeyBit)
+ ret |= cmdKeyBit;
+ if (oldModifiers & cmdKeyBit)
+ ret |= controlKeyBit;
+ }
return ret;
}
void qt_mac_send_modifiers_changed(quint32 modifiers, QObject *object)