From 36663a187de8637a5d69b888bc8b786106afec3b Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 17 Sep 2019 07:07:26 +0200 Subject: [PATCH 1/5] Blacklist tst_seatv4::animatedCursor() in b2qt Task-number: QTBUG-78317 Change-Id: I66e35782470cedd4d3cfeed6ffdfd8d54bc0ba26 Reviewed-by: Jani Heikkinen --- tests/auto/wayland/seatv4/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/auto/wayland/seatv4/BLACKLIST diff --git a/tests/auto/wayland/seatv4/BLACKLIST b/tests/auto/wayland/seatv4/BLACKLIST new file mode 100644 index 00000000000..1c761a74efc --- /dev/null +++ b/tests/auto/wayland/seatv4/BLACKLIST @@ -0,0 +1,2 @@ +[animatedCursor] +b2qt From 13055e46e385f0db7653f8827c01dc5e043b8682 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Fri, 23 Aug 2019 11:42:46 +0200 Subject: [PATCH 2/5] Add client test for multi touch motion Make sure touchPoint order doesn't change even though the compositor event order does. Task-number: QTBUG-77014 Change-Id: If6b8a930344836ca52cc12fe7f29c8ac863d81ba Reviewed-by: Paul Olav Tvete --- tests/auto/wayland/seatv5/tst_seatv5.cpp | 73 ++++++++++++++++++++++ tests/auto/wayland/shared/coreprotocol.cpp | 12 ++++ tests/auto/wayland/shared/coreprotocol.h | 1 + 3 files changed, 86 insertions(+) diff --git a/tests/auto/wayland/seatv5/tst_seatv5.cpp b/tests/auto/wayland/seatv5/tst_seatv5.cpp index ae7c3db2f90..bf3c4f99d21 100644 --- a/tests/auto/wayland/seatv5/tst_seatv5.cpp +++ b/tests/auto/wayland/seatv5/tst_seatv5.cpp @@ -69,6 +69,7 @@ private slots: void createsTouch(); void singleTap(); void singleTapFloat(); + void multiTouch(); }; void tst_seatv5::bindsToSeat() @@ -463,5 +464,77 @@ void tst_seatv5::singleTapFloat() } } +void tst_seatv5::multiTouch() +{ + TouchWindow window; + QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial); + + exec([=] { + auto *t = touch(); + auto *c = client(); + + t->sendDown(xdgToplevel()->surface(), {32, 32}, 0); + t->sendDown(xdgToplevel()->surface(), {48, 48}, 1); + t->sendFrame(c); + + // Compositor event order should not change the order of the QTouchEvent::touchPoints() + // See QTBUG-77014 + t->sendMotion(c, {49, 48}, 1); + t->sendMotion(c, {33, 32}, 0); + t->sendFrame(c); + + t->sendUp(c, 0); + t->sendFrame(c); + + t->sendUp(c, 1); + t->sendFrame(c); + }); + + QTRY_VERIFY(!window.m_events.empty()); + { + auto e = window.m_events.takeFirst(); + QCOMPARE(e.type, QEvent::TouchBegin); + QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointPressed); + QCOMPARE(e.touchPoints.length(), 2); + + QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointPressed); + QCOMPARE(e.touchPoints[0].pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top())); + + QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointPressed); + QCOMPARE(e.touchPoints[1].pos(), QPointF(48-window.frameMargins().left(), 48-window.frameMargins().top())); + } + { + auto e = window.m_events.takeFirst(); + QCOMPARE(e.type, QEvent::TouchUpdate); + QCOMPARE(e.touchPoints.length(), 2); + + QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointMoved); + QCOMPARE(e.touchPoints[0].pos(), QPointF(33-window.frameMargins().left(), 32-window.frameMargins().top())); + + QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointMoved); + QCOMPARE(e.touchPoints[1].pos(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top())); + } + { + auto e = window.m_events.takeFirst(); + QCOMPARE(e.type, QEvent::TouchUpdate); + QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointReleased | Qt::TouchPointState::TouchPointStationary); + QCOMPARE(e.touchPoints.length(), 2); + + QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointReleased); + QCOMPARE(e.touchPoints[0].pos(), QPointF(33-window.frameMargins().left(), 32-window.frameMargins().top())); + + QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointStationary); + QCOMPARE(e.touchPoints[1].pos(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top())); + } + { + auto e = window.m_events.takeFirst(); + QCOMPARE(e.type, QEvent::TouchEnd); + QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointReleased); + QCOMPARE(e.touchPoints.length(), 1); + QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointReleased); + QCOMPARE(e.touchPoints[0].pos(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top())); + } +} + QCOMPOSITOR_TEST_MAIN(tst_seatv5) #include "tst_seatv5.moc" diff --git a/tests/auto/wayland/shared/coreprotocol.cpp b/tests/auto/wayland/shared/coreprotocol.cpp index 120c256c653..b0be2cb4e5b 100644 --- a/tests/auto/wayland/shared/coreprotocol.cpp +++ b/tests/auto/wayland/shared/coreprotocol.cpp @@ -424,6 +424,18 @@ uint Touch::sendUp(wl_client *client, int id) return serial; } +void Touch::sendMotion(wl_client *client, const QPointF &position, int id) +{ + wl_fixed_t x = wl_fixed_from_double(position.x()); + wl_fixed_t y = wl_fixed_from_double(position.y()); + + auto time = m_seat->m_compositor->currentTimeMilliseconds(); + + const auto touchResources = resourceMap().values(client); + for (auto *r : touchResources) + wl_touch::send_motion(r->handle, time, id, x, y); +} + void Touch::sendFrame(wl_client *client) { const auto touchResources = resourceMap().values(client); diff --git a/tests/auto/wayland/shared/coreprotocol.h b/tests/auto/wayland/shared/coreprotocol.h index 50812c29658..fe8202ad114 100644 --- a/tests/auto/wayland/shared/coreprotocol.h +++ b/tests/auto/wayland/shared/coreprotocol.h @@ -318,6 +318,7 @@ public: explicit Touch(Seat *seat) : m_seat(seat) {} uint sendDown(Surface *surface, const QPointF &position, int id); uint sendUp(wl_client *client, int id); + void sendMotion(wl_client *client, const QPointF &position, int id); void sendFrame(wl_client *client); Seat *m_seat = nullptr; From 7dfa3f9d50feeb9525d832057cdc804f082ad3bd Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Fri, 20 Sep 2019 10:38:34 +0200 Subject: [PATCH 3/5] Fix wrong target name for tst_client_fullscreenshellv1 Task-number: QTBUG-78177 Change-Id: Id44794523511241b408e79383e438e52f769d62a Reviewed-by: Pier Luigi Fiorini --- tests/auto/wayland/fullscreenshellv1/fullscreenshellv1.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/wayland/fullscreenshellv1/fullscreenshellv1.pro b/tests/auto/wayland/fullscreenshellv1/fullscreenshellv1.pro index 49d19d5c30d..c4006cdd870 100644 --- a/tests/auto/wayland/fullscreenshellv1/fullscreenshellv1.pro +++ b/tests/auto/wayland/fullscreenshellv1/fullscreenshellv1.pro @@ -1,4 +1,4 @@ include (../shared_old/shared_old.pri) -TARGET = tst_client_fullscreenshell1 +TARGET = tst_client_fullscreenshellv1 SOURCES += tst_fullscreenshellv1.cpp From 6f836567472b3fbc103da33af2b29f9da7f22903 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 26 Aug 2019 14:55:16 +0200 Subject: [PATCH 4/5] Client: Test that wl_touch.up events don't split touch frames We have a workaround for Weston not sending wl_touch.frame events after the last wl_touch.up event. It calls Touch::touch_frame to generate a fake event. The problem, however, is that it used to erroneously do this on wl_touch.up events even when it was not for the last touch point. This in turn, lead to extra frame events being inserted in the middle of a touch sequence, effectively splitting up one touch frame into multiple. Accumulated touch state would be handled prematurely, preventing wl_touch.cancel from working correctly for instance. This tests that we've stopped doing that. Change-Id: Ic545bbb18c23b827e5fa07a642a374094d720dae Reviewed-by: Paul Olav Tvete --- tests/auto/wayland/seatv5/tst_seatv5.cpp | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/auto/wayland/seatv5/tst_seatv5.cpp b/tests/auto/wayland/seatv5/tst_seatv5.cpp index bf3c4f99d21..636f260815a 100644 --- a/tests/auto/wayland/seatv5/tst_seatv5.cpp +++ b/tests/auto/wayland/seatv5/tst_seatv5.cpp @@ -70,6 +70,7 @@ private slots: void singleTap(); void singleTapFloat(); void multiTouch(); + void multiTouchUpAndMotionFrame(); }; void tst_seatv5::bindsToSeat() @@ -536,5 +537,54 @@ void tst_seatv5::multiTouch() } } +void tst_seatv5::multiTouchUpAndMotionFrame() +{ + TouchWindow window; + QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial); + + exec([=] { + auto *t = touch(); + auto *c = client(); + + t->sendDown(xdgToplevel()->surface(), {32, 32}, 0); + t->sendDown(xdgToplevel()->surface(), {48, 48}, 1); + t->sendFrame(c); + + // Sending an up event after a frame event, before any motion or down events used to + // unnecessarily trigger a workaround for a bug in an old version of Weston. The workaround + // would prematurely insert a fake frame event splitting the touch event up into two events. + // However, this should only be needed on the up event for the very last touch point. So in + // this test we verify that it doesn't unncecessarily break up the events. + t->sendUp(c, 0); + t->sendMotion(c, {49, 48}, 1); + t->sendFrame(c); + + t->sendUp(c, 1); + t->sendFrame(c); + }); + + QTRY_VERIFY(!window.m_events.empty()); + { + auto e = window.m_events.takeFirst(); + QCOMPARE(e.type, QEvent::TouchBegin); + QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointPressed); + QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointPressed); + } + { + auto e = window.m_events.takeFirst(); + QCOMPARE(e.type, QEvent::TouchUpdate); + QCOMPARE(e.touchPoints.length(), 2); + QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointReleased); + QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointMoved); + } + { + auto e = window.m_events.takeFirst(); + QCOMPARE(e.type, QEvent::TouchEnd); + QCOMPARE(e.touchPoints.length(), 1); + QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointReleased); + } + QVERIFY(window.m_events.empty()); +} + QCOMPOSITOR_TEST_MAIN(tst_seatv5) #include "tst_seatv5.moc" From 235f8f12fa1163cb7d149b71522a58247ee96e5f Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 13 Sep 2019 15:31:49 +0200 Subject: [PATCH 5/5] Client: Create context menu event when pressing the menu key Effectively is a copy of the code in XCB. When the menu key is pressed, a context menu event should be generated at the current cursor position. The global position in the event isn't truly global as that doesn't exist in wayland but should match client expectations. Change-Id: Ib814883aba632ca5eec58730846e1762b680467f Reviewed-by: Johan Helsing --- .../platforms/wayland/qwaylandinputdevice.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index e39ccf25ee2..a9da452dcbd 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -1158,7 +1158,18 @@ void QWaylandInputDevice::Keyboard::handleKey(ulong timestamp, QEvent::Type type } if (!filtered) { - QWindowSystemInterface::handleExtendedKeyEvent(focusWindow()->window(), timestamp, type, key, modifiers, + auto window = focusWindow()->window(); + + if (type == QEvent::KeyPress && key == Qt::Key_Menu) { + auto cursor = window->screen()->handle()->cursor(); + if (cursor) { + const QPoint globalPos = cursor->pos(); + const QPoint pos = window->mapFromGlobal(globalPos); + QWindowSystemInterface::handleContextMenuEvent(window, false, pos, globalPos, modifiers); + } + } + + QWindowSystemInterface::handleExtendedKeyEvent(window, timestamp, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorepeat, count); } }