--- src/gui/kernel/qguiapplication.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 690a6f2412..fcbc853fb1 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2247,20 +2247,35 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo auto persistentEPD = devPriv->pointById(0); if (mouseMove) { + // See comment in the else section. + // This static variable is used to persist the last touch/click position - has the same bug as the one + // described in the else statement below but hasn't yet been fixed in qt. + static QPointF lastPressPos; QGuiApplicationPrivate::lastCursorPosition = globalPoint; const auto doubleClickDistance = (e->device && e->device->type() == QInputDevice::DeviceType::Mouse ? mouseDoubleClickDistance : touchDoubleTapDistance); - const auto pressPos = persistentEPD->eventPoint.globalPressPosition(); + const auto pressPos = lastPressPos; + lastPressPos = globalPoint; + if (qAbs(globalPoint.x() - pressPos.x()) > doubleClickDistance || qAbs(globalPoint.y() - pressPos.y()) > doubleClickDistance) mousePressButton = Qt::NoButton; } else { + // Static variable is used to help manage synthesised mouse events so screen double tap works. Using a static + // variable here is really ugly (and in my view is not the right way to fix it), but it's the approach the qt + // folks have taken in: + // https://codereview.qt-project.org/c/qt/qtbase/+/516578 + // Unfortunately, to fix this properly is non-trival - there is a lot of complexity in the interactions with + // persistentEPD (from multiple event handling functions) and a lot of different scenarios to cater for. + // I expect qt will likely change this again in due course + static unsigned long lastPressTimestamp = 0; mouse_buttons = e->buttons; if (mousePress) { ulong doubleClickInterval = static_cast(QGuiApplication::styleHints()->mouseDoubleClickInterval()); - doubleClick = e->timestamp - persistentEPD->eventPoint.pressTimestamp() + doubleClick = e->timestamp - lastPressTimestamp < doubleClickInterval && button == mousePressButton; mousePressButton = button; + lastPressTimestamp = e->timestamp; } } -- 2.25.1