QNativeGestureEvent: clean up for Qt 6

Make the touch device a member instead of holding it in a static
QHash, indexed by event address.

Change-Id: I21588ede2ebdde70eea2844ded2fb880700b92fb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Marc Mutz 2019-08-22 10:38:50 +02:00
parent 8811e96aac
commit 92a9778026
2 changed files with 5 additions and 15 deletions

View File

@ -2686,10 +2686,6 @@ QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPoin
{ }
#endif
typedef QHash<const QNativeGestureEvent*, const QTouchDevice*> NativeGestureEventDataHash;
// ### Qt6: move this to a member in QNativeGestureEvent
Q_GLOBAL_STATIC(NativeGestureEventDataHash, g_nativeGestureEventDataHash)
/*!
Constructs a native gesture event of type \a type originating from \a device.
@ -2704,27 +2700,20 @@ QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouc
const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue)
: QInputEvent(QEvent::NativeGesture), mGestureType(type),
mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue),
mSequenceId(sequenceId), mIntValue(intValue)
mSequenceId(sequenceId), mIntValue(intValue), mDevice(device)
{
g_nativeGestureEventDataHash->insert(this, device);
}
QNativeGestureEvent::~QNativeGestureEvent()
{
g_nativeGestureEventDataHash->remove(this);
}
= default;
/*!
\fn const QTouchDevice *QNativeGestureEvent::device() const
\since 5.10
Returns the device.
*/
const QTouchDevice *QNativeGestureEvent::device() const
{
return g_nativeGestureEventDataHash->value(this);
}
/*!
\fn QNativeGestureEvent::gestureType() const
\since 5.2

View File

@ -350,7 +350,7 @@ public:
const QPointF &windowPos() const { return mWindowPos; }
const QPointF &screenPos() const { return mScreenPos; }
const QTouchDevice *device() const;
const QTouchDevice *device() const { return mDevice; }
protected:
Qt::NativeGestureType mGestureType;
@ -360,6 +360,7 @@ protected:
qreal mRealValue;
ulong mSequenceId;
quint64 mIntValue;
const QTouchDevice *mDevice;
};
#endif // QT_NO_GESTURES