diff --git a/dbusinterface.cpp b/dbusinterface.cpp
index 0aa6eb0d1d..abee120e8f 100644
--- a/dbusinterface.cpp
+++ b/dbusinterface.cpp
@@ -20,6 +20,7 @@ along with this program. If not, see .
// own
#include "dbusinterface.h"
+
// kwin
// TODO: remove together with deprecated methods
#include "client.h"
@@ -28,6 +29,9 @@ along with this program. If not, see .
#include "kwinadaptor.h"
#include "workspace.h"
+// Qt
+#include
+
namespace KWin
{
@@ -38,7 +42,10 @@ DBusInterface::DBusInterface(QObject *parent)
QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.registerObject("/KWin", this);
- dbus.registerService("org.kde.KWin");
+ if (!dbus.registerService("org.kde.KWin")) {
+ QDBusServiceWatcher *dog = new QDBusServiceWatcher("org.kde.KWin", dbus, QDBusServiceWatcher::WatchForUnregistration, this);
+ connect (dog, SIGNAL(serviceUnregistered(const QString&)), SLOT(becomeKWinService(const QString&)));
+ }
connect(Compositor::self(), SIGNAL(compositingToggled(bool)), SIGNAL(compositingToggled(bool)));
dbus.connect(QString(), "/KWin", "org.kde.KWin", "reloadConfig",
Workspace::self(), SLOT(slotReloadConfig()));
@@ -46,8 +53,20 @@ DBusInterface::DBusInterface(QObject *parent)
Compositor::self(), SLOT(slotReinitialize()));
}
+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 == "org.kde.KWin" && QDBusConnection::sessionBus().registerService("org.kde.KWin") && sender()) {
+ sender()->deleteLater(); // bye doggy :'(
+ }
+}
+
DBusInterface::~DBusInterface()
{
+ QDBusConnection::sessionBus().unregisterService("org.kde.KWin"); // this is the long standing legal service
+ // KApplication automatically also grabs org.kde.kwin, so it's often been used externally - ensure to free it as well
+ QDBusConnection::sessionBus().unregisterService("org.kde.kwin");
}
void DBusInterface::circulateDesktopApplications()
diff --git a/dbusinterface.h b/dbusinterface.h
index 7c28c73383..40a1dd667a 100644
--- a/dbusinterface.h
+++ b/dbusinterface.h
@@ -147,6 +147,8 @@ Q_SIGNALS: // SIGNALS
* @deprecated
**/
void compositingToggled(bool active);
+private Q_SLOTS:
+ void becomeKWinService(const QString &service);
};
} // namespace
diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp
index 7e371c4ac3..6e39479780 100644
--- a/kcmkwin/kwincompositing/main.cpp
+++ b/kcmkwin/kwincompositing/main.cpp
@@ -196,7 +196,7 @@ void KWinCompositingConfig::showConfirmDialog(bool reinitCompositing)
bool revert = false;
// Feel free to extend this to support several kwin instances (multihead) if you
// think it makes sense.
- OrgKdeKWinInterface kwin("org.kde.kwin", "/KWin", QDBusConnection::sessionBus());
+ OrgKdeKWinInterface kwin("org.kde.KWin", "/KWin", QDBusConnection::sessionBus());
if (reinitCompositing ? !kwin.compositingActive().value() : !kwin.waitForCompositingSetup().value()) {
KMessageBox::sorry(this, i18n(
"Failed to activate desktop effects using the given "
@@ -399,7 +399,7 @@ void KWinCompositingConfig::updateStatusUI(bool compositingIsPossible)
ui.rearmGlSupport->hide();
}
else {
- OrgKdeKWinInterface kwin("org.kde.kwin", "/KWin", QDBusConnection::sessionBus());
+ OrgKdeKWinInterface kwin("org.kde.KWin", "/KWin", QDBusConnection::sessionBus());
ui.compositingOptionsContainer->hide();
QString text = i18n("Desktop effects are not available on this system due to the following technical issues:");
text += "
";
@@ -416,7 +416,7 @@ void KWinCompositingConfig::load()
{
initEffectSelector();
mKWinConfig->reparseConfiguration();
- QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kwin", "/KWin", "org.kde.KWin", "compositingPossible");
+ QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.KWin", "/KWin", "org.kde.KWin", "compositingPossible");
QDBusConnection::sessionBus().callWithCallback(msg, this, SLOT(updateStatusUI(bool)));
// Copy Plugins group to temp config file
@@ -527,7 +527,7 @@ bool KWinCompositingConfig::saveAdvancedTab()
void KWinCompositingConfig::save()
{
- OrgKdeKWinInterface kwin("org.kde.kwin", "/KWin", QDBusConnection::sessionBus());
+ OrgKdeKWinInterface kwin("org.kde.KWin", "/KWin", QDBusConnection::sessionBus());
if (ui.compositingType->currentIndex() == OPENGL_INDEX &&
kwin.openGLIsBroken() && !ui.rearmGlSupport->isVisible())
{
@@ -595,7 +595,7 @@ void KWinCompositingConfig::checkLoadedEffects()
{
// check for effects not supported by Backend or hardware
// such effects are enabled but not returned by DBus method loadedEffects
- OrgKdeKWinInterface kwin("org.kde.kwin", "/KWin", QDBusConnection::sessionBus());
+ OrgKdeKWinInterface kwin("org.kde.KWin", "/KWin", QDBusConnection::sessionBus());
KConfigGroup effectConfig = KConfigGroup(mKWinConfig, "Compositing");
bool enabledAfter = effectConfig.readEntry("Enabled", true);
@@ -626,7 +626,7 @@ void KWinCompositingConfig::checkLoadedEffects()
void KWinCompositingConfig::showDetailedEffectLoadingInformation()
{
QStringList disabledEffects = m_showDetailedErrors->data().toStringList();
- OrgKdeKWinInterface kwin("org.kde.kwin", "/KWin", QDBusConnection::sessionBus());
+ OrgKdeKWinInterface kwin("org.kde.KWin", "/KWin", QDBusConnection::sessionBus());
QDBusPendingReply< QString > pendingCompositingType = kwin.compositingType();
QString compositingType = pendingCompositingType.isError() ? "none" : pendingCompositingType.value();
KServiceTypeTrader* trader = KServiceTypeTrader::self();