wasm: fix mouse double click
Two issues here, timestamp value was getting smashed, and MouseButtonDblClick was not getting sent. Fixes: QTBUG-85712 Pick-to: 5.15 Change-Id: I912e968f1eb0fb9c6f4cf8548b114e23d182396e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>bb10
parent
ed8b8ffde4
commit
f785849768
|
|
@ -329,9 +329,16 @@ QWasmEventTranslator::QWasmEventTranslator(QWasmScreen *screen)
|
|||
, pressedButtons(Qt::NoButton)
|
||||
, resizeMode(QWasmWindow::ResizeNone)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
touchDevice = new QPointingDevice("touchscreen", 1, QInputDevice::DeviceType::TouchScreen,
|
||||
QPointingDevice::PointerType::Finger,
|
||||
QPointingDevice::Capability::Position | QPointingDevice::Capability::Area | QPointingDevice::Capability::NormalizedPosition,
|
||||
10, 0);
|
||||
#else
|
||||
touchDevice = new QPointingDevice;
|
||||
touchDevice->setType(QInputDevice::DeviceType::TouchScreen);
|
||||
touchDevice->setCapabilities(QPointingDevice::Capability::Position | QPointingDevice::Capability::Area | QPointingDevice::Capability::NormalizedPosition);
|
||||
#endif
|
||||
QWindowSystemInterface::registerInputDevice(touchDevice);
|
||||
|
||||
initEventHandlers();
|
||||
|
|
@ -566,7 +573,6 @@ void resizeWindow(QWindow *window, QWasmWindow::ResizeMode mode,
|
|||
|
||||
void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent)
|
||||
{
|
||||
auto timestamp = emscripten_date_now();
|
||||
QPoint targetPoint(mouseEvent->targetX, mouseEvent->targetY);
|
||||
QPoint globalPoint = screen()->geometry().topLeft() + targetPoint;
|
||||
|
||||
|
|
@ -630,6 +636,8 @@ void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven
|
|||
|
||||
if (oldWindow)
|
||||
oldWindow->injectMouseReleased(localPoint, globalPoint, button, modifiers);
|
||||
else
|
||||
htmlWindow->injectMouseReleased(localPoint, globalPoint, button, modifiers);
|
||||
break;
|
||||
}
|
||||
case EMSCRIPTEN_EVENT_MOUSEMOVE: // drag event
|
||||
|
|
@ -658,7 +666,7 @@ void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven
|
|||
}
|
||||
if (window2 && interior) {
|
||||
QWindowSystemInterface::handleMouseEvent<QWindowSystemInterface::SynchronousDelivery>(
|
||||
window2, timestamp, localPoint, globalPoint, pressedButtons, button, buttonEventType, modifiers);
|
||||
window2, getTimestamp(), localPoint, globalPoint, pressedButtons, button, buttonEventType, modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -692,7 +700,6 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh
|
|||
|
||||
QWasmEventTranslator *translator = (QWasmEventTranslator*)userData;
|
||||
Qt::KeyboardModifiers modifiers = translator->translateMouseEventModifier(&mouseEvent);
|
||||
auto timestamp = emscripten_date_now();
|
||||
QPoint targetPoint(mouseEvent.targetX, mouseEvent.targetY);
|
||||
QPoint globalPoint = eventTranslator->screen()->geometry().topLeft() + targetPoint;
|
||||
|
||||
|
|
@ -706,7 +713,7 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh
|
|||
if (wheelEvent->deltaY != 0) pixelDelta.setY(wheelEvent->deltaY * scrollFactor);
|
||||
if (wheelEvent->deltaX != 0) pixelDelta.setX(wheelEvent->deltaX * scrollFactor);
|
||||
|
||||
QWindowSystemInterface::handleWheelEvent(window2, timestamp, localPoint,
|
||||
QWindowSystemInterface::handleWheelEvent(window2, getTimestamp(), localPoint,
|
||||
globalPoint, QPoint(), pixelDelta, modifiers);
|
||||
QWasmEventDispatcher::maintainTimers();
|
||||
|
||||
|
|
@ -799,7 +806,7 @@ int QWasmEventTranslator::handleTouch(int eventType, const EmscriptenTouchEvent
|
|||
|
||||
quint64 QWasmEventTranslator::getTimestamp()
|
||||
{
|
||||
return QDeadlineTimer::current().deadlineNSecs() / 1000;
|
||||
return emscripten_performance_now();
|
||||
}
|
||||
|
||||
struct KeyMapping { Qt::Key from, to; };
|
||||
|
|
|
|||
|
|
@ -35,7 +35,11 @@
|
|||
#include <QtCore/qpoint.h>
|
||||
#include <emscripten/html5.h>
|
||||
#include "qwasmwindow.h"
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QtGui/qinputdevice.h>
|
||||
#else
|
||||
#include <QtGui/qpointingdevice.h>
|
||||
#endif
|
||||
#include <QHash>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
@ -89,8 +93,12 @@ private:
|
|||
QWasmWindow::ResizeMode resizeMode;
|
||||
QPoint resizePoint;
|
||||
QRect resizeStartRect;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QPointingDevice *touchDevice;
|
||||
quint64 getTimestamp();
|
||||
#else
|
||||
QTouchDevice *touchDevice;
|
||||
#endif
|
||||
static quint64 getTimestamp();
|
||||
|
||||
Qt::Key m_emDeadKey = Qt::Key_unknown;
|
||||
bool m_emStickyDeadKey = false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue