From b9873b7dde4042445dbb5ff3c46cea96b2dea4aa Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 3 Aug 2020 13:07:47 +0200 Subject: [PATCH] Add QEventPoint::pressTimestamp() and priv setPressTimestamp() There was no good reason for QEventPoint::pressTimestamp() to be missing. The case for QEventPoint::timestamp() is a bit dubious because it's redundant with QInputEvent::timestamp(); but for now, we keep m_timestamp, in anticipation that Qt Quick may need to keep copies of eventpoints between events, thus they need to avoid depending on their shorter-lived parent events too much. Change-Id: Iec38acfdfaa2afb3dc77d5cd1b95baa8d301c0fd Reviewed-by: Fabian Kosmale --- src/gui/kernel/qevent.h | 3 ++- src/gui/kernel/qevent_p.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 79a3ea3378..cfbaf8603e 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -154,6 +154,7 @@ public: State state() const { return m_state; } int id() const { return m_pointId; } QPointingDeviceUniqueId uniqueId() const { return m_uniqueId; } + ulong pressTimestamp() const { return m_pressTimestamp; } qreal timeHeld() const { return (m_timestamp - m_pressTimestamp) / qreal(1000); } qreal pressure() const { return m_pressure; } qreal rotation() const { return m_rotation; } @@ -177,7 +178,7 @@ protected: QVector2D m_velocity; QPointer m_exclusiveGrabber; QList > m_passiveGrabbers; - ulong m_timestamp = 0; + ulong m_timestamp = 0; // redundant with m_parent->timestamp(), but keeps timeHeld() working in a saved copy ulong m_pressTimestamp = 0; QPointingDeviceUniqueId m_uniqueId; int m_pointId = -1; diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 25cce4b3a4..275a56eeb6 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -88,6 +88,8 @@ public: void setTimestamp(const ulong t) { m_timestamp = t; } + void setPressTimestamp(const ulong t) { m_pressTimestamp = t; } + void setState(QEventPoint::State state) { m_state = state; } void setUniqueId(const QPointingDeviceUniqueId &uid) { m_uniqueId = uid; }