From f3150368c36a8ec89b278617f959a9a617a4153e Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 4 Mar 2022 09:28:09 +1000 Subject: [PATCH] wasm: fix native keyboard on iOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apple added iPhonePlatform to navigator properties and so use that Fixes: QTBUG-101441 Change-Id: I5a0f27fc18dfa224b6373c5d809cf884d51c880a Pick-to: 6.3 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasminputcontext.cpp | 11 +++++++---- src/plugins/platforms/wasm/qwasmintegration.cpp | 2 ++ src/plugins/platforms/wasm/qwasmintegration.h | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasminputcontext.cpp b/src/plugins/platforms/wasm/qwasminputcontext.cpp index f50395c059..20a6da9ebd 100644 --- a/src/plugins/platforms/wasm/qwasminputcontext.cpp +++ b/src/plugins/platforms/wasm/qwasminputcontext.cpp @@ -80,12 +80,14 @@ QWasmInputContext::QWasmInputContext() &androidKeyboardCallback); } - if (QWasmIntegration::get()->platform == QWasmIntegration::MacOSPlatform) + if (QWasmIntegration::get()->platform == QWasmIntegration::MacOSPlatform || + QWasmIntegration::get()->platform == QWasmIntegration::iPhonePlatform) { auto callback = [=](emscripten::val) { - m_inputElement["parentElement"].call("removeChild", m_inputElement); }; + m_inputElement["parentElement"].call("removeChild", m_inputElement); + inputPanelIsOpen = false; + }; m_blurEventHandler.reset(new EventCallback(m_inputElement, "blur", callback)); - inputPanelIsOpen = false; } QObject::connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, @@ -132,7 +134,8 @@ void QWasmInputContext::showInputPanel() // captured by the keyboard event handler installed on the // canvas. - if (QWasmIntegration::get()->platform == QWasmIntegration::MacOSPlatform + if (QWasmIntegration::get()->platform == QWasmIntegration::MacOSPlatform // keep for compatibility + || QWasmIntegration::get()->platform == QWasmIntegration::iPhonePlatform || QWasmIntegration::get()->platform == QWasmIntegration::WindowsPlatform) { emscripten::val canvas = focusCanvas(); if (canvas == emscripten::val::undefined()) diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index 01fb9f1cd0..765f89052e 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -113,6 +113,8 @@ QWasmIntegration::QWasmIntegration() if (rawPlatform.call("includes", emscripten::val("Mac"))) platform = MacOSPlatform; + if (rawPlatform.call("includes", emscripten::val("iPhone"))) + platform = iPhonePlatform; if (rawPlatform.call("includes", emscripten::val("Win32"))) platform = WindowsPlatform; if (rawPlatform.call("includes", emscripten::val("Linux"))) { diff --git a/src/plugins/platforms/wasm/qwasmintegration.h b/src/plugins/platforms/wasm/qwasmintegration.h index 316f6eef40..cba5057f09 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.h +++ b/src/plugins/platforms/wasm/qwasmintegration.h @@ -66,7 +66,8 @@ public: MacOSPlatform, WindowsPlatform, LinuxPlatform, - AndroidPlatform + AndroidPlatform, + iPhonePlatform }; QWasmIntegration();