From 410c414bad9ddfd9d412aaa7010b18b9f9242f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Tue, 14 Oct 2014 13:29:13 +0200 Subject: [PATCH] Add Registry::interfacesAnnounced signal Emitted when the Wayland display is done flushing the initial interface callbacks, announcing wl_display properties. This can be used to compress events. Note that this signal is emitted only after announcing interfaces, such as outputs, but not after receiving callbacks of interface properties, such as the output's geometry, modes, etc.. This signal is emitted from the wl_display_sync callback. REVIEW:120471 --- .../client/test_wayland_registry.cpp | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/wayland/autotests/client/test_wayland_registry.cpp b/src/wayland/autotests/client/test_wayland_registry.cpp index 571be0f8a2..77658734b9 100644 --- a/src/wayland/autotests/client/test_wayland_registry.cpp +++ b/src/wayland/autotests/client/test_wayland_registry.cpp @@ -21,6 +21,7 @@ License along with this library. If not, see . #include // KWin #include "../../src/client/connection_thread.h" +#include "../../src/client/event_queue.h" #include "../../src/client/registry.h" #include "../../src/server/compositor_interface.h" #include "../../src/server/display.h" @@ -45,6 +46,8 @@ private Q_SLOTS: void testBindOutput(); void testBindShm(); void testBindSeat(); + void testGlobalSync(); + void testGlobalSyncThreaded(); void testRemoval(); void testDestroy(); @@ -274,5 +277,57 @@ void TestWaylandRegistry::testDestroy() registry.destroy(); } +void TestWaylandRegistry::testGlobalSync() +{ + using namespace KWayland::Client; + ConnectionThread connection; + connection.setSocketName(s_socketName); + QSignalSpy connectedSpy(&connection, SIGNAL(connected())); + connection.initConnection(); + QVERIFY(connectedSpy.wait()); + + Registry registry; + QSignalSpy syncSpy(®istry, SIGNAL(interfacesAnnounced())); + // Most simple case: don't even use the ConnectionThread, + // just its display. + registry.create(connection.display()); + registry.setup(); + QVERIFY(syncSpy.wait()); + QCOMPARE(syncSpy.count(), 1); + registry.destroy(); +} + +void TestWaylandRegistry::testGlobalSyncThreaded() +{ + // More complex case, use a ConnectionThread, in a different Thread, + // and our own EventQueue + using namespace KWayland::Client; + ConnectionThread connection; + connection.setSocketName(s_socketName); + QThread thread; + connection.moveToThread(&thread); + thread.start(); + + QSignalSpy connectedSpy(&connection, SIGNAL(connected())); + connection.initConnection(); + + QVERIFY(connectedSpy.wait()); + EventQueue queue; + queue.setup(&connection); + + Registry registry; + QSignalSpy syncSpy(®istry, SIGNAL(interfacesAnnounced())); + registry.setEventQueue(&queue); + registry.create(&connection); + registry.setup(); + + QVERIFY(syncSpy.wait()); + QCOMPARE(syncSpy.count(), 1); + registry.destroy(); + + thread.quit(); + thread.wait(); +} + QTEST_GUILESS_MAIN(TestWaylandRegistry) #include "test_wayland_registry.moc"