Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.3
plasma5-workspace
0029-Generate-DBusMenu-Interface-for-libdbusmen...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0029-Generate-DBusMenu-Interface-for-libdbusmenuqt.patch of Package plasma5-workspace
From f0ba40d4bcb8a59493f822be568fad11cccd2413 Mon Sep 17 00:00:00 2001 From: David Edmundson <kde@davidedmundson.co.uk> Date: Tue, 17 Jan 2017 14:34:48 +0000 Subject: [PATCH 29/44] Generate DBusMenu Interface for libdbusmenuqt Summary: This not only makes the code cleaner but more importantly avoids plasma making a blocking DBus call to a client in the QDBusInterface constructor which does a blocking call to Introspect Test Plan: Ran my test app with the dynamic menu. Everything was still fine Reviewers: #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4172 --- libdbusmenuqt/CMakeLists.txt | 8 ++++++ libdbusmenuqt/com.canonical.dbusmenu.xml | 49 ++++++++++++++++++++++++++++++++ libdbusmenuqt/dbusmenuimporter.cpp | 25 +++++++--------- libdbusmenuqt/dbusmenuimporter.h | 1 - 4 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 libdbusmenuqt/com.canonical.dbusmenu.xml diff --git a/libdbusmenuqt/CMakeLists.txt b/libdbusmenuqt/CMakeLists.txt index 6c13e470..49d34204 100644 --- a/libdbusmenuqt/CMakeLists.txt +++ b/libdbusmenuqt/CMakeLists.txt @@ -5,6 +5,14 @@ dbusmenutypes_p.cpp utils.cpp ) +set_source_files_properties(com.canonical.dbusmenu.xml PROPERTIES + NO_NAMESPACE true + INCLUDE "dbusmenutypes_p.h" + CLASSNAME DBusMenuInterface +) +qt5_add_dbus_interface(libdbusmenu_SRCS com.canonical.dbusmenu.xml dbusmenu_interface) + + add_library(dbusmenuqt STATIC ${libdbusmenu_SRCS}) target_link_libraries(dbusmenuqt Qt5::DBus diff --git a/libdbusmenuqt/com.canonical.dbusmenu.xml b/libdbusmenuqt/com.canonical.dbusmenu.xml new file mode 100644 index 00000000..a5118c3e --- /dev/null +++ b/libdbusmenuqt/com.canonical.dbusmenu.xml @@ -0,0 +1,49 @@ +<interface name="com.canonical.dbusmenu"> + <property name="Version" type="u" access="read"/> + <property name="Status" type="s" access="read"/> + <signal name="ItemsPropertiesUpdated"> + <arg type="a(ia{sv})" direction="out"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="DBusMenuItemList"/> + <arg type="a(ias)" direction="out"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="DBusMenuItemKeysList"/> + </signal> + <signal name="LayoutUpdated"> + <arg name="revision" type="u" direction="out"/> + <arg name="parentId" type="i" direction="out"/> + </signal> + <signal name="ItemActivationRequested"> + <arg name="id" type="i" direction="out"/> + <arg name="timeStamp" type="u" direction="out"/> + </signal> + <method name="Event"> + <arg name="id" type="i" direction="in"/> + <arg name="eventId" type="s" direction="in"/> + <arg name="data" type="v" direction="in"/> + <arg name="timestamp" type="u" direction="in"/> + <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> + </method> + <method name="GetProperty"> + <arg type="v" direction="out"/> + <arg name="id" type="i" direction="in"/> + <arg name="property" type="s" direction="in"/> + </method> + <method name="GetLayout"> + <arg type="u" direction="out"/> + <arg name="parentId" type="i" direction="in"/> + <arg name="recursionDepth" type="i" direction="in"/> + <arg name="propertyNames" type="as" direction="in"/> + <arg name="item" type="(ia{sv}av)" direction="out"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="DBusMenuLayoutItem"/> + </method> + <method name="GetGroupProperties"> + <arg type="a(ia{sv})" direction="out"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="DBusMenuItemList"/> + <arg name="ids" type="ai" direction="in"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QList<int>"/> + <arg name="propertyNames" type="as" direction="in"/> + </method> + <method name="AboutToShow"> + <arg type="b" direction="out"/> + <arg name="id" type="i" direction="in"/> + </method> +</interface> diff --git a/libdbusmenuqt/dbusmenuimporter.cpp b/libdbusmenuqt/dbusmenuimporter.cpp index 8737fb25..07f62acd 100644 --- a/libdbusmenuqt/dbusmenuimporter.cpp +++ b/libdbusmenuqt/dbusmenuimporter.cpp @@ -41,6 +41,9 @@ #include "dbusmenushortcut_p.h" #include "utils_p.h" +// Generated +#include "dbusmenu_interface.h" + //#define BENCHMARK #ifdef BENCHMARK #include <QTime> @@ -52,8 +55,6 @@ static QTime sChrono; return; \ } -static const char *DBUSMENU_INTERFACE = "com.canonical.dbusmenu"; - static const char *DBUSMENU_PROPERTY_ID = "_dbusmenu_id"; static const char *DBUSMENU_PROPERTY_ICON_NAME = "_dbusmenu_icon_name"; static const char *DBUSMENU_PROPERTY_ICON_DATA_HASH = "_dbusmenu_icon_data_hash"; @@ -79,7 +80,7 @@ class DBusMenuImporterPrivate public: DBusMenuImporter *q; - QDBusAbstractInterface *m_interface; + DBusMenuInterface *m_interface; QMenu *m_menu; using ActionForId = QMap<int, QAction* >; ActionForId m_actionForId; @@ -90,7 +91,7 @@ public: QDBusPendingCallWatcher *refresh(int id) { - QDBusPendingCall call = m_interface->asyncCall(QStringLiteral("GetLayout"), id, 1, QStringList()); + auto call = m_interface->GetLayout(id, 1, QStringList()); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, q); watcher->setProperty(DBUSMENU_PROPERTY_ID, id); QObject::connect(watcher, &QDBusPendingCallWatcher::finished, @@ -266,8 +267,7 @@ public: void sendEvent(int id, const QString &eventId) { - QVariant empty = QVariant::fromValue(QDBusVariant(QString())); - m_interface->asyncCall(QStringLiteral("Event"), id, eventId, empty, 0u); + m_interface->Event(id, eventId, QDBusVariant(QString()), 0u); } }; @@ -278,19 +278,16 @@ DBusMenuImporter::DBusMenuImporter(const QString &service, const QString &path, DBusMenuTypes_register(); d->q = this; - d->m_interface = new QDBusInterface(service, path, DBUSMENU_INTERFACE, QDBusConnection::sessionBus(), this); + d->m_interface = new DBusMenuInterface(service, path, QDBusConnection::sessionBus(), this); d->m_menu = 0; d->m_pendingLayoutUpdateTimer = new QTimer(this); d->m_pendingLayoutUpdateTimer->setSingleShot(true); connect(d->m_pendingLayoutUpdateTimer, &QTimer::timeout, this, &DBusMenuImporter::processPendingLayoutUpdates); - QDBusConnection::sessionBus().connect(service, path, DBUSMENU_INTERFACE, QStringLiteral("LayoutUpdated"), QStringLiteral("ui"), - this, SLOT(slotLayoutUpdated(uint, int))); - QDBusConnection::sessionBus().connect(service, path, DBUSMENU_INTERFACE, QStringLiteral("ItemsPropertiesUpdated"), QStringLiteral("a(ia{sv})a(ias)"), - this, SLOT(slotItemsPropertiesUpdated(DBusMenuItemList, DBusMenuItemKeysList))); - QDBusConnection::sessionBus().connect(service, path, DBUSMENU_INTERFACE, QStringLiteral("ItemActivationRequested"), QStringLiteral("iu"), - this, SLOT(slotItemActivationRequested(int, uint))); + connect(d->m_interface, &DBusMenuInterface::LayoutUpdated, this, &DBusMenuImporter::slotLayoutUpdated); + connect(d->m_interface, &DBusMenuInterface::ItemActivationRequested, this, &DBusMenuImporter::slotItemActivationRequested); + connect(d->m_interface, &DBusMenuInterface::ItemsPropertiesUpdated, this, std::bind(&DBusMenuImporterPrivate::slotItemsPropertiesUpdated, d, std::placeholders::_1, std::placeholders::_2)); d->refresh(0); } @@ -467,7 +464,7 @@ void DBusMenuImporter::updateMenu(QMenu * menu) int id = action->property(DBUSMENU_PROPERTY_ID).toInt(); - QDBusPendingCall call = d->m_interface->asyncCall(QStringLiteral("AboutToShow"), id); + auto call = d->m_interface->AboutToShow(id); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); watcher->setProperty(DBUSMENU_PROPERTY_ID, id); connect(watcher, &QDBusPendingCallWatcher::finished, this, diff --git a/libdbusmenuqt/dbusmenuimporter.h b/libdbusmenuqt/dbusmenuimporter.h index 5c4d7c46..6d3fd4f8 100644 --- a/libdbusmenuqt/dbusmenuimporter.h +++ b/libdbusmenuqt/dbusmenuimporter.h @@ -25,7 +25,6 @@ #include <QtCore/QObject> class QAction; -class QDBusAbstractInterface; class QDBusPendingCallWatcher; class QDBusVariant; class QIcon; -- 2.12.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor