diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ac5e5bb52..cca92db67d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,6 +199,8 @@ if(KWIN_BUILD_KAPPMENU) kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS} appmenu.cpp ) + qt5_add_dbus_interface(kwin_KDEINIT_SRCS + ${KDEBASE_WORKSPACE_SOURCE_DIR}/appmenu/org.kde.kappmenu.xml appmenu_interface) endif() if(KWIN_BUILD_ACTIVITIES) diff --git a/appmenu.cpp b/appmenu.cpp index 77e2f83bd9..2937a46ea1 100644 --- a/appmenu.cpp +++ b/appmenu.cpp @@ -22,31 +22,20 @@ along with this program. If not, see . #include "appmenu.h" #include "client.h" #include "workspace.h" -// Qt -#include -#include -#include +#include namespace KWin { -static QString KDED_SERVICE = QStringLiteral("org.kde.kappmenu"); -static QString KDED_APPMENU_PATH = QStringLiteral("/KAppMenu"); -static QString KDED_INTERFACE = QStringLiteral("org.kde.kappmenu"); - KWIN_SINGLETON_FACTORY(ApplicationMenu) ApplicationMenu::ApplicationMenu(QObject *parent) : QObject(parent) + , m_appmenuInterface(new OrgKdeKappmenuInterface(QStringLiteral("org.kde.kappmenu"), QStringLiteral("/KAppMenu"), QDBusConnection::sessionBus(), this)) { - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, QStringLiteral("showRequest"), - this, SLOT(slotShowRequest(qulonglong))); - dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, QStringLiteral("menuAvailable"), - this, SLOT(slotMenuAvailable(qulonglong))); - dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, QStringLiteral("menuHidden"), - this, SLOT(slotMenuHidden(qulonglong))); - dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, QStringLiteral("clearMenus"), - this, SLOT(slotClearMenus())); + connect(m_appmenuInterface, &OrgKdeKappmenuInterface::showRequest, this, &ApplicationMenu::slotShowRequest); + connect(m_appmenuInterface, &OrgKdeKappmenuInterface::menuAvailable, this, &ApplicationMenu::slotMenuAvailable); + connect(m_appmenuInterface, &OrgKdeKappmenuInterface::menuHidden, this, &ApplicationMenu::slotMenuHidden); + connect(m_appmenuInterface, &OrgKdeKappmenuInterface::clearMenus, this, &ApplicationMenu::slotClearMenus); } ApplicationMenu::~ApplicationMenu() @@ -88,10 +77,7 @@ void ApplicationMenu::slotClearMenus() void ApplicationMenu::showApplicationMenu(const QPoint &p, const xcb_window_t id) { - QList args = QList() << p.x() << p.y() << qulonglong(id); - QDBusMessage method = QDBusMessage::createMethodCall(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, QStringLiteral("showMenu")); - method.setArguments(args); - QDBusConnection::sessionBus().asyncCall(method); + m_appmenuInterface->showMenu(p.x(), p.y(), id); } } // namespace diff --git a/appmenu.h b/appmenu.h index 43b5a2b476..341b5f0d35 100644 --- a/appmenu.h +++ b/appmenu.h @@ -29,6 +29,7 @@ along with this program. If not, see . #include class QPoint; +class OrgKdeKappmenuInterface; namespace KWin { @@ -51,6 +52,7 @@ private Q_SLOTS: private: QList m_windowsMenu; + OrgKdeKappmenuInterface *m_appmenuInterface; KWIN_SINGLETON(ApplicationMenu) };