From a6b740869d369dacb8700042aa5da35183a03b5a Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Wed, 9 May 2018 14:00:07 +0900 Subject: Fix build without features.gestures Change-Id: Id2fb6419be9a35ddaa24106d3022e72070cb908d Reviewed-by: Shawn Rutledge Reviewed-by: Oswald Buddenhagen --- src/quick/handlers/qquickmultipointhandler.cpp | 2 ++ src/quick/handlers/qquickpinchhandler.cpp | 7 ++++++- src/quick/items/qquickevents.cpp | 11 ++++++++++- src/quick/items/qquickevents_p_p.h | 8 ++++++++ src/quick/items/qquickwindow.cpp | 6 ++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/quick/handlers/qquickmultipointhandler.cpp b/src/quick/handlers/qquickmultipointhandler.cpp index b126b93211..d595b4c9b4 100644 --- a/src/quick/handlers/qquickmultipointhandler.cpp +++ b/src/quick/handlers/qquickmultipointhandler.cpp @@ -76,8 +76,10 @@ bool QQuickMultiPointHandler::wantsPointerEvent(QQuickPointerEvent *event) if (!QQuickPointerDeviceHandler::wantsPointerEvent(event)) return false; +#if QT_CONFIG(gestures) if (event->asPointerNativeGestureEvent()) return true; +#endif if (sameAsCurrentPoints(event)) return true; diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp index 155822197f..fc69accffc 100644 --- a/src/quick/handlers/qquickpinchhandler.cpp +++ b/src/quick/handlers/qquickpinchhandler.cpp @@ -248,6 +248,7 @@ bool QQuickPinchHandler::wantsPointerEvent(QQuickPointerEvent *event) if (!QQuickMultiPointHandler::wantsPointerEvent(event)) return false; +#if QT_CONFIG(gestures) if (const auto gesture = event->asPointerNativeGestureEvent()) { if (minimumPointCount() == 2) { switch (gesture->type()) { @@ -263,6 +264,7 @@ bool QQuickPinchHandler::wantsPointerEvent(QQuickPointerEvent *event) return false; } } +#endif return true; } @@ -319,6 +321,7 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event) } qreal dist = 0; +#if QT_CONFIG(gestures) if (const auto gesture = event->asPointerNativeGestureEvent()) { switch (gesture->type()) { case Qt::EndNativeGesture: @@ -349,7 +352,9 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event) m_centroidVelocity = QVector2D(); m_activeTranslation = QVector2D(); } - } else { + } else +#endif // QT_CONFIG(gestures) + { bool containsReleasedPoints = event->isReleaseEvent(); if (!active()) { // Verify that at least one of the points has moved beyond threshold needed to activate the handler diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 3343ea3fa7..d964f2bb32 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -1388,6 +1388,7 @@ void QQuickPointerTouchEvent::localize(QQuickItem *target) point->localizePosition(target); } +#if QT_CONFIG(gestures) QQuickPointerEvent *QQuickPointerNativeGestureEvent::reset(QEvent *event) { auto ev = static_cast(event); @@ -1417,6 +1418,7 @@ void QQuickPointerNativeGestureEvent::localize(QQuickItem *target) { m_gesturePoint->localizePosition(target); } +#endif // QT_CONFIG(gestures) QQuickEventPoint *QQuickPointerMouseEvent::point(int i) const { if (i == 0) @@ -1430,11 +1432,13 @@ QQuickEventPoint *QQuickPointerTouchEvent::point(int i) const { return nullptr; } +#if QT_CONFIG(gestures) QQuickEventPoint *QQuickPointerNativeGestureEvent::point(int i) const { if (i == 0) return m_gesturePoint; return nullptr; } +#endif // QT_CONFIG(gestures) QQuickEventPoint::QQuickEventPoint(QQuickPointerEvent *parent) : QObject(parent), m_pointId(0), m_exclusiveGrabber(nullptr), m_timestamp(0), m_pressTimestamp(0), @@ -1662,6 +1666,7 @@ QMouseEvent *QQuickPointerTouchEvent::syntheticMouseEvent(int pointID, QQuickIte return &m_synthMouseEvent; } +#if QT_CONFIG(gestures) /*! Returns the exclusive grabber of this event, if any, in a vector. */ @@ -1719,6 +1724,7 @@ qreal QQuickPointerNativeGestureEvent::value() const { return static_cast(m_event)->value(); } +#endif // QT_CONFIG(gestures) /*! \internal @@ -1742,12 +1748,13 @@ QQuickEventPoint *QQuickPointerTouchEvent::pointById(int pointId) const { return nullptr; } +#if QT_CONFIG(gestures) QQuickEventPoint *QQuickPointerNativeGestureEvent::pointById(int pointId) const { if (m_gesturePoint && pointId == m_gesturePoint->pointId()) return m_gesturePoint; return nullptr; } - +#endif /*! \internal @@ -1866,6 +1873,7 @@ QTouchEvent *QQuickPointerTouchEvent::asTouchEvent() const return static_cast(m_event); } +#if QT_CONFIG(gestures) bool QQuickPointerNativeGestureEvent::allPointsAccepted() const { return m_gesturePoint->isAccepted(); } @@ -1878,6 +1886,7 @@ bool QQuickPointerNativeGestureEvent::allPointsGrabbed() const { return m_gesturePoint->exclusiveGrabber() != nullptr; } +#endif // QT_CONFIG(gestures) #ifndef QT_NO_DEBUG_STREAM diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index 00ee0e18f9..bb6726706d 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -66,7 +66,9 @@ QT_BEGIN_NAMESPACE class QQuickPointerDevice; class QQuickPointerEvent; class QQuickPointerMouseEvent; +#if QT_CONFIG(gestures) class QQuickPointerNativeGestureEvent; +#endif class QQuickPointerTabletEvent; class QQuickPointerTouchEvent; class QQuickPointerHandler; @@ -414,11 +416,15 @@ public: // helpers for C++ only (during event delivery) virtual QQuickPointerMouseEvent *asPointerMouseEvent() { return nullptr; } virtual QQuickPointerTouchEvent *asPointerTouchEvent() { return nullptr; } virtual QQuickPointerTabletEvent *asPointerTabletEvent() { return nullptr; } +#if QT_CONFIG(gestures) virtual QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() { return nullptr; } +#endif virtual const QQuickPointerMouseEvent *asPointerMouseEvent() const { return nullptr; } virtual const QQuickPointerTouchEvent *asPointerTouchEvent() const { return nullptr; } virtual const QQuickPointerTabletEvent *asPointerTabletEvent() const { return nullptr; } +#if QT_CONFIG(gestures) virtual const QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() const { return nullptr; } +#endif virtual bool allPointsAccepted() const = 0; virtual bool allUpdatedPointsAccepted() const = 0; virtual bool allPointsGrabbed() const = 0; @@ -519,6 +525,7 @@ private: Q_DISABLE_COPY(QQuickPointerTouchEvent) }; +#if QT_CONFIG(gestures) class Q_QUICK_PRIVATE_EXPORT QQuickPointerNativeGestureEvent : public QQuickPointerEvent { Q_OBJECT @@ -553,6 +560,7 @@ private: Q_DISABLE_COPY(QQuickPointerNativeGestureEvent) }; +#endif // QT_CONFIG(gestures) // ### Qt 6: move this to qtbase, replace QTouchDevice and the enums in QTabletEvent diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 0f617733c4..535770e9f9 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -2225,8 +2225,10 @@ QQuickPointerEvent *QQuickWindowPrivate::queryPointerEventInstance(QQuickPointer for (QQuickPointerEvent *e : pointerEventInstances) { // If device can generate native gestures (e.g. a trackpad), there might be two QQuickPointerEvents: // QQuickPointerNativeGestureEvent and QQuickPointerTouchEvent. Use eventType to disambiguate. +#if QT_CONFIG(gestures) if (eventType == QEvent::NativeGesture && !qobject_cast(e)) continue; +#endif // Otherwise we assume there's only one event type per device. // More disambiguation tests might need to be added above if that changes later. if (e->device() == device) @@ -2250,9 +2252,11 @@ QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QQuickPointerDevic break; case QQuickPointerDevice::TouchPad: case QQuickPointerDevice::TouchScreen: +#if QT_CONFIG(gestures) if (eventType == QEvent::NativeGesture) ev = new QQuickPointerNativeGestureEvent(q, device); else // assume QEvent::Type is one of TouchBegin/Update/End +#endif ev = new QQuickPointerTouchEvent(q, device); break; default: @@ -2287,9 +2291,11 @@ QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QEvent *event) con dev = QQuickPointerDevice::touchDevice(static_cast(event)->device()); break; // TODO tablet event types +#if QT_CONFIG(gestures) case QEvent::NativeGesture: dev = QQuickPointerDevice::touchDevice(static_cast(event)->device()); break; +#endif default: break; } -- cgit v1.2.3