Skip to content

Instantly share code, notes, and snippets.

@jsm222
Created November 7, 2021 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsm222/8b6a92566e7ce53bdc5ec094c1093549 to your computer and use it in GitHub Desktop.
Save jsm222/8b6a92566e7ce53bdc5ec094c1093549 to your computer and use it in GitHub Desktop.
--- src/appmenu/menuimporter.cpp.orig 2021-06-20 16:59:06 UTC
+++ src/appmenu/menuimporter.cpp
@@ -27,7 +27,7 @@
#include "menuimporter.h"
#include "menuimporteradaptor.h"
#include "dbusmenutypes_p.h"
-
+#include <QX11Info>
#include <QDBusMessage>
#include <QDBusObjectPath>
#include <QDBusServiceWatcher>
@@ -83,13 +83,27 @@ void MenuImporter::RegisterWindow(WId id, const QDBusO
m_windowClasses.insert(id, classClass);
m_menuServices.insert(id, service);
m_menuPaths.insert(id, path);
-
+
if (!m_serviceWatcher->watchedServices().contains(service)) {
m_serviceWatcher->addWatchedService(service);
}
+ if(path.path().startsWith(QStringLiteral("/com/canonical/menu")) && KWindowSystem::isPlatformX11()) {
+ auto *c = QX11Info::connection();
+ const QByteArray name = QByteArrayLiteral("_KDE_NET_WM_APPMENU_OBJECT_PATH");
+ const QByteArray name1 = QByteArrayLiteral("_KDE_NET_WM_APPMENU_SERVICE_NAME");
+ const xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, false, name.length(), name.constData());
+ xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(c, cookie, nullptr);
+ xcb_change_property(c, XCB_PROP_MODE_REPLACE, id, reply->atom, XCB_ATOM_STRING, 8, path.path().size(), qPrintable(path.path()));
+ const xcb_intern_atom_cookie_t cookie1 = xcb_intern_atom(c, false, name1.length(), name1.constData());
+ xcb_intern_atom_reply_t *reply1 = xcb_intern_atom_reply(c, cookie1, nullptr);
+ xcb_change_property(c, XCB_PROP_MODE_REPLACE, id, reply1->atom, XCB_ATOM_STRING, 8, service.length(), qPrintable(service));
+
+ }
+
emit WindowRegistered(id, service, path);
}
+
void MenuImporter::UnregisterWindow(WId id)
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment