aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickwindow_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/items/qquickwindow_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/items/qquickwindow_p.h')
-rw-r--r--src/quick/items/qquickwindow_p.h55
1 files changed, 33 insertions, 22 deletions
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index 2046fb0462..632cf1b6da 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -64,8 +64,10 @@
#include <QtCore/qmutex.h>
#include <QtCore/qwaitcondition.h>
#include <QtCore/qrunnable.h>
+#include <QtCore/qstack.h>
#include <QtGui/private/qevent_p.h>
+#include <QtGui/private/qpointingdevice_p.h>
#include <QtGui/private/qwindow_p.h>
#include <QtGui/qevent.h>
#include <QtGui/qstylehints.h>
@@ -150,28 +152,33 @@ public:
#if QT_CONFIG(quick_draganddrop)
QQuickDragGrabber *dragGrabber;
#endif
- int touchMouseId;
+ QStack<QPointerEvent *> eventsInDelivery;
+
+ int touchMouseId; // only for obsolete stuff like QQuickItem::grabMouse()
+ // TODO get rid of these
const QPointingDevice *touchMouseDevice;
- bool checkIfDoubleTapped(ulong newPressEventTimestamp, QPoint newPressPos);
ulong touchMousePressTimestamp;
QPoint touchMousePressPos; // in screen coordiantes
+ bool isDeliveringTouchAsMouse() const { return touchMouseId != -1 && touchMouseDevice; }
void cancelTouchMouseSynthesis();
+ bool checkIfDoubleTapped(ulong newPressEventTimestamp, QPoint newPressPos);
+ QPointingDevicePrivate::EventPointData *mousePointData();
+ QPointerEvent *eventInDelivery() const;
+
// Mouse positions are saved in widget coordinates
QPointF lastMousePosition;
- bool deliverTouchAsMouse(QQuickItem *item, QQuickPointerEvent *pointerEvent);
- bool isDeliveringTouchAsMouse() const { return touchMouseId != -1 && touchMouseDevice; }
+ bool deliverTouchAsMouse(QQuickItem *item, QTouchEvent *pointerEvent);
void translateTouchEvent(QTouchEvent *touchEvent);
- void grabTouchPoints(QObject *grabber, const QVector<int> &ids);
void removeGrabber(QQuickItem *grabber, bool mouse = true, bool touch = true);
void sendUngrabEvent(QQuickItem *grabber, bool touch);
+ void onGrabChanged(QObject *grabber, QPointingDevice::GrabTransition transition, const QPointerEvent *event, const QEventPoint &point);
static QMouseEvent *cloneMouseEvent(QMouseEvent *event, QPointF *transformedLocalPos = nullptr);
- void deliverToPassiveGrabbers(const QVector<QPointer <QQuickPointerHandler> > &passiveGrabbers, QQuickPointerEvent *pointerEvent);
- void deliverMouseEvent(QQuickPointerMouseEvent *pointerEvent);
+ void deliverToPassiveGrabbers(const QVector<QPointer<QObject> > &passiveGrabbers, QPointerEvent *pointerEvent);
bool sendFilteredMouseEvent(QEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
- bool sendFilteredPointerEvent(QQuickPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent = nullptr);
- bool sendFilteredPointerEventImpl(QQuickPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
- bool deliverSinglePointEventUntilAccepted(QQuickPointerEvent *);
+ bool sendFilteredPointerEvent(QPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent = nullptr);
+ bool sendFilteredPointerEventImpl(QPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
+ bool deliverSinglePointEventUntilAccepted(QPointerEvent *);
// entry point of events to the window
void handleTouchEvent(QTouchEvent *);
@@ -180,22 +187,25 @@ public:
void flushFrameSynchronousEvents();
void deliverDelayedTouchEvent();
- // the device-specific event instances which are reused during event delivery
- mutable QVector<QQuickPointerEvent *> pointerEventInstances;
- QQuickPointerEvent *queryPointerEventInstance(const QPointingDevice *device, QEvent::Type eventType = QEvent::None) const;
- QQuickPointerEvent *pointerEventInstance(const QPointingDevice *device, QEvent::Type eventType = QEvent::None) const;
+ // utility functions that used to be in QQuickPointerEvent et al.
+ bool allUpdatedPointsAccepted(const QPointerEvent *ev);
+ void localizePointerEvent(QPointerEvent *ev, const QQuickItem *dest);
+ QList<QObject *> exclusiveGrabbers(QPointerEvent *ev);
+ static bool isMouseEvent(const QPointerEvent *ev);
+ static bool isTouchEvent(const QPointerEvent *ev);
+ static bool isTabletEvent(const QPointerEvent *ev);
// delivery of pointer events:
- QMouseEvent *touchToMouseEvent(QEvent::Type type, const QEventPoint &p, QTouchEvent *event, QQuickItem *item, bool transformNeeded = true);
- QQuickPointerEvent *pointerEventInstance(QEvent *ev) const;
- void deliverPointerEvent(QQuickPointerEvent *);
- void deliverTouchEvent(QQuickPointerTouchEvent *);
+ QMouseEvent touchToMouseEvent(QEvent::Type type, const QEventPoint &p, QTouchEvent *event, QQuickItem *item);
+ void ensureDeviceConnected(const QPointingDevice *dev);
+ void deliverPointerEvent(QPointerEvent *);
bool deliverTouchCancelEvent(QTouchEvent *);
- bool deliverPressOrReleaseEvent(QQuickPointerEvent *, bool handlersOnly = false);
- void deliverUpdatedTouchPoints(QQuickPointerTouchEvent *event);
- void deliverMatchingPointsToItem(QQuickItem *item, QQuickPointerEvent *pointerEvent, bool handlersOnly = false);
+ bool deliverPressOrReleaseEvent(QPointerEvent *, bool handlersOnly = false);
+ void deliverUpdatedPoints(QPointerEvent *event);
+ void deliverMatchingPointsToItem(QQuickItem *item, bool isGrabber, QPointerEvent *pointerEvent, bool handlersOnly = false);
- QVector<QQuickItem *> pointerTargets(QQuickItem *, QQuickEventPoint *point, bool checkMouseButtons, bool checkAcceptsTouch) const;
+ QVector<QQuickItem *> pointerTargets(QQuickItem *, const QPointerEvent *event, const QEventPoint &point,
+ bool checkMouseButtons, bool checkAcceptsTouch) const;
QVector<QQuickItem *> mergePointerTargets(const QVector<QQuickItem *> &list1, const QVector<QQuickItem *> &list2) const;
// hover delivery
@@ -277,6 +287,7 @@ public:
QQuickRenderControl *renderControl;
QScopedPointer<QQuickAnimatorController> animationController;
QScopedPointer<QMutableTouchEvent> delayedTouch;
+ QList<const QPointingDevice *> knownPointingDevices;
int pointerEventRecursionGuard;