From 1bd496f42b5c15c88f37562e7b8383be61b6ce0a Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Mon, 25 Oct 2021 16:54:13 +0200 Subject: [PATCH] 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. --- src/wayland/autotests/client/test_drag_drop.cpp | 2 +- src/wayland/datadevice_interface.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wayland/autotests/client/test_drag_drop.cpp b/src/wayland/autotests/client/test_drag_drop.cpp index d4f7e43edd..dd31622903 100644 --- a/src/wayland/autotests/client/test_drag_drop.cpp +++ b/src/wayland/autotests/client/test_drag_drop.cpp @@ -339,7 +339,7 @@ void TestDragAndDrop::testTouchDragAndDrop() QVERIFY(dragEnteredSpy.wait()); QCOMPARE(dragEnteredSpy.count(), 1); QCOMPARE(dragEnteredSpy.first().first().value(), 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); diff --git a/src/wayland/datadevice_interface.cpp b/src/wayland/datadevice_interface.cpp index b182d602ac..c5d38537f7 100644 --- a/src/wayland/datadevice_interface.cpp +++ b/src/wayland/datadevice_interface.cpp @@ -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();