diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-08-24 13:22:52 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-08-26 09:36:25 +0200 |
commit | 6bf70bc0144ca29939a1db6757ed586b015fc3d2 (patch) | |
tree | 9c6eb79fdc91332144253d7adacdc879902abf6d /src | |
parent | 1ecf2212fae176b78c9951a37df9e33eb24d4f2d (diff) |
Refactor QApplication::translateRawTouchEvent to take a QTouchEvent*
Both call sites just pass the data from an existing QTouchEvent through,
so just pass the QTouchEvent through instead.
Amends 20d4f45a132606f7a910050d468519108486e9cf.
Pick-to: 6.2
Change-Id: If3b9508b83311889b58e109e7f64743985b8b178
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsproxywidget.cpp | 4 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 18 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication_p.h | 6 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 4 |
4 files changed, 11 insertions, 21 deletions
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index 84a8c979f6..d7eb62407d 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -922,9 +922,7 @@ bool QGraphicsProxyWidget::event(QEvent *event) case QEvent::TouchEnd: { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); auto touchPoints = touchEvent->points(); - bool res = QApplicationPrivate::translateRawTouchEvent(d->widget, touchEvent->pointingDevice(), - touchPoints, touchEvent->timestamp(), - event->spontaneous()); + bool res = QApplicationPrivate::translateRawTouchEvent(d->widget, touchEvent); if (res) { event->accept(); return true; diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index b97383115a..6dba04d284 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3916,17 +3916,15 @@ void QApplicationPrivate::activateImplicitTouchGrab(QWidget *widget, QTouchEvent // TODO setExclusiveGrabber() to be consistent with Qt Quick? } -bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, - const QPointingDevice *device, - QList<QEventPoint> &touchPoints, - ulong timestamp, - bool spontaneous) +bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QTouchEvent *te) { QApplicationPrivate *d = self; // TODO get rid of this QPair typedef QPair<QEventPoint::State, QList<QEventPoint> > StatesAndTouchPoints; QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents; + const auto *device = te->pointingDevice(); + auto touchPoints = te->points(); // touch points will be mutated for (auto &touchPoint : touchPoints) { // update state QPointer<QObject> target; @@ -4011,7 +4009,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, QMutableTouchEvent touchEvent(eventType, device, QGuiApplication::keyboardModifiers(), it.value().second); bool containsPress = updateTouchPointsForWidget(widget, &touchEvent); - touchEvent.setTimestamp(timestamp); + touchEvent.setTimestamp(te->timestamp()); touchEvent.setTarget(widget); if (containsPress) @@ -4022,8 +4020,8 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, { // if the TouchBegin handler recurses, we assume that means the event // has been implicitly accepted and continue to send touch events - bool res = spontaneous ? QApplication::sendSpontaneousEvent(widget, &touchEvent) - : QApplication::sendEvent(widget, &touchEvent); + bool res = te->spontaneous() ? QApplication::sendSpontaneousEvent(widget, &touchEvent) + : QApplication::sendEvent(widget, &touchEvent); if (res && touchEvent.isAccepted()) { accepted = true; if (!widget.isNull()) @@ -4037,8 +4035,8 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, || QGestureManager::gesturePending(widget) #endif ) { - bool res = spontaneous ? QApplication::sendSpontaneousEvent(widget, &touchEvent) - : QApplication::sendEvent(widget, &touchEvent); + bool res = te->spontaneous() ? QApplication::sendSpontaneousEvent(widget, &touchEvent) + : QApplication::sendEvent(widget, &touchEvent); if (res && touchEvent.isAccepted()) accepted = true; // widget can be deleted on TouchEnd diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 31dde00dd9..ee41f91060 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -250,11 +250,7 @@ public: void appendTouchPoint(const QEventPoint &touchPoint); void removeTouchPoint(int touchPointId); void activateImplicitTouchGrab(QWidget *widget, QTouchEvent *touchBeginEvent); - static bool translateRawTouchEvent(QWidget *widget, - const QPointingDevice *device, - QList<QEventPoint> &touchPoints, - ulong timestamp, - bool spontaneous = true); + static bool translateRawTouchEvent(QWidget *widget, const QTouchEvent *touchEvent); static void translateTouchCancel(const QPointingDevice *device, ulong timestamp); QPixmap applyQIconStyleHelper(QIcon::Mode mode, const QPixmap& base) const override; diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index cdc358aca2..346289cafe 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -698,9 +698,7 @@ void QWidgetWindow::handleTouchEvent(QTouchEvent *event) // events instead, which QWidgetWindow::handleMouseEvent will forward correctly: event->ignore(); } else { - event->setAccepted(QApplicationPrivate::translateRawTouchEvent(m_widget, event->pointingDevice(), - const_cast<QList<QEventPoint> &>(event->points()), - event->timestamp())); + event->setAccepted(QApplicationPrivate::translateRawTouchEvent(m_widget, event)); } } |