Revert "Forward touchEvents to children inside QGraphicsProxyWidget"

This reverts commit 1ecf2212fae176b78c9951a37df9e33eb24d4f2d.

The fix is not correct after all. TouchBegin goes to the correct
widget with the fix, but following TouchUpdate and TouchEnd events
now go to the viewport, as QApplication::translateRawTouchEvent always
gives precedence to the widget that Qt recorded to be the touch
grabber, which is the viewport. This results in infinite recursion,
as the proxy widget trying to send the touch events to the embedded
widget (expecting that translateRawTouchEvent will split it up) ends
up sending the events back to the viewport.

Leave the added test case as QEXPECT_FAIL, reactivate the (never run,
hence unnoticed) test that the fix broke.

Pick-to: 6.2 6.1
Task-number: QTBUG-45737
Task-number: QTBUG-67819
Change-Id: I4810affb3cd066743ae94ab7beb2f0c06b60d211
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Volker Hilsheimer 2021-08-29 11:10:16 +02:00 committed by Shawn Rutledge
parent d9381bc7c3
commit 6e2a5312db
3 changed files with 10 additions and 14 deletions

View File

@ -922,13 +922,14 @@ bool QGraphicsProxyWidget::event(QEvent *event)
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd: {
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
auto touchPoints = touchEvent->points();
bool res = QApplicationPrivate::translateRawTouchEvent(d->widget, touchEvent);
if (res) {
event->accept();
if (event->spontaneous())
qt_sendSpontaneousEvent(d->widget, event);
else
QCoreApplication::sendEvent(d->widget, event);
if (event->isAccepted())
return true;
}
break;
}
default:

View File

@ -4020,9 +4020,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QTouchEv
{
// if the TouchBegin handler recurses, we assume that means the event
// has been implicitly accepted and continue to send touch events
bool res = te->spontaneous() ? QApplication::sendSpontaneousEvent(widget, &touchEvent)
: QApplication::sendEvent(widget, &touchEvent);
if (res && touchEvent.isAccepted()) {
if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted()) {
accepted = true;
if (!widget.isNull())
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
@ -4035,9 +4033,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QTouchEv
|| QGestureManager::gesturePending(widget)
#endif
) {
bool res = te->spontaneous() ? QApplication::sendSpontaneousEvent(widget, &touchEvent)
: QApplication::sendEvent(widget, &touchEvent);
if (res && touchEvent.isAccepted())
if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted())
accepted = true;
// widget can be deleted on TouchEnd
if (touchEvent.type() == QEvent::TouchEnd && !widget.isNull())

View File

@ -3782,8 +3782,6 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation()
// QTBUG_45737
void tst_QGraphicsProxyWidget::forwardTouchEvent()
{
QSKIP("Test is currently broken");
QGraphicsScene scene;
TouchWidget *widget = new TouchWidget;
@ -3931,6 +3929,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
sequence.press(0, pushButton1->pos() + pb1Center + formProxy->pos().toPoint());
}
// ..., formProxy, pushButton1, formWidget
QEXPECT_FAIL("", "Touch events are not forwarded to children - QTBUG-67819", Abort);
QCOMPARE(eventSpy.count(), 6);
record = eventSpy.at(eventSpy.count() - 2);
QCOMPARE(record.receiver, pushButton1);