QGuiApplication: Fix condition for when doubleclick events are triggered
QGuiApplicationPrivate::processMouseEvent() requires the following conditions to be met in order to trigger a double click event: 1. The same button should be pressed (kept in mousePressButton member) 2. The time between two press events should not exceed doubleClickInterval 3. Movement between presses shouldn't be bigger than doubleClickDistance Unfortunately, when we are processing *synthesized* mouse events (from touch), in order to check criterion 2) we cannot rely on QPointingDevicePrivate::pointById(0)->eventPoint.pressTimestamp(); because this was already updated in QGuiApplication::processTouchEvent(), so it does not any longer reflect the *previous* press timestamp, but the current one. Therefore we could not reliably calculate the time between the previous press and the current press (in fact, it never exceeded the doubleClickInterval condition) I suspect this occurs with all touchscreens, but at least it was reproduced with e.g. a NVIDIA Terra / Thinkvision touch screen on Windows 11 and Dell Express SVC touch screen on Windows 11. => Since QGuiApplication is a singleton, add a static local variable to remember the time stamp of the last processed press event. Autotesting has been modelled in PS7. However, QTest::touchEvent is unable to synthesize hardware specific detection latency and stray touch events, which actually reproduce the issue. => Not adding an autotest. Fixes: QTBUG-112479 Fixes: QTBUG-119032 Fixes: QTBUG-100688 Pick-to: 6.6 6.5 Change-Id: Idc97fb9d49ed334f56d702d420451fc062e9b5a9 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
a180dc5e27
commit
4bb230f65e
@ -2256,12 +2256,14 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
|
||||
qAbs(globalPoint.y() - pressPos.y()) > doubleClickDistance)
|
||||
mousePressButton = Qt::NoButton;
|
||||
} else {
|
||||
static unsigned long lastPressTimestamp = 0;
|
||||
mouse_buttons = e->buttons;
|
||||
if (mousePress) {
|
||||
ulong doubleClickInterval = static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval());
|
||||
doubleClick = e->timestamp - persistentEPD->eventPoint.pressTimestamp()
|
||||
doubleClick = e->timestamp - lastPressTimestamp
|
||||
< doubleClickInterval && button == mousePressButton;
|
||||
mousePressButton = button;
|
||||
lastPressTimestamp = e ->timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user