From 1e38c38c1feac025165e409d7d37cfba55a7ce45 Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Mon, 13 Oct 2014 22:35:04 +0200 Subject: [PATCH] Add an env var KWIN_DBUS_SERVICE_SUFFIX to set a different dbus service name Signed-off-by: Axel Davy REVIEW: 120028 --- dbusinterface.cpp | 13 +++++++++---- dbusinterface.h | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dbusinterface.cpp b/dbusinterface.cpp index 345b45b6aa..ae1c9bb407 100644 --- a/dbusinterface.cpp +++ b/dbusinterface.cpp @@ -43,13 +43,18 @@ namespace KWin DBusInterface::DBusInterface(QObject *parent) : QObject(parent) + , m_serviceName(QStringLiteral("org.kde.KWin")) { (void) new KWinAdaptor(this); QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerObject(QStringLiteral("/KWin"), this); - if (!dbus.registerService(QStringLiteral("org.kde.KWin"))) { - QDBusServiceWatcher *dog = new QDBusServiceWatcher(QStringLiteral("org.kde.KWin"), dbus, QDBusServiceWatcher::WatchForUnregistration, this); + const QByteArray dBusSuffix = qgetenv("KWIN_DBUS_SERVICE_SUFFIX"); + if (!dBusSuffix.isNull()) { + m_serviceName = m_serviceName + QStringLiteral(".") + dBusSuffix; + } + if (!dbus.registerService(m_serviceName)) { + QDBusServiceWatcher *dog = new QDBusServiceWatcher(m_serviceName, dbus, QDBusServiceWatcher::WatchForUnregistration, this); connect (dog, SIGNAL(serviceUnregistered(QString)), SLOT(becomeKWinService(QString))); } dbus.connect(QString(), QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"), @@ -60,14 +65,14 @@ void DBusInterface::becomeKWinService(const QString &service) { // TODO: this watchdog exists to make really safe that we at some point get the service // but it's probably no longer needed since we explicitly unregister the service with the deconstructor - if (service == QStringLiteral("org.kde.KWin") && QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KWin")) && sender()) { + if (service == m_serviceName && QDBusConnection::sessionBus().registerService(m_serviceName) && sender()) { sender()->deleteLater(); // bye doggy :'( } } DBusInterface::~DBusInterface() { - QDBusConnection::sessionBus().unregisterService(QStringLiteral("org.kde.KWin")); // this is the long standing legal service + 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")); } diff --git a/dbusinterface.h b/dbusinterface.h index 1c0a875127..83ab9e7306 100644 --- a/dbusinterface.h +++ b/dbusinterface.h @@ -67,6 +67,9 @@ public Q_SLOTS: // METHODS private Q_SLOTS: void becomeKWinService(const QString &service); + +private: + QString m_serviceName; }; class CompositorDBusInterface : public QObject