summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2012-12-29 23:15:30 (GMT)
committerThomas Lübking <thomas.luebking@gmail.com>2013-01-02 18:05:11 (GMT)
commit59d1104d5e9a9bebf7b2207888c964b4becc2e78 (patch)
tree58376be56864dbf15b0cc73de96d1ba2ab5d80fd
parent7ab26e350c564fefa5fc5d82766811ac24a3c7c0 (diff)
fix dbus service registration/invocation
REVIEW: 108016
-rw-r--r--kwin/dbusinterface.cpp21
-rw-r--r--kwin/dbusinterface.h2
-rw-r--r--kwin/kcmkwin/kwincompositing/main.cpp12
3 files changed, 28 insertions, 7 deletions
diff --git a/kwin/dbusinterface.cpp b/kwin/dbusinterface.cpp
index 0aa6eb0..abee120 100644
--- a/kwin/dbusinterface.cpp
+++ b/kwin/dbusinterface.cpp
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// 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 <http://www.gnu.org/licenses/>.
#include "kwinadaptor.h"
#include "workspace.h"
+// Qt
+#include <QDBusServiceWatcher>
+
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/kwin/dbusinterface.h b/kwin/dbusinterface.h
index 7c28c73..40a1dd6 100644
--- a/kwin/dbusinterface.h
+++ b/kwin/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/kwin/kcmkwin/kwincompositing/main.cpp b/kwin/kcmkwin/kwincompositing/main.cpp
index 7e371c4..6e39479 100644
--- a/kwin/kcmkwin/kwincompositing/main.cpp
+++ b/kwin/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 += "<hr>";
@@ -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();