summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-07-15 10:47:55 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-07-15 12:55:19 +0200
commit5ca5dfa89e05c6deda6cd9282cd505eb324228cd (patch)
tree16807d1b11ed7f3ff24f70a1fb171706763ec2d5 /src/gui/kernel/qevent.cpp
parent1ebb891c2f9f31429e9238e31b3f4211a5118b56 (diff)
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 4e400369c08db251cd489fec1229398c224d02b4 Change-Id: I926d268982449e46e7ca713c4a6ee2014c28c645 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r--src/gui/kernel/qevent.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index c77a6b23c6..0284dc2098 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -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);