aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickevents_p_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-02-14 10:04:49 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-21 15:28:36 +0000
commit507efe5a8a2390813fb620a91b0b3b6b383f599d (patch)
treef60fdb68f5af695197673706fa5a6d3a0c93bfbe /src/quick/items/qquickevents_p_p.h
parent8967a1b7b86306879a3113b290610b03727670ff (diff)
unify handler grab state handling into onGrabChanged
onGrabChanged and handleGrab looked redundant. It was also not clear how important it is for handlers to react to passive ungrabs, overrides or cancellations. Rather than debating about when to call one of these and when not to, let's centralize the responsibility in QQuickEventPoint (because the grabber pointers are stored there, so it's the ultimate destination of any grab change), and let's notify all the relevant handlers about all changes, with enough information that each handler can decide for itself what's important and what isn't. But so far most handlers don't need to override this virtual. The base class QQuickPointerHandler takes care of setting the active property to false, rejecting the eventpoint, and unsetting keepMouseGrab and keepTouchGrab whenever grab is lost; and emitting grabChanged or canceled as appropriate to notify any QML code which needs to know. Subclasses mainly care about the change of active state: they must initiate active state themselves, and may react when it reverts to false. Change-Id: I6c7f29472d12564d74ae091b0c81fa08fe131ce7 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.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index 00da53eb48..ede0ebfde6 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -275,6 +275,17 @@ public:
};
Q_ENUM(State)
+ enum GrabState {
+ GrabPassive = 0,
+ GrabExclusive,
+ UngrabPassive,
+ UngrabExclusive,
+ CancelGrabPassive,
+ CancelGrabExclusive,
+ OverrideGrabPassive
+ };
+ Q_ENUM(GrabState)
+
QQuickEventPoint(QQuickPointerEvent *parent);
void reset(Qt::TouchPointState state, const QPointF &scenePos, quint64 pointId, ulong timestamp, const QVector2D &velocity = QVector2D());
@@ -306,6 +317,7 @@ public:
Q_INVOKABLE void cancelExclusiveGrab();
Q_INVOKABLE void cancelPassiveGrab(QQuickPointerHandler *handler);
+ bool removePassiveGrabber(QQuickPointerHandler *handler);
void cancelAllGrabs(QQuickPointerHandler *handler);
QVector<QPointer <QQuickPointerHandler> > passiveGrabbers() const { return m_passiveGrabbers; }