From 861e7a5739b2cc190aba6848bab5d635e8f83211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 23 Jan 2015 09:06:05 +0100 Subject: [PATCH] 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 --- atoms.cpp | 2 ++ atoms.h | 2 ++ dbusinterface.cpp | 12 ++++++++++++ dbusinterface.h | 1 + 4 files changed, 17 insertions(+) diff --git a/atoms.cpp b/atoms.cpp index 98cd091d33..c530598581 100644 --- a/atoms.cpp +++ b/atoms.cpp @@ -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) diff --git a/atoms.h b/atoms.h index 0873d5e442..ecbc52cb60 100644 --- a/atoms.h +++ b/atoms.h @@ -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 diff --git a/dbusinterface.cpp b/dbusinterface.cpp index 0b13bf3517..e852c139c2 100644 --- a/dbusinterface.cpp +++ b/dbusinterface.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . #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 diff --git a/dbusinterface.h b/dbusinterface.h index 83ab9e7306..19e9cb529e 100644 --- a/dbusinterface.h +++ b/dbusinterface.h @@ -69,6 +69,7 @@ private Q_SLOTS: void becomeKWinService(const QString &service); private: + void announceService(); QString m_serviceName; };