DataDevice: Send enter event with a correct position if we're using touch

It used to send the pointer position, which may be somewhere completely
different when we're using touch.
This commit is contained in:
Arjen Hiemstra 2021-10-25 16:54:13 +02:00
parent 10eb1aa0b9
commit 1bd496f42b
2 changed files with 7 additions and 3 deletions

View file

@ -339,7 +339,7 @@ void TestDragAndDrop::testTouchDragAndDrop()
QVERIFY(dragEnteredSpy.wait());
QCOMPARE(dragEnteredSpy.count(), 1);
QCOMPARE(dragEnteredSpy.first().first().value<quint32>(), m_display->serial());
QCOMPARE(dragEnteredSpy.first().last().toPointF(), QPointF(0, 0));
QCOMPARE(dragEnteredSpy.first().last().toPointF(), QPointF(50.0, 50.0));
QCOMPARE(m_dataDevice->dragSurface().data(), s.data());
auto offer = m_dataDevice->dragOffer();
QVERIFY(offer);

View file

@ -272,8 +272,12 @@ void DataDeviceInterface::updateDragTarget(SurfaceInterface *surface, quint32 se
d->drag = DataDeviceInterfacePrivate::Drag();
});
// TODO: handle touch position
const QPointF pos = d->seat->dragSurfaceTransformation().map(d->seat->pointerPos());
QPointF pos;
if (d->seat->isDragPointer()) {
pos = d->seat->dragSurfaceTransformation().map(d->seat->pointerPos());
} else if (d->seat->isDragTouch()) {
pos = d->seat->dragSurfaceTransformation().map(d->seat->firstTouchPointPosition());
}
d->send_enter(serial, surface->resource(), wl_fixed_from_double(pos.x()), wl_fixed_from_double(pos.y()), offer ? offer->resource() : nullptr);
if (offer) {
offer->sendSourceActions();