Reset the velocity Kalman filter when the mouse enters a window
If we always tracked the mouse, we could always have accurate velocity; but most of the time, when the mouse enters a top-level window, we don't know how fast it was moving at that time, unless the application has requested a window-system mouse grab. It's better to assume that any residual velocity stored in the persistent QEventPoint instance (in QPointingDevicePrivate::activePoints) is inaccurate, and just start over from zero. Especially for the sake of autotest sanity. Task-number: QTBUG-88346 Change-Id: Id6c4fbffb8a86a8ab50a09f09aa62125d10155b4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
73e64a98c6
commit
4ccfe7b734
@ -2417,7 +2417,19 @@ void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::En
|
||||
|
||||
currentMouseWindow = e->enter;
|
||||
|
||||
// TODO later: EnterEvent must report _which_ mouse entered the window; for now we assume primaryPointingDevice()
|
||||
QEnterEvent event(e->localPos, e->localPos, e->globalPos);
|
||||
|
||||
// Since we don't always track mouse moves that occur outside a window, any residual velocity
|
||||
// stored in the persistent QEventPoint may be inaccurate (especially in fast-moving autotests).
|
||||
// Reset the Kalman filter so that the velocity of the first mouse event after entering the window
|
||||
// will be based on a zero residual velocity (but the result can still be non-zero if the mouse
|
||||
// moves to a different position from where this enter event occurred; tests often do that).
|
||||
const QPointingDevicePrivate *devPriv = QPointingDevicePrivate::get(event.pointingDevice());
|
||||
auto epd = devPriv->queryPointById(event.points().first().id());
|
||||
Q_ASSERT(epd);
|
||||
QMutableEventPoint::from(epd->eventPoint).setVelocity({});
|
||||
|
||||
QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user