aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickpointerhandler_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-07-23 13:56:26 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-09-18 20:56:25 +0200
commita97759a336c597327cb82eebc9f45c793aec32c9 (patch)
tree632bbee8568d38af56974e02df5810afcf48aedc /src/quick/handlers/qquickpointerhandler_p.h
parent39f4d687fc37f48cbc181f42797c42be91b4a345 (diff)
Remove QQuickPointerEvent etc.; deliver QPointerEvents directly
QEventPoint does not have an accessor to get the QPointerEvent that it came from, because that's inconsistent with the idea that QPointerEvent instances are temporary, stack-allocated and movable (the pointer would often be wrong or null, therefore could not be relied upon). So most functions that worked directly with QQuickEventPoint before (which fortunately are still private API) now need to receive the QPointerEvent too, which we choose to pass by pointer. QEventPoint is always passed by reference (const where possible) to be consistent with functions in QPointerEvent that take QEventPoint by reference. QEventPoint::velocity() should be always in scene coordinates now, which saves us the trouble of transforming it to each item's coordinate system during delivery, but means that it will need to be done in handlers or applications sometimes. If we were going to transform it, it would be important to also store the sceneVelocity separately in QEventPoint so that the transformation could be done repeatedly for different items. Task-number: QTBUG-72173 Change-Id: I7ee164d2e6893c4e407fb7d579c75aa32843933a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickpointerhandler_p.h')
-rw-r--r--src/quick/handlers/qquickpointerhandler_p.h36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/quick/handlers/qquickpointerhandler_p.h b/src/quick/handlers/qquickpointerhandler_p.h
index 3e7876b3d9..8d7fdcdcad 100644
--- a/src/quick/handlers/qquickpointerhandler_p.h
+++ b/src/quick/handlers/qquickpointerhandler_p.h
@@ -110,7 +110,7 @@ public:
QQuickItem * parentItem() const;
- void handlePointerEvent(QQuickPointerEvent *event);
+ void handlePointerEvent(QPointerEvent *event);
GrabPermissions grabPermissions() const;
void setGrabPermissions(GrabPermissions grabPermissions);
@@ -135,9 +135,9 @@ Q_SIGNALS:
void targetChanged();
void marginChanged();
Q_REVISION(2, 15) void dragThresholdChanged();
- void grabChanged(QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point);
+ void grabChanged(QPointingDevice::GrabTransition transition, QEventPoint point);
void grabPermissionChanged();
- void canceled(QQuickEventPoint *point);
+ void canceled(QEventPoint point);
#if QT_CONFIG(cursor)
Q_REVISION(2, 15) void cursorShapeChanged();
#endif
@@ -147,24 +147,26 @@ protected:
void classBegin() override;
void componentComplete() override;
+ bool event(QEvent *) override;
- QQuickPointerEvent *currentEvent();
- virtual bool wantsPointerEvent(QQuickPointerEvent *event);
- virtual bool wantsEventPoint(QQuickEventPoint *point);
- virtual void handlePointerEventImpl(QQuickPointerEvent *event);
+ QPointerEvent *currentEvent();
+ virtual bool wantsPointerEvent(QPointerEvent *event);
+ virtual bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point);
+ virtual void handlePointerEventImpl(QPointerEvent *event);
void setActive(bool active);
virtual void onTargetChanged(QQuickItem *oldTarget) { Q_UNUSED(oldTarget); }
virtual void onActiveChanged() { }
- virtual void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point);
- virtual bool canGrab(QQuickEventPoint *point);
- virtual bool approveGrabTransition(QQuickEventPoint *point, QObject *proposedGrabber);
- void setPassiveGrab(QQuickEventPoint *point, bool grab = true);
- bool setExclusiveGrab(QQuickEventPoint *point, bool grab = true);
- void cancelAllGrabs(QQuickEventPoint *point);
- QPointF eventPos(const QQuickEventPoint *point) const;
- bool parentContains(const QQuickEventPoint *point) const;
-
- friend class QQuickEventPoint;
+ virtual void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition,
+ QPointerEvent *event, QEventPoint &point);
+ virtual bool canGrab(QPointerEvent *event, const QEventPoint &point);
+ virtual bool approveGrabTransition(QPointerEvent *event, const QEventPoint &point, QObject *proposedGrabber);
+ void setPassiveGrab(QPointerEvent *event, const QEventPoint &point, bool grab = true);
+ bool setExclusiveGrab(QPointerEvent *ev, const QEventPoint &point, bool grab = true);
+ void cancelAllGrabs(QPointerEvent *event, QEventPoint &point);
+ QPointF eventPos(const QEventPoint &point) const;
+ bool parentContains(const QEventPoint &point) const;
+ bool parentContains(const QPointF &scenePosition) const;
+
friend class QQuickItemPrivate;
friend class QQuickWindowPrivate;