diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-09-03 13:32:55 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-09-10 03:15:49 +0200 |
commit | ae7442a4e93d4a63f28c1c2692be80a3d87f54a9 (patch) | |
tree | 2fb51f24ca4557f06a3ae209521a83d9a03c972a /src/gui/kernel/qevent.h | |
parent | db3d5a30973eef3d3abc767e625923c13f8cf327 (diff) | |
download | qtbase-ae7442a4e93d4a63f28c1c2692be80a3d87f54a9.tar.gz |
Give QEventPoint a d-pointer after all
I still have doubts that QEventPoint can't be made small enough that
copying would be cheaper than reference-counting and all the indirections
in now-noninline accessors, but this gives us the usual freedom to
change the data members later on.
Change-Id: I792f7fc85ac3a9538589da9d7618b647edf0e70c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent.h')
-rw-r--r-- | src/gui/kernel/qevent.h | 85 |
1 files changed, 34 insertions, 51 deletions
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index c8402b6632..eed6b93156 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -90,10 +90,7 @@ protected: qint64 m_extra = 0; // reserved, unused for now }; -namespace QTest { - class QTouchEventSequence; // just for the friend declaration below -} - +struct QEventPointPrivate; class Q_GUI_EXPORT QEventPoint { Q_GADGET @@ -110,19 +107,22 @@ public: QEventPoint(int id = -1, const QPointingDevice *device = nullptr); QEventPoint(int pointId, State state, const QPointF &scenePosition, const QPointF &globalPosition); - - QPointF position() const { return m_pos; } - QPointF pressPosition() const { return m_globalPressPos - m_globalPos + m_pos; } - QPointF grabPosition() const { return m_globalGrabPos - m_globalPos + m_pos; } - QPointF lastPosition() const { return m_globalLastPos - m_globalPos + m_pos; } - QPointF scenePosition() const { return m_scenePos; } - QPointF scenePressPosition() const { return m_globalPressPos - m_globalPos + m_scenePos; } - QPointF sceneGrabPosition() const { return m_globalGrabPos - m_globalPos + m_scenePos; } - QPointF sceneLastPosition() const { return m_globalLastPos - m_globalPos + m_scenePos; } - QPointF globalPosition() const { return m_globalPos; } - QPointF globalPressPosition() const { return m_globalPressPos; } - QPointF globalGrabPosition() const { return m_globalGrabPos; } - QPointF globalLastPosition() const { return m_globalLastPos; } + QEventPoint(const QEventPoint &other); + QEventPoint &operator=(const QEventPoint &other); + ~QEventPoint(); + + QPointF position() const; + QPointF pressPosition() const; + QPointF grabPosition() const; + QPointF lastPosition() const; + QPointF scenePosition() const; + QPointF scenePressPosition() const; + QPointF sceneGrabPosition() const; + QPointF sceneLastPosition() const; + QPointF globalPosition() const; + QPointF globalPressPosition() const; + QPointF globalGrabPosition() const; + QPointF globalLastPosition() const; #if QT_DEPRECATED_SINCE(6, 0) // QEventPoint replaces QTouchEvent::TouchPoint, so we need all its old accessors, for now @@ -151,45 +151,28 @@ public: QT_DEPRECATED_VERSION_X_6_0("Use globalLastPosition()") QPointF lastNormalizedPos() const; #endif // QT_DEPRECATED_SINCE(6, 0) - QVector2D velocity() const { return m_velocity; } - State state() const { return m_state; } - const QPointingDevice *device() const { return m_device; } - 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; } - QSizeF ellipseDiameters() const { return m_ellipseDiameters; } - - bool isAccepted() const { return m_accept; } + QVector2D velocity() const; + State state() const; + const QPointingDevice *device() const; + int id() const; + QPointingDeviceUniqueId uniqueId() const; + ulong pressTimestamp() const; + qreal timeHeld() const; + qreal pressure() const; + qreal rotation() const; + QSizeF ellipseDiameters() const; + + bool isAccepted() const; void setAccepted(bool accepted = true); - QObject *exclusiveGrabber() const { return m_exclusiveGrabber.data(); } + QObject *exclusiveGrabber() const; void setExclusiveGrabber(QObject *exclusiveGrabber); - const QList<QPointer <QObject>> &passiveGrabbers() const { return m_passiveGrabbers; } + const QList<QPointer <QObject>> &passiveGrabbers() const; void setPassiveGrabbers(const QList<QPointer <QObject>> &grabbers); void clearPassiveGrabbers(); -protected: - const QPointingDevice *m_device = nullptr; - QPointF m_pos, m_scenePos, m_globalPos, - m_globalPressPos, m_globalGrabPos, m_globalLastPos; - qreal m_pressure = 1; - qreal m_rotation = 0; - QSizeF m_ellipseDiameters = QSizeF(0, 0); - QVector2D m_velocity; - QPointer<QObject> m_exclusiveGrabber; - QList<QPointer <QObject> > m_passiveGrabbers; - ulong m_timestamp = 0; - ulong m_pressTimestamp = 0; - QPointingDeviceUniqueId m_uniqueId; - int m_pointId = -1; - State m_state : 8; - quint32 m_accept : 1; - quint32 m_stationaryWithModifiedProperty : 1; - quint32 m_reserved : 22; - - friend class QTest::QTouchEventSequence; +private: + QEventPointPrivate *d; + friend class QMutableEventPoint; }; #ifndef QT_NO_DEBUG_STREAM |