diff --git a/autotests/integration/xclipboardsync_test.cpp b/autotests/integration/xclipboardsync_test.cpp index ee9a5e6752..143f644f8d 100644 --- a/autotests/integration/xclipboardsync_test.cpp +++ b/autotests/integration/xclipboardsync_test.cpp @@ -56,6 +56,8 @@ void XClipboardSyncTest::initTestCase() QVERIFY(workspaceCreatedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); + QSignalSpy clipboardSyncDevicedCreated{waylandServer(), &WaylandServer::xclipboardSyncDataDeviceCreated}; + QVERIFY(clipboardSyncDevicedCreated.isValid()); QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); kwinApp()->start(); @@ -65,8 +67,8 @@ void XClipboardSyncTest::initTestCase() QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); waylandServer()->initWorkspace(); // wait till the xclipboard sync data device is created - while (waylandServer()->xclipboardSyncDataDevice().isNull()) { - QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); + if (clipboardSyncDevicedCreated.empty()) { + QVERIFY(clipboardSyncDevicedCreated.wait()); } QVERIFY(!waylandServer()->xclipboardSyncDataDevice().isNull()); } diff --git a/wayland_server.cpp b/wayland_server.cpp index 90db349f74..6c590f6a06 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -246,6 +246,7 @@ bool WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags) [this] (DataDeviceInterface *ddi) { if (ddi->client() == m_xclipbaordSync.client && m_xclipbaordSync.client != nullptr) { m_xclipbaordSync.ddi = QPointer(ddi); + emit xclipboardSyncDataDeviceCreated(); connect(m_xclipbaordSync.ddi.data(), &DataDeviceInterface::selectionChanged, this, [this] { // testing whether the active client inherits Client diff --git a/wayland_server.h b/wayland_server.h index 60dbcc0ade..bc0a589983 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -210,6 +210,7 @@ Q_SIGNALS: void terminatingInternalClientConnection(); void initialized(); void foreignTransientChanged(KWayland::Server::SurfaceInterface *child); + void xclipboardSyncDataDeviceCreated(); private: void setupX11ClipboardSync();