diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-01-18 13:53:07 +0100 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2017-02-07 16:30:18 +0000 |
commit | fb8058e5bfbd412e4503eb280721e4875fda0936 (patch) | |
tree | e24830323e33f826071d28ba7f8c0e0160a8fa5d /src/quick/items/qquickevents_p_p.h | |
parent | e2fd141372335f917c2d216051abb00d8b15f87c (diff) |
QQuickWindow: use QVector eventDeliveryTargets to avoid repeated delivery
If no handler or item accepts a newly-pressed point, the event will be
re-delivered in deliverTouchEvent(). It doesn't make sense to
re-deliver to the same handlers though.
A temporary QSet isn't cheap to create, whereas it seems we will need
to keep track of handlers which have already been visited, in order to
avoid visiting passively-grabbing handlers multiple times. Since both
a QVector and a QSet are heap-allocated, and we expect to have a limited
quantity of handlers grabbing at one time, a retained QVector (cleared
between events) seems to be the cheapest data structure.
Change-Id: I831e9a2576b2fcb9095e065795f2baff58115a49
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/items/qquickevents_p_p.h')
-rw-r--r-- | src/quick/items/qquickevents_p_p.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index bbfc34dacf..1751e366b2 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -553,6 +553,8 @@ public: static QQuickPointerDevice *genericMouseDevice(); static QQuickPointerDevice *tabletDevice(qint64); + QVector<QQuickPointerHandler *> &eventDeliveryTargets() { return m_eventDeliveryTargets; } + private: QQuickPointerDevice(DeviceType devType, PointerType pType, Capabilities caps, int maxPoints, int buttonCount, const QString &name, qint64 uniqueId = 0) : m_deviceType(devType), m_pointerType(pType), m_capabilities(caps) @@ -579,6 +581,7 @@ private: QPointingDeviceUniqueId m_uniqueId; // the device-specific event instance which is reused during event delivery QQuickPointerEvent *m_event; + QVector<QQuickPointerHandler *> m_eventDeliveryTargets; // during delivery, handlers which have already seen the event Q_DISABLE_COPY(QQuickPointerDevice) friend struct ConstructableQQuickPointerDevice; |