diff options
Diffstat (limited to 'src/quick/items/qquickwindow_p.h')
-rw-r--r-- | src/quick/items/qquickwindow_p.h | 92 |
1 files changed, 41 insertions, 51 deletions
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index 7d2b1af29b..3328eb65c4 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -53,6 +53,7 @@ #include "qquickitem.h" #include "qquickwindow.h" +#include "qquickevents_p_p.h" #include <QtQuick/private/qsgcontext_p.h> @@ -68,13 +69,19 @@ QT_BEGIN_NAMESPACE -//Make it easy to identify and customize the root item if needed - +class QOpenGLVertexArrayObjectHelper; class QQuickAnimatorController; -class QSGRenderLoop; -class QQuickRenderControl; class QQuickDragGrabber; +class QQuickItemPrivate; +class QQuickPointerDevice; +class QQuickRenderControl; +class QQuickWindowIncubationController; +class QQuickWindowPrivate; +class QQuickWindowRenderLoop; +class QSGRenderLoop; +class QTouchEvent; +//Make it easy to identify and customize the root item if needed class QQuickRootItem : public QQuickItem { Q_OBJECT @@ -85,15 +92,6 @@ public Q_SLOTS: void setHeight(int h) {QQuickItem::setHeight(qreal(h));} }; -class QQuickItemPrivate; -class QQuickWindowPrivate; - -class QTouchEvent; -class QQuickWindowRenderLoop; -class QQuickWindowIncubationController; - -class QOpenGLVertexArrayObjectHelper; - class Q_QUICK_PRIVATE_EXPORT QQuickCustomRenderStage { public: @@ -127,7 +125,6 @@ public: void deliverKeyEvent(QKeyEvent *e); // Keeps track of the item currently receiving mouse events - QQuickItem *mouseGrabberItem; #ifndef QT_NO_CURSOR QQuickItem *cursorItem; #endif @@ -135,18 +132,19 @@ public: QQuickDragGrabber *dragGrabber; #endif int touchMouseId; + QQuickPointerDevice *touchMouseDevice; bool checkIfDoubleClicked(ulong newPressEventTimestamp); ulong touchMousePressTimestamp; // Mouse positions are saved in widget coordinates QPointF lastMousePosition; - bool translateTouchToMouse(QQuickItem *item, QTouchEvent *event); + bool deliverTouchAsMouse(QQuickItem *item, QQuickPointerEvent *pointerEvent); void translateTouchEvent(QTouchEvent *touchEvent); void setMouseGrabber(QQuickItem *grabber); - static void transformTouchPoints(QList<QTouchEvent::TouchPoint> &touchPoints, const QTransform &transform); + void grabTouchPoints(QQuickItem *grabber, const QVector<int> &ids); + void removeGrabber(QQuickItem *grabber, bool mouse = true, bool touch = true); static QMouseEvent *cloneMouseEvent(QMouseEvent *event, QPointF *transformedLocalPos = 0); - bool deliverInitialMousePressEvent(QQuickItem *, QMouseEvent *); - bool deliverMouseEvent(QMouseEvent *); + void deliverMouseEvent(QQuickPointerMouseEvent *pointerEvent); bool sendFilteredMouseEvent(QQuickItem *, QQuickItem *, QEvent *, QSet<QQuickItem *> *); #ifndef QT_NO_WHEELEVENT bool deliverWheelEvent(QQuickItem *, QWheelEvent *); @@ -154,21 +152,33 @@ public: #ifndef QT_NO_GESTURES bool deliverNativeGestureEvent(QQuickItem *, QNativeGestureEvent *); #endif - bool deliverTouchPoints(QQuickItem *, QTouchEvent *, const QList<QTouchEvent::TouchPoint> &, QSet<int> *, - QHash<QQuickItem *, QList<QTouchEvent::TouchPoint> > *, QSet<QQuickItem*> *filtered); - void deliverTouchEvent(QTouchEvent *); - void reallyDeliverTouchEvent(QTouchEvent *); - bool deliverTouchCancelEvent(QTouchEvent *); + + // entry point of events to the window + void handleTouchEvent(QTouchEvent *); + void handleMouseEvent(QMouseEvent *); + bool compressTouchEvent(QTouchEvent *); + void flushFrameSynchronousEvents(); void deliverDelayedTouchEvent(); - void flushDelayedTouchEvent(); + + // delivery of pointer events: + QQuickPointerEvent *pointerEventInstance(QEvent *ev); + void deliverPointerEvent(QQuickPointerEvent *); + void deliverTouchEvent(QQuickPointerTouchEvent *); + bool deliverTouchCancelEvent(QTouchEvent *); + bool deliverPressEvent(QQuickPointerEvent *, QSet<QQuickItem *> *); + bool deliverUpdatedTouchPoints(QQuickPointerTouchEvent *event, QSet<QQuickItem *> *hasFiltered); + bool deliverMatchingPointsToItem(QQuickItem *item, QQuickPointerEvent *pointerEvent, QSet<QQuickItem*> *filtered); + bool sendFilteredTouchEvent(QQuickItem *target, QQuickItem *item, QQuickPointerTouchEvent *event, QSet<QQuickItem*> *filtered); + + QVector<QQuickItem *> pointerTargets(QQuickItem *, const QPointF &, bool checkMouseButtons) const; + QVector<QQuickItem *> mergePointerTargets(const QVector<QQuickItem *> &list1, const QVector<QQuickItem *> &list2) const; + + // hover delivery bool deliverHoverEvent(QQuickItem *, const QPointF &scenePos, const QPointF &lastScenePos, Qt::KeyboardModifiers modifiers, ulong timestamp, bool &accepted); - bool deliverMatchingPointsToItem(QQuickItem *item, QTouchEvent *event, QSet<int> *acceptedNewPoints, const QSet<int> &matchingNewPoints, const QList<QTouchEvent::TouchPoint> &matchingPoints, QSet<QQuickItem*> *filtered); - QTouchEvent *touchEventForItemBounds(QQuickItem *target, const QTouchEvent &originalEvent); - QTouchEvent *touchEventWithPoints(const QTouchEvent &event, const QList<QTouchEvent::TouchPoint> &newPoints); - bool sendFilteredTouchEvent(QQuickItem *target, QQuickItem *item, QTouchEvent *event, QSet<QQuickItem*> *filtered); bool sendHoverEvent(QEvent::Type, QQuickItem *, const QPointF &scenePos, const QPointF &lastScenePos, Qt::KeyboardModifiers modifiers, ulong timestamp, bool accepted); bool clearHover(ulong timestamp = 0); + #ifndef QT_NO_DRAGANDDROP void deliverDragEvent(QQuickDragGrabber *, QEvent *); bool deliverDragEvent(QQuickDragGrabber *, QQuickItem *, QDragMoveEvent *); @@ -233,7 +243,8 @@ public: QQuickRenderControl *renderControl; QQuickAnimatorController *animationController; QScopedPointer<QTouchEvent> delayedTouch; - int touchRecursionGuard; + + int pointerEventRecursionGuard; QQuickCustomRenderStage *customRenderStage; QColor clearColor; @@ -254,15 +265,12 @@ public: QOpenGLVertexArrayObjectHelper *vaoHelper; - // Keeps track of which touch point (int) was last accepted by which item - QHash<int, QQuickItem *> itemForTouchPointId; - QSet<int> touchMouseIdCandidates; - mutable QQuickWindowIncubationController *incubationController; static bool defaultAlphaBuffer; static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1); + static bool dragOverThreshold(qreal d, Qt::Axis axis, const QTouchEvent::TouchPoint *tp, int startDragThreshold = -1); // data property static void data_append(QQmlListProperty<QObject> *, QObject *); @@ -288,22 +296,6 @@ private: static void cleanupNodesOnShutdown(QQuickItem *); }; -class Q_QUICK_PRIVATE_EXPORT QQuickCloseEvent : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) - -public: - QQuickCloseEvent() - : _accepted(true) {} - - bool isAccepted() { return _accepted; } - void setAccepted(bool accepted) { _accepted = accepted; } - -private: - bool _accepted; -}; - class QQuickWindowQObjectCleanupJob : public QRunnable { public: @@ -321,6 +313,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickWindowPrivate::FocusOptions) QT_END_NAMESPACE -QML_DECLARE_TYPE(QQuickCloseEvent) - #endif // QQUICKWINDOW_P_H |