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>
This commit is contained in:
David Skoland 2021-12-06 13:43:34 +01:00 committed by Morten Johan Sørvig
parent af0f13b460
commit 4b1229e523
3 changed files with 12 additions and 10 deletions

View File

@ -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");
}

View File

@ -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)

View File

@ -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);
}