Set QEventPoint::state properly in QSinglePointEvent

State was Unknown by default, and that is OK in widgets so far, because
widgets pay attention to the event type, not QEventPoint::state().
But Qt Quick cares about that, because QEventPoint turns into
QQuickEventPoint, in which state() has long been important, due to
the semi-unified handling of mouse and touch events.

If it was not a button that caused the event, state is Updated (the
mouse is hovering or dragging, or it's an enter event, wheel event etc.)
If more buttons are now held than before, state is Pressed.
If fewer buttons are now held than before, state is Released.

Amends 4e400369c0

Change-Id: I926d268982449e46e7ca713c4a6ee2014c28c645
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Shawn Rutledge 2020-07-15 10:47:55 +02:00
parent 1ebb891c2f
commit 5ca5dfa89e

View File

@ -350,6 +350,12 @@ QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *d
m_reserved(0)
{
QMutableEventPoint &mut = QMutableEventPoint::from(m_point);
if (button == Qt::NoButton)
mut.setState(QEventPoint::State::Updated); // stationary only happens with touch events, not single-point events
else if ((button | buttons) == buttons)
mut.setState(QEventPoint::State::Pressed);
else
mut.setState(QEventPoint::State::Released);
mut.setPosition(localPos);
mut.setScenePosition(scenePos);
mut.setGlobalPosition(globalPos);