summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@gmail.com>2020-06-02 14:27:37 +1000
committerLorn Potter <lorn.potter@gmail.com>2020-06-29 12:20:40 +1000
commitf1638edf4599aa74be439873a7719d9b70c57f54 (patch)
tree69e693e340179b6193bc095c6335a9f004d3846f /src/plugins
parent4ed01f5d23320f57ab72ae62cd1592828d7d023c (diff)
wasm: fix handling on int dead keys on mac
Q_OS_MAC is not defined when building wasm on mac, so we need to use a runtime check. Pick-to: 5.15 Change-Id: I1e9c5ec4e11aae94c9d8e918b5f1f1526723c782 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/wasm/qwasmeventtranslator.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
index 8eb30c0ecd..38dbb2e9ff 100644
--- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
+++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
@@ -305,7 +305,7 @@ static constexpr const auto DeadKeyShiftTbl = qMakeArray(
// macOS CTRL <-> META switching. We most likely want to enable
// the existing switching code in QtGui, but for now do it here.
-static bool g_usePlatformMacCtrlMetaSwitching = false;
+static bool g_usePlatformMacSpecifics = false;
bool g_useNaturalScrolling = true; // natural scrolling is default on linux/windows
@@ -348,7 +348,7 @@ void QWasmEventTranslator::initEventHandlers()
};
Platform platform = Platform(emscripten::val::global("navigator")["platform"]
.call<bool>("includes", emscripten::val("Mac")));
- g_usePlatformMacCtrlMetaSwitching = (platform == MacOSPlatform);
+ g_usePlatformMacSpecifics = (platform == MacOSPlatform);
if (platform == MacOSPlatform) {
g_useNaturalScrolling = false; // make this !default on macOS
@@ -385,7 +385,7 @@ QFlags<Qt::KeyboardModifier> QWasmEventTranslator::translatKeyModifier(const Eve
if (event->shiftKey)
keyModifier |= Qt::ShiftModifier;
if (event->ctrlKey) {
- if (g_usePlatformMacCtrlMetaSwitching)
+ if (g_usePlatformMacSpecifics)
keyModifier |= Qt::MetaModifier;
else
keyModifier |= Qt::ControlModifier;
@@ -393,7 +393,7 @@ QFlags<Qt::KeyboardModifier> QWasmEventTranslator::translatKeyModifier(const Eve
if (event->altKey)
keyModifier |= Qt::AltModifier;
if (event->metaKey) {
- if (g_usePlatformMacCtrlMetaSwitching)
+ if (g_usePlatformMacSpecifics)
keyModifier |= Qt::ControlModifier;
else
keyModifier |= Qt::MetaModifier;
@@ -442,7 +442,6 @@ Qt::Key QWasmEventTranslator::translateEmscriptKey(const EmscriptenKeyboardEvent
} else if (qstrncmp(emscriptKey->code, "Key", 3) == 0 || qstrncmp(emscriptKey->code, "Numpad", 6) == 0 ||
qstrncmp(emscriptKey->code, "Digit", 5) == 0) {
-
emkb2qt_t searchKey{emscriptKey->code, 0}; // search emcsripten code
auto it1 = std::lower_bound(KeyTbl.cbegin(), KeyTbl.cend(), searchKey);
if (it1 != KeyTbl.end() && !(searchKey < *it1)) {
@@ -839,12 +838,19 @@ static Qt::Key find(const KeyMapping (&map)[N], Qt::Key key) noexcept
Qt::Key QWasmEventTranslator::translateDeadKey(Qt::Key deadKey, Qt::Key accentBaseKey)
{
Qt::Key wasmKey = Qt::Key_unknown;
+
+ if (deadKey == Qt::Key_QuoteLeft ) {
+ if (g_usePlatformMacSpecifics) { // ` macOS: Key_Dead_Grave
+ wasmKey = find(graveKeyTable, accentBaseKey);
+ } else {
+ wasmKey = find(diaeresisKeyTable, accentBaseKey);
+ }
+ return wasmKey;
+ }
+
switch (deadKey) {
-#ifdef Q_OS_MACOS
- case Qt::Key_QuoteLeft: // ` macOS: Key_Dead_Grave
-#else
+ // case Qt::Key_QuoteLeft:
case Qt::Key_O: // ´ Key_Dead_Grave
-#endif
wasmKey = find(graveKeyTable, accentBaseKey);
break;
case Qt::Key_E: // ´ Key_Dead_Acute
@@ -854,9 +860,6 @@ Qt::Key QWasmEventTranslator::translateDeadKey(Qt::Key deadKey, Qt::Key accentBa
case Qt::Key_N:// Key_Dead_Tilde
wasmKey = find(tildeKeyTable, accentBaseKey);
break;
-#ifndef Q_OS_MACOS
- case Qt::Key_QuoteLeft:
-#endif
case Qt::Key_U:// ¨ Key_Dead_Diaeresis
wasmKey = find(diaeresisKeyTable, accentBaseKey);
break;