Relax assumptions of the value of the touchMouseId
This is needed in order to be able to integrate a change that mangles the device identifier into the touch point id in qtbase Change-Id: I7675ade377da51f8da31830c7d43875487680845 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
parent
82a5bb18d2
commit
2369fab86c
|
@ -71,7 +71,7 @@ Q_SIGNALS:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EventItem(QQuickItem *parent = 0)
|
EventItem(QQuickItem *parent = 0)
|
||||||
: QQuickItem(parent), acceptMouse(false), acceptTouch(false), filterTouch(false)
|
: QQuickItem(parent), acceptMouse(false), acceptTouch(false), filterTouch(false), point0(-1)
|
||||||
{
|
{
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,9 @@ public:
|
||||||
void touchEvent(QTouchEvent *event)
|
void touchEvent(QTouchEvent *event)
|
||||||
{
|
{
|
||||||
eventList.append(Event(event->type(), event->touchPoints()));
|
eventList.append(Event(event->type(), event->touchPoints()));
|
||||||
|
QList<QTouchEvent::TouchPoint> tps = event->touchPoints();
|
||||||
|
Q_ASSERT(!tps.isEmpty());
|
||||||
|
point0 = tps.first().id();
|
||||||
event->setAccepted(acceptTouch);
|
event->setAccepted(acceptTouch);
|
||||||
emit onTouchEvent(this);
|
emit onTouchEvent(this);
|
||||||
}
|
}
|
||||||
|
@ -125,12 +128,16 @@ public:
|
||||||
event->type() == QEvent::TouchEnd) {
|
event->type() == QEvent::TouchEnd) {
|
||||||
QTouchEvent *touch = static_cast<QTouchEvent*>(event);
|
QTouchEvent *touch = static_cast<QTouchEvent*>(event);
|
||||||
eventList.append(Event(event->type(), touch->touchPoints()));
|
eventList.append(Event(event->type(), touch->touchPoints()));
|
||||||
|
QList<QTouchEvent::TouchPoint> tps = touch->touchPoints();
|
||||||
|
Q_ASSERT(!tps.isEmpty());
|
||||||
|
point0 = tps.first().id();
|
||||||
if (filterTouch)
|
if (filterTouch)
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
int point0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class tst_TouchMouse : public QQmlDataTest
|
class tst_TouchMouse : public QQmlDataTest
|
||||||
|
@ -581,7 +588,7 @@ void tst_TouchMouse::buttonOnFlickable()
|
||||||
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress);
|
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress);
|
||||||
|
|
||||||
QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window);
|
QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window);
|
||||||
QCOMPARE(windowPriv->touchMouseId, 0);
|
QVERIFY(windowPriv->touchMouseId != -1);
|
||||||
auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent();
|
auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent();
|
||||||
QCOMPARE(pointerEvent->point(0)->grabber(), eventItem1);
|
QCOMPARE(pointerEvent->point(0)->grabber(), eventItem1);
|
||||||
QCOMPARE(window->mouseGrabberItem(), eventItem1);
|
QCOMPARE(window->mouseGrabberItem(), eventItem1);
|
||||||
|
@ -603,7 +610,7 @@ void tst_TouchMouse::buttonOnFlickable()
|
||||||
QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseMove);
|
QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseMove);
|
||||||
|
|
||||||
QCOMPARE(window->mouseGrabberItem(), flickable);
|
QCOMPARE(window->mouseGrabberItem(), flickable);
|
||||||
QCOMPARE(windowPriv->touchMouseId, 0);
|
QVERIFY(windowPriv->touchMouseId != -1);
|
||||||
QCOMPARE(pointerEvent->point(0)->grabber(), flickable);
|
QCOMPARE(pointerEvent->point(0)->grabber(), flickable);
|
||||||
QVERIFY(flickable->isMovingVertically());
|
QVERIFY(flickable->isMovingVertically());
|
||||||
|
|
||||||
|
@ -710,7 +717,7 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable()
|
||||||
// flickable should have the mouse grab, and have moved the itemForTouchPointId
|
// flickable should have the mouse grab, and have moved the itemForTouchPointId
|
||||||
// for the touchMouseId to the new grabber.
|
// for the touchMouseId to the new grabber.
|
||||||
QCOMPARE(window->mouseGrabberItem(), flickable);
|
QCOMPARE(window->mouseGrabberItem(), flickable);
|
||||||
QCOMPARE(windowPriv->touchMouseId, 0);
|
QVERIFY(windowPriv->touchMouseId != -1);
|
||||||
auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent();
|
auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent();
|
||||||
QCOMPARE(pointerEvent->point(0)->grabber(), flickable);
|
QCOMPARE(pointerEvent->point(0)->grabber(), flickable);
|
||||||
|
|
||||||
|
@ -1246,7 +1253,7 @@ void tst_TouchMouse::touchGrabCausesMouseUngrab()
|
||||||
rightItem->acceptTouch = true;
|
rightItem->acceptTouch = true;
|
||||||
{
|
{
|
||||||
QVector<int> ids;
|
QVector<int> ids;
|
||||||
ids.append(0);
|
ids.append(leftItem->point0);
|
||||||
rightItem->grabTouchPoints(ids);
|
rightItem->grabTouchPoints(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue