Announce KWin's dbus service name on a root window property

KWin sets a _ORG_KDE_KWIN_DBUS_SERVICE property on the root window
with the name of the DBus service it registered. The type of the
property is UTF8_STRING.

REVIEW: 122215
icc-effect-5.14.5
Martin Gräßlin 2015-01-23 09:06:05 +01:00
parent cef84cd8a5
commit 861e7a5739
4 changed files with 17 additions and 0 deletions

View File

@ -56,6 +56,8 @@ Atoms::Atoms()
, kde_skip_close_animation(QByteArrayLiteral("_KDE_NET_WM_SKIP_CLOSE_ANIMATION"))
, kde_screen_edge_show(QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW"))
, gtk_frame_extents(QByteArrayLiteral("_GTK_FRAME_EXTENTS"))
, kwin_dbus_service(QByteArrayLiteral("_ORG_KDE_KWIN_DBUS_SERVICE"))
, utf8_string(QByteArrayLiteral("UTF8_STRING"))
, m_dtSmWindowInfo(QByteArrayLiteral("_DT_SM_WINDOW_INFO"))
, m_motifSupport(QByteArrayLiteral("_MOTIF_WM_INFO"))
, m_helpersRetrieved(false)

View File

@ -65,6 +65,8 @@ public:
Xcb::Atom kde_skip_close_animation;
Xcb::Atom kde_screen_edge_show;
Xcb::Atom gtk_frame_extents;
Xcb::Atom kwin_dbus_service;
Xcb::Atom utf8_string;
/**
* @internal

View File

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "compositingadaptor.h"
// kwin
#include "atoms.h"
#include "composite.h"
#include "compositingprefs.h"
#include "main.h"
@ -56,6 +57,8 @@ DBusInterface::DBusInterface(QObject *parent)
if (!dbus.registerService(m_serviceName)) {
QDBusServiceWatcher *dog = new QDBusServiceWatcher(m_serviceName, dbus, QDBusServiceWatcher::WatchForUnregistration, this);
connect (dog, SIGNAL(serviceUnregistered(QString)), SLOT(becomeKWinService(QString)));
} else {
announceService();
}
dbus.connect(QString(), QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"),
Workspace::self(), SLOT(slotReloadConfig()));
@ -67,6 +70,7 @@ void DBusInterface::becomeKWinService(const QString &service)
// but it's probably no longer needed since we explicitly unregister the service with the deconstructor
if (service == m_serviceName && QDBusConnection::sessionBus().registerService(m_serviceName) && sender()) {
sender()->deleteLater(); // bye doggy :'(
announceService();
}
}
@ -75,6 +79,14 @@ 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);
}
void DBusInterface::announceService()
{
const QByteArray service = m_serviceName.toUtf8();
xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, rootWindow(), atoms->kwin_dbus_service,
atoms->utf8_string, 8, service.size(), service.constData());
}
// wrap void methods with no arguments to Workspace

View File

@ -69,6 +69,7 @@ private Q_SLOTS:
void becomeKWinService(const QString &service);
private:
void announceService();
QString m_serviceName;
};