fix dbus service registration/invocation
REVIEW: 108016
This commit is contained in:
parent
75e87a44ce
commit
2f18371e27
3 changed files with 28 additions and 7 deletions
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// own
|
// own
|
||||||
#include "dbusinterface.h"
|
#include "dbusinterface.h"
|
||||||
|
|
||||||
// kwin
|
// kwin
|
||||||
// TODO: remove together with deprecated methods
|
// TODO: remove together with deprecated methods
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
@ -28,6 +29,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "kwinadaptor.h"
|
#include "kwinadaptor.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
|
|
||||||
|
// Qt
|
||||||
|
#include <QDBusServiceWatcher>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -38,7 +42,10 @@ DBusInterface::DBusInterface(QObject *parent)
|
||||||
|
|
||||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||||
dbus.registerObject("/KWin", this);
|
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)));
|
connect(Compositor::self(), SIGNAL(compositingToggled(bool)), SIGNAL(compositingToggled(bool)));
|
||||||
dbus.connect(QString(), "/KWin", "org.kde.KWin", "reloadConfig",
|
dbus.connect(QString(), "/KWin", "org.kde.KWin", "reloadConfig",
|
||||||
Workspace::self(), SLOT(slotReloadConfig()));
|
Workspace::self(), SLOT(slotReloadConfig()));
|
||||||
|
@ -46,8 +53,20 @@ DBusInterface::DBusInterface(QObject *parent)
|
||||||
Compositor::self(), SLOT(slotReinitialize()));
|
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()
|
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()
|
void DBusInterface::circulateDesktopApplications()
|
||||||
|
|
|
@ -147,6 +147,8 @@ Q_SIGNALS: // SIGNALS
|
||||||
* @deprecated
|
* @deprecated
|
||||||
**/
|
**/
|
||||||
void compositingToggled(bool active);
|
void compositingToggled(bool active);
|
||||||
|
private Q_SLOTS:
|
||||||
|
void becomeKWinService(const QString &service);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -196,7 +196,7 @@ void KWinCompositingConfig::showConfirmDialog(bool reinitCompositing)
|
||||||
bool revert = false;
|
bool revert = false;
|
||||||
// Feel free to extend this to support several kwin instances (multihead) if you
|
// Feel free to extend this to support several kwin instances (multihead) if you
|
||||||
// think it makes sense.
|
// 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()) {
|
if (reinitCompositing ? !kwin.compositingActive().value() : !kwin.waitForCompositingSetup().value()) {
|
||||||
KMessageBox::sorry(this, i18n(
|
KMessageBox::sorry(this, i18n(
|
||||||
"Failed to activate desktop effects using the given "
|
"Failed to activate desktop effects using the given "
|
||||||
|
@ -399,7 +399,7 @@ void KWinCompositingConfig::updateStatusUI(bool compositingIsPossible)
|
||||||
ui.rearmGlSupport->hide();
|
ui.rearmGlSupport->hide();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
OrgKdeKWinInterface kwin("org.kde.kwin", "/KWin", QDBusConnection::sessionBus());
|
OrgKdeKWinInterface kwin("org.kde.KWin", "/KWin", QDBusConnection::sessionBus());
|
||||||
ui.compositingOptionsContainer->hide();
|
ui.compositingOptionsContainer->hide();
|
||||||
QString text = i18n("Desktop effects are not available on this system due to the following technical issues:");
|
QString text = i18n("Desktop effects are not available on this system due to the following technical issues:");
|
||||||
text += "<hr>";
|
text += "<hr>";
|
||||||
|
@ -416,7 +416,7 @@ void KWinCompositingConfig::load()
|
||||||
{
|
{
|
||||||
initEffectSelector();
|
initEffectSelector();
|
||||||
mKWinConfig->reparseConfiguration();
|
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)));
|
QDBusConnection::sessionBus().callWithCallback(msg, this, SLOT(updateStatusUI(bool)));
|
||||||
|
|
||||||
// Copy Plugins group to temp config file
|
// Copy Plugins group to temp config file
|
||||||
|
@ -527,7 +527,7 @@ bool KWinCompositingConfig::saveAdvancedTab()
|
||||||
|
|
||||||
void KWinCompositingConfig::save()
|
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 &&
|
if (ui.compositingType->currentIndex() == OPENGL_INDEX &&
|
||||||
kwin.openGLIsBroken() && !ui.rearmGlSupport->isVisible())
|
kwin.openGLIsBroken() && !ui.rearmGlSupport->isVisible())
|
||||||
{
|
{
|
||||||
|
@ -595,7 +595,7 @@ void KWinCompositingConfig::checkLoadedEffects()
|
||||||
{
|
{
|
||||||
// check for effects not supported by Backend or hardware
|
// check for effects not supported by Backend or hardware
|
||||||
// such effects are enabled but not returned by DBus method loadedEffects
|
// 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");
|
KConfigGroup effectConfig = KConfigGroup(mKWinConfig, "Compositing");
|
||||||
bool enabledAfter = effectConfig.readEntry("Enabled", true);
|
bool enabledAfter = effectConfig.readEntry("Enabled", true);
|
||||||
|
|
||||||
|
@ -626,7 +626,7 @@ void KWinCompositingConfig::checkLoadedEffects()
|
||||||
void KWinCompositingConfig::showDetailedEffectLoadingInformation()
|
void KWinCompositingConfig::showDetailedEffectLoadingInformation()
|
||||||
{
|
{
|
||||||
QStringList disabledEffects = m_showDetailedErrors->data().toStringList();
|
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();
|
QDBusPendingReply< QString > pendingCompositingType = kwin.compositingType();
|
||||||
QString compositingType = pendingCompositingType.isError() ? "none" : pendingCompositingType.value();
|
QString compositingType = pendingCompositingType.isError() ? "none" : pendingCompositingType.value();
|
||||||
KServiceTypeTrader* trader = KServiceTypeTrader::self();
|
KServiceTypeTrader* trader = KServiceTypeTrader::self();
|
||||||
|
|
Loading…
Reference in a new issue