From 023fc220a1267876ebb210619672271f8c2130d7 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 7 Apr 2023 22:14:27 +0000 Subject: [PATCH] wayland: Update pointer state before ending the drag ending a drag will update focus. Kwin explicitly resets it to whatever is now under the mouse now that the implicit grab has ended. This means no-one sends a pointer up. Clients (xwayland) don't automatically make leave events count as a mouse up, because typically you don't get a leave event whilst we have a grab. Xwayland also can't track the status of the wl_datasource as it didn't use it. This patch shouldn't affect any wayland clients as we don't send a frame event until the focus changes which is after the dnd_finished events. BUG: 465444 Testing done: - dragged firefox under xwayland tabs out from firefox to the desktop - confirmed a new window appeared --- src/wayland/autotests/client/test_drag_drop.cpp | 6 ++++-- src/wayland/seat_interface.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wayland/autotests/client/test_drag_drop.cpp b/src/wayland/autotests/client/test_drag_drop.cpp index 9478cb9a59..25422380ab 100644 --- a/src/wayland/autotests/client/test_drag_drop.cpp +++ b/src/wayland/autotests/client/test_drag_drop.cpp @@ -272,7 +272,8 @@ void TestDragAndDrop::testPointerDragAndDrop() // verify that we did not get any further input events QVERIFY(pointerMotionSpy.isEmpty()); - QCOMPARE(buttonPressSpy.count(), 1); + // the release event is sent primarily for xwayland + QCOMPARE(buttonPressSpy.count(), 2); } void TestDragAndDrop::testTouchDragAndDrop() @@ -530,8 +531,9 @@ void TestDragAndDrop::testPointerEventsIgnored() QCOMPARE(axisSpy.count(), 1); QCOMPARE(pointerMotionSpy.count(), 1); QCOMPARE(pointerEnteredSpy.count(), 1); - QCOMPARE(buttonSpy.count(), 1); QVERIFY(pointerLeftSpy.isEmpty()); + // the release event is sent primary for xwayland, see BUG 465444 + QCOMPARE(buttonSpy.count(), 2); } QTEST_GUILESS_MAIN(TestDragAndDrop) diff --git a/src/wayland/seat_interface.cpp b/src/wayland/seat_interface.cpp index 07693f205c..7732465a40 100644 --- a/src/wayland/seat_interface.cpp +++ b/src/wayland/seat_interface.cpp @@ -714,6 +714,7 @@ void SeatInterface::notifyPointerButton(quint32 button, PointerButtonState state // not our drag button - ignore return; } + d->pointer->sendButton(button, state, serial); d->endDrag(); return; }