summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmcompositor.cpp
diff options
context:
space:
mode:
authorMikolaj Boc <mikolaj.boc@qt.io>2022-09-16 15:34:03 +0200
committerMikolaj Boc <mikolaj.boc@qt.io>2022-09-18 21:44:35 +0200
commit38049164c370dd424afe0c4574b458f7bd79083b (patch)
tree3ee33506ad9ace404f57d58842efbdec9db5c0fe /src/plugins/platforms/wasm/qwasmcompositor.cpp
parent9536a0ad48a54fef504689cc7a1e65ab865c5ff4 (diff)
Make the clipboard paste from the outside work correctly
During the previous refactoring, two exceptions that triggered native copy/paste events were omitted. Fixes: QTBUG-106668 Pick-to: 6.4.0 6.4 Change-Id: Ie61dd6a0c1d9d2fdd47bd94be055d0221feae25b Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmcompositor.cpp')
-rw-r--r--src/plugins/platforms/wasm/qwasmcompositor.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp
index ccf7bd93562..a892f7077b7 100644
--- a/src/plugins/platforms/wasm/qwasmcompositor.cpp
+++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp
@@ -823,21 +823,30 @@ void QWasmCompositor::WindowManipulation::onPointerUp(const PointerEvent& event)
bool QWasmCompositor::processKeyboard(int eventType, const EmscriptenKeyboardEvent *emKeyEvent)
{
+ constexpr bool ProceedToNativeEvent = false;
Q_ASSERT(eventType == EMSCRIPTEN_EVENT_KEYDOWN || eventType == EMSCRIPTEN_EVENT_KEYUP);
auto translatedEvent = m_eventTranslator->translateKeyEvent(eventType, emKeyEvent);
const QFlags<Qt::KeyboardModifier> modifiers = KeyboardModifier::getForEvent(*emKeyEvent);
- if (QWasmIntegration::get()->getWasmClipboard()->processKeyboard(translatedEvent, modifiers))
- return false;
+ const auto clipboardResult = QWasmIntegration::get()->getWasmClipboard()->processKeyboard(
+ translatedEvent, modifiers);
+
+ using ProcessKeyboardResult = QWasmClipboard::ProcessKeyboardResult;
+ if (clipboardResult == ProcessKeyboardResult::NativeClipboardEventNeeded)
+ return ProceedToNativeEvent;
if (translatedEvent.text.isEmpty())
translatedEvent.text = QString(emKeyEvent->key);
if (translatedEvent.text.size() > 1)
translatedEvent.text.clear();
- return QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(
- 0, translatedEvent.type, translatedEvent.key, modifiers, translatedEvent.text);
+ const auto result =
+ QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(
+ 0, translatedEvent.type, translatedEvent.key, modifiers, translatedEvent.text);
+ return clipboardResult == ProcessKeyboardResult::NativeClipboardEventAndCopiedDataNeeded
+ ? ProceedToNativeEvent
+ : result;
}
bool QWasmCompositor::processWheel(int eventType, const EmscriptenWheelEvent *wheelEvent)