Discard extra mouse move event generated by touchpad

On Windows, and possibly other platforms, a touchpad can send a mouse
button press followed by an unexpected mouse move event to the same
coordinates, before sending a mouse button release, which may confuse
applications. Before the enhanced mouse event processing was added, the
code in QGuiApplication was responsible for deducing the mouse event
type and other info, and in the process performed a checking that
discarded events that did not change state. The enhanced mouse
processing code lacked this checking. This change adds an equivalent
checking to the enhanced mouse event processing.

Fixes: QTBUG-85431
Pick-to: 5.15
Change-Id: Ie3e2ae8cbf9870d465dfd2c8808942dd6fc647d2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Andre de la Rocha 2020-07-18 01:52:49 -03:00
parent e4e4bb78b7
commit b50daef977

View File

@ -2110,6 +2110,13 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
processMouseEvent(e); // the original mouse event
return;
}
if (mouseMove && !positionChanged) {
// On Windows, and possibly other platforms, a touchpad can send a mouse move
// that does not change position, between a press and a release. This may
// confuse applications, so we always filter out these mouse events for
// consistent behavior among platforms.
return;
}
} else {
Qt::MouseButtons stateChange = e->buttons ^ mouse_buttons;
if (positionChanged && (stateChange != Qt::NoButton)) {