Port to kwayland-server socket changes

This commit is contained in:
David Edmundson 2020-11-17 13:26:01 +00:00 committed by Vlad Zahorodnii
parent 9799456f3b
commit 1e2f2a28c7
6 changed files with 22 additions and 10 deletions

View file

@ -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)

View file

@ -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());

View file

@ -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);

View file

@ -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);

View file

@ -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<AbstractClient *> &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();
}
}

View file

@ -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 *);