summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Skoland <david.skoland@qt.io>2021-12-06 13:43:34 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2022-12-20 18:13:47 +0000
commit4b1229e5235412062a5240410ec49e358019507c (patch)
treea7610c8f717f11e9a24ed6099b0455d2772cd07d /src
parentaf0f13b46053254c7b2416a1f71a95d141247600 (diff)
Set WASM platform default to synchronous window event handling
Based on existing code, it appears that it's always preferred in wasm to use synchronous delivery (<QWindowSystemInterface::SynchronousDelivery>), 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 <morten.sorvig@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/wasm/qwasmclipboard.cpp6
-rw-r--r--src/plugins/platforms/wasm/qwasmcompositor.cpp14
-rw-r--r--src/plugins/platforms/wasm/qwasminputcontext.cpp2
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::SynchronousDelivery>(
+ 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::SynchronousDelivery>(
+ 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::SynchronousDelivery>(
+ 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::SynchronousDelivery>(
+ 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::SynchronousDelivery>(
+ 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::SynchronousDelivery>(
+ 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<QWindowSystemInterface::SynchronousDelivery>(
+ accepted = QWindowSystemInterface::handleTouchEvent(
targetWindow, QWasmIntegration::getTimestamp(), m_touchDevice.get(), touchPointList, keyModifier);
return static_cast<int>(accepted);
@@ -721,12 +723,12 @@ void QWasmCompositor::releaseCapture()
void QWasmCompositor::leaveWindow(QWindow *window)
{
m_windowUnderMouse = nullptr;
- QWindowSystemInterface::handleLeaveEvent<QWindowSystemInterface::SynchronousDelivery>(window);
+ QWindowSystemInterface::handleLeaveEvent(window);
}
void QWasmCompositor::enterWindow(QWindow *window, const QPoint &pointInTargetWindowCoords, const QPoint &targetPointInScreenCoords)
{
- QWindowSystemInterface::handleEnterEvent<QWindowSystemInterface::SynchronousDelivery>(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::SynchronousDelivery>(
+ QWindowSystemInterface::handleKeyEvent(
0, QEvent::KeyPress,keys[0].key(), keys[0].keyboardModifiers(), inputString);
}