From 4b1229e5235412062a5240410ec49e358019507c Mon Sep 17 00:00:00 2001 From: David Skoland Date: Mon, 6 Dec 2021 13:43:34 +0100 Subject: [PATCH] Set WASM platform default to synchronous window event handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on existing code, it appears that it's always preferred in wasm to use synchronous delivery (), however, we can simply define this as the default mode of operation, which will make these unnecessary. Change-Id: Ia4c78593333e314f91efb266268917317794e2f5 Pick-to: 6.5 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmclipboard.cpp | 6 +++--- src/plugins/platforms/wasm/qwasmcompositor.cpp | 14 ++++++++------ src/plugins/platforms/wasm/qwasminputcontext.cpp | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmclipboard.cpp b/src/plugins/platforms/wasm/qwasmclipboard.cpp index 1ef2e2a984b..d6343e9f6bc 100644 --- a/src/plugins/platforms/wasm/qwasmclipboard.cpp +++ b/src/plugins/platforms/wasm/qwasmclipboard.cpp @@ -51,7 +51,7 @@ static void qClipboardCutTo(val event) { if (!QWasmIntegration::get()->getWasmClipboard()->hasClipboardApi()) { // Send synthetic Ctrl+X to make the app cut data to Qt's clipboard - QWindowSystemInterface::handleKeyEvent( + QWindowSystemInterface::handleKeyEvent( 0, QEvent::KeyPress, Qt::Key_C, Qt::ControlModifier, "X"); } @@ -62,7 +62,7 @@ static void qClipboardCopyTo(val event) { if (!QWasmIntegration::get()->getWasmClipboard()->hasClipboardApi()) { // Send synthetic Ctrl+C to make the app copy data to Qt's clipboard - QWindowSystemInterface::handleKeyEvent( + QWindowSystemInterface::handleKeyEvent( 0, QEvent::KeyPress, Qt::Key_C, Qt::ControlModifier, "C"); } commonCopyEvent(event); @@ -74,7 +74,7 @@ static void qWasmClipboardPaste(QMimeData *mData) QWasmIntegration::get()->clipboard()-> QPlatformClipboard::setMimeData(mData, QClipboard::Clipboard); - QWindowSystemInterface::handleKeyEvent( + QWindowSystemInterface::handleKeyEvent( 0, QEvent::KeyPress, Qt::Key_V, Qt::ControlModifier, "V"); } diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index 0f082543ff4..f4f2d1b11dd 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -54,7 +54,9 @@ QWasmCompositor::QWasmCompositor(QWasmScreen *screen) QPointingDevice::Capability::Position | QPointingDevice::Capability::Area | QPointingDevice::Capability::NormalizedPosition, 10, 0); + QWindowSystemInterface::registerInputDevice(m_touchDevice.get()); + QWindowSystemInterface::setSynchronousWindowSystemEvents(true); } QWasmCompositor::~QWasmCompositor() @@ -283,7 +285,7 @@ void QWasmCompositor::deliverUpdateRequest(QWasmWindow *window, UpdateRequestDel window->QPlatformWindow::deliverUpdateRequest(); } else { QWindow *qwindow = window->window(); - QWindowSystemInterface::handleExposeEvent( + QWindowSystemInterface::handleExposeEvent( qwindow, QRect(QPoint(0, 0), qwindow->geometry().size())); } } @@ -472,7 +474,7 @@ bool QWasmCompositor::deliverEventToTarget(const PointerEvent &event, QWindow *e MouseEvent::mouseEventTypeFromEventType(event.type, windowArea); return eventType != QEvent::None && - QWindowSystemInterface::handleMouseEvent( + QWindowSystemInterface::handleMouseEvent( eventTarget, QWasmIntegration::getTimestamp(), eventTarget->mapFromGlobal(targetPointClippedToScreen), targetPointClippedToScreen, event.mouseButtons, event.mouseButton, @@ -574,7 +576,7 @@ bool QWasmCompositor::processKeyboard(int eventType, const EmscriptenKeyboardEve if (translatedEvent.text.size() > 1) translatedEvent.text.clear(); const auto result = - QWindowSystemInterface::handleKeyEvent( + QWindowSystemInterface::handleKeyEvent( 0, translatedEvent.type, translatedEvent.key, modifiers, translatedEvent.text); return clipboardResult == ProcessKeyboardResult::NativeClipboardEventAndCopiedDataNeeded ? ProceedToNativeEvent @@ -701,7 +703,7 @@ bool QWasmCompositor::processTouch(int eventType, const EmscriptenTouchEvent *to if (eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL) accepted = QWindowSystemInterface::handleTouchCancelEvent(targetWindow, QWasmIntegration::getTimestamp(), m_touchDevice.get(), keyModifier); else - accepted = QWindowSystemInterface::handleTouchEvent( + accepted = QWindowSystemInterface::handleTouchEvent( targetWindow, QWasmIntegration::getTimestamp(), m_touchDevice.get(), touchPointList, keyModifier); return static_cast(accepted); @@ -721,12 +723,12 @@ void QWasmCompositor::releaseCapture() void QWasmCompositor::leaveWindow(QWindow *window) { m_windowUnderMouse = nullptr; - QWindowSystemInterface::handleLeaveEvent(window); + QWindowSystemInterface::handleLeaveEvent(window); } void QWasmCompositor::enterWindow(QWindow *window, const QPoint &pointInTargetWindowCoords, const QPoint &targetPointInScreenCoords) { - QWindowSystemInterface::handleEnterEvent(window, pointInTargetWindowCoords, targetPointInScreenCoords); + QWindowSystemInterface::handleEnterEvent(window, pointInTargetWindowCoords, targetPointInScreenCoords); } bool QWasmCompositor::processMouseEnter(const EmscriptenMouseEvent *mouseEvent) diff --git a/src/plugins/platforms/wasm/qwasminputcontext.cpp b/src/plugins/platforms/wasm/qwasminputcontext.cpp index 1bf8b5f1683..1c004b226fa 100644 --- a/src/plugins/platforms/wasm/qwasminputcontext.cpp +++ b/src/plugins/platforms/wasm/qwasminputcontext.cpp @@ -144,7 +144,7 @@ void QWasmInputContext::inputStringChanged(QString &inputString, QWasmInputConte Q_UNUSED(context) QKeySequence keys = QKeySequence::fromString(inputString); // synthesize this keyevent as android is not normal - QWindowSystemInterface::handleKeyEvent( + QWindowSystemInterface::handleKeyEvent( 0, QEvent::KeyPress,keys[0].key(), keys[0].keyboardModifiers(), inputString); }