From 1e2f2a28c7d8aed2b437c99b1eb25c1f74ca1a56 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 17 Nov 2020 13:26:01 +0000 Subject: [PATCH] Port to kwayland-server socket changes --- .../integration/no_xdg_runtime_dir_test.cpp | 3 +-- main_wayland.cpp | 2 +- plugins/platforms/wayland/wayland_output.cpp | 2 +- .../x11/windowed/x11windowed_backend.cpp | 2 +- wayland_server.cpp | 17 ++++++++++++----- wayland_server.h | 6 ++++++ 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/autotests/integration/no_xdg_runtime_dir_test.cpp b/autotests/integration/no_xdg_runtime_dir_test.cpp index 0c9254ca98..42524a08e3 100644 --- a/autotests/integration/no_xdg_runtime_dir_test.cpp +++ b/autotests/integration/no_xdg_runtime_dir_test.cpp @@ -29,8 +29,7 @@ void NoXdgRuntimeDirTest::initTestCase() void NoXdgRuntimeDirTest::testInitFails() { // this test verifies that without an XDG_RUNTIME_DIR the WaylandServer fails to start - QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); - QVERIFY(!waylandServer()->start()); + QVERIFY(!waylandServer()->init(s_socketName.toLocal8Bit())); } WAYLANDTEST_MAIN(NoXdgRuntimeDirTest) diff --git a/main_wayland.cpp b/main_wayland.cpp index 184ca65a2c..19e2c3d473 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -696,7 +696,7 @@ int main(int argc, char * argv[]) a.platform()->setInitialOutputCount(outputCount); QObject::connect(&a, &KWin::Application::workspaceCreated, server, &KWin::WaylandServer::initWorkspace); - environment.insert(QStringLiteral("WAYLAND_DISPLAY"), server->display()->socketName()); + environment.insert(QStringLiteral("WAYLAND_DISPLAY"), server->socketName()); a.setProcessStartupEnvironment(environment); a.setStartXwayland(parser.isSet(xwaylandOption)); a.setApplicationsToStart(parser.positionalArguments()); diff --git a/plugins/platforms/wayland/wayland_output.cpp b/plugins/platforms/wayland/wayland_output.cpp index 4d0113aa3d..aa76574093 100644 --- a/plugins/platforms/wayland/wayland_output.cpp +++ b/plugins/platforms/wayland/wayland_output.cpp @@ -121,7 +121,7 @@ void XdgShellOutput::updateWindowTitle() grab = i18n("Press right control key to grab pointer"); } const QString title = i18nc("Title of nested KWin Wayland with Wayland socket identifier as argument", - "KDE Wayland Compositor #%1 (%2)", m_number, waylandServer()->display()->socketName()); + "KDE Wayland Compositor #%1 (%2)", m_number, waylandServer()->socketName()); if (grab.isEmpty()) { m_xdgShellSurface->setTitle(title); diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.cpp b/plugins/platforms/x11/windowed/x11windowed_backend.cpp index cfbcb7c2a3..df48a7f92e 100644 --- a/plugins/platforms/x11/windowed/x11windowed_backend.cpp +++ b/plugins/platforms/x11/windowed/x11windowed_backend.cpp @@ -348,7 +348,7 @@ void X11WindowedBackend::updateWindowTitle() { const QString grab = m_keyboardGrabbed ? i18n("Press right control to ungrab input") : i18n("Press right control key to grab input"); const QString title = QStringLiteral("%1 (%2) - %3").arg(i18n("KDE Wayland Compositor")) - .arg(waylandServer()->display()->socketName()) + .arg(waylandServer()->socketName()) .arg(grab); for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { (*it)->setWindowTitle(title); diff --git a/wayland_server.cpp b/wayland_server.cpp index 8e14d3087a..3646da80f9 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -331,10 +331,8 @@ bool WaylandServer::init(const QByteArray &socketName, InitializationFlags flags { m_initFlags = flags; m_display = new KWinDisplay(this); - if (!socketName.isNull() && !socketName.isEmpty()) { - m_display->setSocketName(QString::fromUtf8(socketName)); - } else { - m_display->setAutomaticSocketNaming(true); + if (!m_display->addSocketName(QString::fromUtf8(socketName))) { + return false; } m_compositor = m_display->createCompositor(m_display); connect(m_compositor, &CompositorInterface::surfaceCreated, this, @@ -744,7 +742,7 @@ void WaylandServer::dispatch() if (m_internalConnection.server) { m_internalConnection.server->flush(); } - m_display->dispatchEvents(0); + m_display->dispatchEvents(); } static AbstractClient *findClientInList(const QList &clients, KWaylandServer::SurfaceInterface *surface) @@ -827,4 +825,13 @@ bool WaylandServer::isKeyboardShortcutsInhibited() const return false; } +QString WaylandServer::socketName() const +{ + const QStringList socketNames = display()->socketNames(); + if (!socketNames.isEmpty()) { + return socketNames.first(); + } + return QString(); +} + } diff --git a/wayland_server.h b/wayland_server.h index 26ddbc67d5..362d33f581 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -241,6 +241,12 @@ public: AbstractWaylandOutput *findOutput(KWaylandServer::OutputInterface *output) const; + /** + * Returns the first socket name that can be used to connect to this server. + * For a full list, use display()->socketNames() + */ + QString socketName() const; + Q_SIGNALS: void shellClientAdded(KWin::AbstractClient *); void shellClientRemoved(KWin::AbstractClient *);