Remove hard X11 runtime dependency from DBusInterface

Summary:
KWin's DBusInterface announces the service name on an X11 root window
property. For this it requires a runtime dependency on X11. If we would
try to start kwin_wayland without XWayland support this would result in
a crash.

This change turns the dependency into an optional one by checking
whether the KWin::Application has support for X11 and registers a
connection to announce the property as soon as a connection is
established. Thus it even supports the restart of XWayland now.

Test Plan: Compiles

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7474
icc-effect-5.14.5
Martin Flöser 2017-08-23 11:15:37 +02:00
parent 12cb1c108e
commit 793624b9a7
1 changed files with 8 additions and 2 deletions

View File

@ -64,6 +64,7 @@ DBusInterface::DBusInterface(QObject *parent)
}
dbus.connect(QString(), QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"),
Workspace::self(), SLOT(slotReloadConfig()));
connect(kwinApp(), &Application::x11ConnectionChanged, this, &DBusInterface::announceService);
}
void DBusInterface::becomeKWinService(const QString &service)
@ -81,13 +82,18 @@ DBusInterface::~DBusInterface()
QDBusConnection::sessionBus().unregisterService(m_serviceName);
// KApplication automatically also grabs org.kde.kwin, so it's often been used externally - ensure to free it as well
QDBusConnection::sessionBus().unregisterService(QStringLiteral("org.kde.kwin"));
xcb_delete_property(connection(), rootWindow(), atoms->kwin_dbus_service);
if (kwinApp()->x11Connection()) {
xcb_delete_property(kwinApp()->x11Connection(), kwinApp()->x11RootWindow(), atoms->kwin_dbus_service);
}
}
void DBusInterface::announceService()
{
if (!kwinApp()->x11Connection()) {
return;
}
const QByteArray service = m_serviceName.toUtf8();
xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, rootWindow(), atoms->kwin_dbus_service,
xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_REPLACE, kwinApp()->x11RootWindow(), atoms->kwin_dbus_service,
atoms->utf8_string, 8, service.size(), service.constData());
}