diff --git a/debian/rules b/debian/rules index 9fbc0fdc0..a23c49052 100755 --- a/debian/rules +++ b/debian/rules @@ -12,4 +12,5 @@ DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) override_dh_auto_configure: dh_auto_configure -- \ - -DHOST_MULTIARCH="$(DEB_HOST_MULTIARCH)" + -DHOST_MULTIARCH="$(DEB_HOST_MULTIARCH)" \ + -DUSE_AM=YES diff --git a/frame/dbus/dockinterface.cpp b/frame/dbus/dockinterface.cpp new file mode 100644 index 000000000..d02b6fe9c --- /dev/null +++ b/frame/dbus/dockinterface.cpp @@ -0,0 +1,378 @@ +/* + * Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd. + * + * Author: donghualin + * + * Maintainer: donghualin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "dockinterface.h" + +#ifdef USE_AM +// 因为 types/dockrect.h 文件中定义了DockRect类,而在此处也定义了DockRect, +// 所以在此处先加上DOCKRECT_H宏(types/dockrect.h文件中定义的宏)来禁止包含types/dockrect.h头文件 +// 否则会出现重复定义的错误 +#define DOCKRECT_H +#include + +DockRect::DockRect() + : x(0) + , y(0) + , w(0) + , h(0) +{ +} + +QDebug operator<<(QDebug debug, const DockRect &rect) +{ + debug << QString("DockRect(%1, %2, %3, %4)").arg(rect.x) + .arg(rect.y) + .arg(rect.w) + .arg(rect.h); + + return debug; +} + +DockRect::operator QRect() const +{ + return QRect(x, y, w, h); +} + +QDBusArgument &operator<<(QDBusArgument &arg, const DockRect &rect) +{ + arg.beginStructure(); + arg << rect.x << rect.y << rect.w << rect.h; + arg.endStructure(); + + return arg; +} + +const QDBusArgument &operator>>(const QDBusArgument &arg, DockRect &rect) +{ + arg.beginStructure(); + arg >> rect.x >> rect.y >> rect.w >> rect.h; + arg.endStructure(); + + return arg; +} + +void registerDockRectMetaType() +{ + qRegisterMetaType("DockRect"); + qDBusRegisterMetaType(); +} + +/* + * Implementation of interface class __Dock + */ + +class DockPrivate +{ +public: + DockPrivate() = default; + + // begin member variables + int DisplayMode; + QStringList DockedApps; + QList Entries; + DockRect FrontendWindowRect; + int HideMode; + int HideState; + uint HideTimeout; + uint IconSize; + double Opacity; + int Position; + uint ShowTimeout; + uint WindowSize; + uint WindowSizeEfficient; + uint WindowSizeFashion; + +public: + QMap m_processingCalls; + QMap> m_waittingCalls; +}; + +// 窗管中提供的ActiveWindow接口,MinimizeWindow目前还在开发过程中,因此,关于这两个接口暂时使用v23的后端接口 +// 等窗管完成了这几个接口后,删除此处v20的接口,改成v23提供的新接口即可 +using DockInter = com::deepin::dde::daemon::Dock; +/** + * @brief 任务栏的部分DBUS接口是通过窗管获取的,由于AM后端并未提供窗管的相关接口,因此, + * 此处先将窗管的接口集成进来,作为私有类,只提供任务栏接口使用 + */ +class WM : public QDBusAbstractInterface +{ +public: + static inline const char *staticInterfaceName() + { return "com.deepin.wm"; } + +public: + explicit WM(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = Q_NULLPTR); + ~WM(); + +public Q_SLOTS: // METHODS + + inline QDBusPendingReply<> ActivateWindow(uint in0) + { + return m_dockInter->ActivateWindow(in0); + } + + QDBusPendingReply<> MinimizeWindow(uint in0) + { + return m_dockInter->MinimizeWindow(in0); + } + + inline QDBusPendingReply<> CancelPreviewWindow() + { + return asyncCallWithArgumentList(QStringLiteral("CancelPreviewWindow"), QList()); + } + + inline QDBusPendingReply<> PreviewWindow(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("CancelPreviewWindow"), argumentList); + } + +private: + DockInter *m_dockInter; +}; + +WM::WM(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) + , m_dockInter(new DockInter("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this)) +{ +} + +WM::~WM() +{ +} + +Dde_Dock::Dde_Dock(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) + , d_ptr(new DockPrivate) + , m_wm(new WM("com.deepin.wm", "/com/deepin/wm", QDBusConnection::sessionBus(), this)) +{ + QDBusConnection::sessionBus().connect(this->service(), this->path(), + "org.freedesktop.DBus.Properties", + "PropertiesChanged","sa{sv}as", + this, + SLOT(onPropertyChanged(const QDBusMessage &))); + + if (QMetaType::type("DockRect") == QMetaType::UnknownType) + registerDockRectMetaType(); +} + +Dde_Dock::~Dde_Dock() +{ + qDeleteAll(d_ptr->m_processingCalls.values()); + delete d_ptr; +} + +void Dde_Dock::onPropertyChanged(const QDBusMessage& msg) +{ + QList arguments = msg.arguments(); + if (3 != arguments.count()) + return; + + QString interfaceName = msg.arguments().at(0).toString(); + if (interfaceName != staticInterfaceName()) + return; + + QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); + QStringList keys = changedProps.keys(); + foreach(const QString &prop, keys) { + const QMetaObject* self = metaObject(); + for (int i=self->propertyOffset(); i < self->propertyCount(); ++i) { + QMetaProperty p = self->property(i); + if (p.name() == prop) + Q_EMIT p.notifySignal().invoke(this); + } + } +} + +int Dde_Dock::displayMode() +{ + return qvariant_cast(property("DisplayMode")); +} + +void Dde_Dock::setDisplayMode(int value) +{ + setProperty("DisplayMode", QVariant::fromValue(value)); +} + +QStringList Dde_Dock::dockedApps() +{ + return qvariant_cast(property("DockedApps")); +} + +QList Dde_Dock::entries() +{ + return qvariant_cast>(property("Entries")); +} + +DockRect Dde_Dock::frontendWindowRect() +{ + return qvariant_cast(property("FrontendWindowRect")); +} + +int Dde_Dock::hideMode() +{ + return qvariant_cast(property("HideMode")); +} + +void Dde_Dock::setHideMode(int value) +{ + internalPropSet("HideMode", QVariant::fromValue(value)); +} + +int Dde_Dock::hideState() +{ + return qvariant_cast(property("HideState")); +} + +uint Dde_Dock::hideTimeout() +{ + return qvariant_cast(property("HideTimeout")); +} + +void Dde_Dock::setHideTimeout(uint value) +{ + setProperty("HideTimeout", QVariant::fromValue(value)); +} + +uint Dde_Dock::iconSize() +{ + return qvariant_cast(property("IconSize")); +} + +void Dde_Dock::setIconSize(uint value) +{ + setProperty("IconSize", QVariant::fromValue(value)); +} + +double Dde_Dock::opacity() +{ + return qvariant_cast(property("Opacity")); +} + +void Dde_Dock::setOpacity(double value) +{ + setProperty("Opacity", QVariant::fromValue(value)); +} + +int Dde_Dock::position() +{ + return qvariant_cast(property("Position")); +} + +void Dde_Dock::setPosition(int value) +{ + setProperty("Position", QVariant::fromValue(value)); +} + +uint Dde_Dock::showTimeout() +{ + return qvariant_cast(property("ShowTimeout")); +} + +void Dde_Dock::setShowTimeout(uint value) +{ + setProperty("ShowTimeout", QVariant::fromValue(value)); +} + +uint Dde_Dock::windowSize() +{ + return qvariant_cast(property("WindowSize")); +} + +void Dde_Dock::setWindowSize(uint value) +{ + setProperty("WindowSize", QVariant::fromValue(value)); +} + +uint Dde_Dock::windowSizeEfficient() +{ + return qvariant_cast(property("WindowSizeEfficient")); +} + +void Dde_Dock::setWindowSizeEfficient(uint value) +{ + setProperty("WindowSizeEfficient", QVariant::fromValue(value)); +} + +uint Dde_Dock::windowSizeFashion() +{ + return qvariant_cast(property("WindowSizeFashion")); +} + +void Dde_Dock::setWindowSizeFashion(uint value) +{ + setProperty("WindowSizeFashion", QVariant::fromValue(value)); +} + +QDBusPendingReply<> Dde_Dock::ActivateWindow(uint in0) +{ + return m_wm->ActivateWindow(in0); +} + +QDBusPendingReply<> Dde_Dock::PreviewWindow(uint in0) +{ + return m_wm->PreviewWindow(in0); +} + +QDBusPendingReply<> Dde_Dock::CancelPreviewWindow() +{ + return m_wm->CancelPreviewWindow(); +} + +QDBusPendingReply<> Dde_Dock::MinimizeWindow(uint in0) +{ + return m_wm->MinimizeWindow(in0); +} + +void Dde_Dock::CallQueued(const QString &callName, const QList &args) +{ + if (d_ptr->m_waittingCalls.contains(callName)) { + d_ptr->m_waittingCalls[callName] = args; + return; + } + + if (d_ptr->m_processingCalls.contains(callName)) { + d_ptr->m_waittingCalls.insert(callName, args); + } else { + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args)); + connect(watcher, &QDBusPendingCallWatcher::finished, this, &Dde_Dock::onPendingCallFinished); + d_ptr->m_processingCalls.insert(callName, watcher); + } +} + +void Dde_Dock::onPendingCallFinished(QDBusPendingCallWatcher *w) +{ + w->deleteLater(); + const auto callName = d_ptr->m_processingCalls.key(w); + Q_ASSERT(!callName.isEmpty()); + if (callName.isEmpty()) + return; + + d_ptr->m_processingCalls.remove(callName); + if (!d_ptr->m_waittingCalls.contains(callName)) + return; + + const auto args = d_ptr->m_waittingCalls.take(callName); + CallQueued(callName, args); +} + +#endif diff --git a/frame/dbus/dockinterface.h b/frame/dbus/dockinterface.h new file mode 100644 index 000000000..1734bea2c --- /dev/null +++ b/frame/dbus/dockinterface.h @@ -0,0 +1,342 @@ +/* + * Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd. + * + * Author: donghualin + * + * Maintainer: donghualin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DOCK_INTERFACE +#define DOCK_INTERFACE + +#ifdef USE_AM + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface com.deepin.dde.daemon.Dock + */ +class DockPrivate; +class WM; + +struct DockRect +{ +public: + DockRect(); + operator QRect() const; + + friend QDebug operator<<(QDebug debug, const DockRect &rect); + friend const QDBusArgument &operator>>(const QDBusArgument &arg, DockRect &rect); + friend QDBusArgument &operator<<(QDBusArgument &arg, const DockRect &rect); + +private: + int x; + int y; + uint w; + uint h; +}; + +Q_DECLARE_METATYPE(DockRect) + +void registerDockRectMetaType(); + +class Dde_Dock : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + static inline const char *staticInterfaceName() + { return "org.deepin.dde.daemon.Dock1"; } + +public: + explicit Dde_Dock(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~Dde_Dock(); + + Q_PROPERTY(int DisplayMode READ displayMode WRITE setDisplayMode NOTIFY DisplayModeChanged) + int displayMode(); + void setDisplayMode(int value); + + Q_PROPERTY(QStringList DockedApps READ dockedApps NOTIFY DockedAppsChanged) + QStringList dockedApps(); + + Q_PROPERTY(QList Entries READ entries NOTIFY EntriesChanged) + QList entries(); + + Q_PROPERTY(DockRect FrontendWindowRect READ frontendWindowRect NOTIFY FrontendWindowRectChanged) + DockRect frontendWindowRect(); + + Q_PROPERTY(int HideMode READ hideMode WRITE setHideMode NOTIFY HideModeChanged) + int hideMode(); + void setHideMode(int value); + + Q_PROPERTY(int HideState READ hideState NOTIFY HideStateChanged) + int hideState(); + + Q_PROPERTY(uint HideTimeout READ hideTimeout WRITE setHideTimeout NOTIFY HideTimeoutChanged) + uint hideTimeout(); + void setHideTimeout(uint value); + + Q_PROPERTY(uint IconSize READ iconSize WRITE setIconSize NOTIFY IconSizeChanged) + uint iconSize(); + void setIconSize(uint value); + + Q_PROPERTY(double Opacity READ opacity WRITE setOpacity NOTIFY OpacityChanged) + double opacity(); + void setOpacity(double value); + + Q_PROPERTY(int Position READ position WRITE setPosition NOTIFY PositionChanged) + int position(); + void setPosition(int value); + + Q_PROPERTY(uint ShowTimeout READ showTimeout WRITE setShowTimeout NOTIFY ShowTimeoutChanged) + uint showTimeout(); + void setShowTimeout(uint value); + + Q_PROPERTY(uint WindowSize READ windowSize WRITE setWindowSize NOTIFY WindowSizeChanged) + uint windowSize(); + void setWindowSize(uint value); + + Q_PROPERTY(uint WindowSizeEfficient READ windowSizeEfficient WRITE setWindowSizeEfficient NOTIFY WindowSizeEfficientChanged) + uint windowSizeEfficient(); + void setWindowSizeEfficient(uint value); + + Q_PROPERTY(uint WindowSizeFashion READ windowSizeFashion WRITE setWindowSizeFashion NOTIFY WindowSizeFashionChanged) + uint windowSizeFashion(); + void setWindowSizeFashion(uint value); + +public Q_SLOTS: // METHODS + QDBusPendingReply<> ActivateWindow(uint in0); + + QDBusPendingReply<> PreviewWindow(uint in0); + + QDBusPendingReply<> CancelPreviewWindow(); + + QDBusPendingReply<> MinimizeWindow(uint in0); + + inline void ActivateWindowQueued(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + + CallQueued(QStringLiteral("ActivateWindow"), argumentList); + } + + inline QDBusPendingReply<> CloseWindow(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("CloseWindow"), argumentList); + } + + inline void CloseWindowQueued(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + + CallQueued(QStringLiteral("CloseWindow"), argumentList); + } + + inline QDBusPendingReply GetDockedAppsDesktopFiles() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("GetDockedAppsDesktopFiles"), argumentList); + } + + inline QDBusPendingReply GetEntryIDs() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("GetEntryIDs"), argumentList); + } + + inline QDBusPendingReply GetPluginSettings() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("GetPluginSettings"), argumentList); + } + + inline QDBusPendingReply IsDocked(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("IsDocked"), argumentList); + } + + inline QDBusPendingReply IsOnDock(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("IsOnDock"), argumentList); + } + + inline QDBusPendingReply<> MergePluginSettings(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("MergePluginSettings"), argumentList); + } + + inline void MergePluginSettingsQueued(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + + CallQueued(QStringLiteral("MergePluginSettings"), argumentList); + } + + inline QDBusPendingReply<> MoveEntry(int in0, int in1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + return asyncCallWithArgumentList(QStringLiteral("MoveEntry"), argumentList); + } + + inline void MoveEntryQueued(int in0, int in1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + + CallQueued(QStringLiteral("MoveEntry"), argumentList); + } + + inline void MoveWindowQueued(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + + CallQueued(QStringLiteral("MoveWindow"), argumentList); + } + + inline QDBusPendingReply QueryWindowIdentifyMethod(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("QueryWindowIdentifyMethod"), argumentList); + } + + inline QDBusPendingReply<> RemovePluginSettings(const QString &in0, const QStringList &in1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + return asyncCallWithArgumentList(QStringLiteral("RemovePluginSettings"), argumentList); + } + + inline void RemovePluginSettingsQueued(const QString &in0, const QStringList &in1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + + CallQueued(QStringLiteral("RemovePluginSettings"), argumentList); + } + + inline QDBusPendingReply RequestDock(const QString &in0, int in1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + return asyncCallWithArgumentList(QStringLiteral("RequestDock"), argumentList); + } + + inline QDBusPendingReply RequestUndock(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("RequestUndock"), argumentList); + } + + inline QDBusPendingReply<> SetFrontendWindowRect(int in0, int in1, uint in2, uint in3) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2) << QVariant::fromValue(in3); + return asyncCallWithArgumentList(QStringLiteral("SetFrontendWindowRect"), argumentList); + } + + inline void SetFrontendWindowRectQueued(int in0, int in1, uint in2, uint in3) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2) << QVariant::fromValue(in3); + + CallQueued(QStringLiteral("SetFrontendWindowRect"), argumentList); + } + + inline QDBusPendingReply<> SetPluginSettings(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("SetPluginSettings"), argumentList); + } + + inline void SetPluginSettingsQueued(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + + CallQueued(QStringLiteral("SetPluginSettings"), argumentList); + } + +Q_SIGNALS: // SIGNALS + void DockAppSettingsSynced(); + void EntryAdded(const QDBusObjectPath &in0, int in1); + void EntryRemoved(const QString &in0); + void PluginSettingsSynced(); + void ServiceRestarted(); + // begin property changed signals + void DisplayModeChanged(int value) const; + void DockedAppsChanged(const QStringList &value) const; + void EntriesChanged(const QList &value) const; + void FrontendWindowRectChanged(DockRect value) const; + void HideModeChanged(int value) const; + void HideStateChanged(int value) const; + void HideTimeoutChanged(uint value) const; + void IconSizeChanged(uint value) const; + void OpacityChanged(double value) const; + void PositionChanged(int value) const; + void ShowTimeoutChanged(uint value) const; + void WindowSizeChanged(uint value) const; + void WindowSizeEfficientChanged(uint value) const; + void WindowSizeFashionChanged(uint value) const; + +public Q_SLOTS: + void CallQueued(const QString &callName, const QList &args); + +private Q_SLOTS: + void onPendingCallFinished(QDBusPendingCallWatcher *w); + void onPropertyChanged(const QDBusMessage& msg); + +private: + DockPrivate *d_ptr; + WM *m_wm; +}; + +namespace org { + namespace deepin { + namespace dde { + namespace daemon { + typedef ::Dde_Dock DdeDock; + } + } + } +} + +#endif // USE_AM + +#endif // DOCK_INTERFACE diff --git a/frame/dbus/entryinterface.cpp b/frame/dbus/entryinterface.cpp new file mode 100644 index 000000000..f2245f921 --- /dev/null +++ b/frame/dbus/entryinterface.cpp @@ -0,0 +1,290 @@ +/* + * Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd. + * + * Author: donghualin + * + * Maintainer: donghualin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "entryinterface.h" + +/* + * Implementation of interface class __Entry + */ + +#ifdef USE_AM + +void registerWindowListMetaType() +{ + qRegisterMetaType(); + qDBusRegisterMetaType(); +} + +void registerWindowInfoMapMetaType() +{ + registerWindowInfoMetaType(); + + qRegisterMetaType("WindowInfoMap"); + qDBusRegisterMetaType(); +} + +void registerWindowInfoMetaType() +{ + qRegisterMetaType("WindowInfo"); + qDBusRegisterMetaType(); +} + +QDebug operator<<(QDebug argument, const WindowInfo &info) +{ + argument << '(' << info.title << ',' << info.attention << ')'; + + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const WindowInfo &info) +{ + argument.beginStructure(); + argument << info.title << info.attention; + argument.endStructure(); + + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, WindowInfo &info) +{ + argument.beginStructure(); + argument >> info.title >> info.attention; + argument.endStructure(); + + return argument; +} + +bool WindowInfo::operator==(const WindowInfo &rhs) const +{ + return attention == rhs.attention && + title == rhs.title; +} + +class EntryPrivate +{ +public: + EntryPrivate() = default; + + // begin member variables + uint CurrentWindow; + QString DesktopFile; + QString Icon; + QString Id; + bool IsActive; + bool IsDocked; + QString Menu; + QString Name; + + WindowInfoMap WindowInfos; + +public: + QMap m_processingCalls; + QMap> m_waittingCalls; +}; + +Dock_Entry::Dock_Entry(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) + , d_ptr(new EntryPrivate) +{ + QDBusConnection::sessionBus().connect(this->service(), this->path(), + "org.freedesktop.DBus.Properties", + "PropertiesChanged","sa{sv}as", + this, + SLOT(onPropertyChanged(const QDBusMessage &))); + + if (QMetaType::type("WindowList") == QMetaType::UnknownType) + registerWindowListMetaType(); + if (QMetaType::type("WindowInfoMap") == QMetaType::UnknownType) + registerWindowInfoMapMetaType(); +} + +Dock_Entry::~Dock_Entry() +{ + qDeleteAll(d_ptr->m_processingCalls.values()); + delete d_ptr; +} + +void Dock_Entry::onPropertyChanged(const QString &propName, const QVariant &value) +{ + if (propName == QStringLiteral("CurrentWindow")) { + const uint &CurrentWindow = qvariant_cast(value); + if (d_ptr->CurrentWindow != CurrentWindow) + { + d_ptr->CurrentWindow = CurrentWindow; + Q_EMIT CurrentWindowChanged(d_ptr->CurrentWindow); + } + return; + } + + if (propName == QStringLiteral("DesktopFile")) { + const QString &DesktopFile = qvariant_cast(value); + if (d_ptr->DesktopFile != DesktopFile) { + d_ptr->DesktopFile = DesktopFile; + Q_EMIT DesktopFileChanged(d_ptr->DesktopFile); + } + return; + } + + if (propName == QStringLiteral("Icon")) { + const QString &Icon = qvariant_cast(value); + if (d_ptr->Icon != Icon) + { + d_ptr->Icon = Icon; + Q_EMIT IconChanged(d_ptr->Icon); + } + return; + } + + if (propName == QStringLiteral("Id")) { + const QString &Id = qvariant_cast(value); + if (d_ptr->Id != Id) { + d_ptr->Id = Id; + Q_EMIT IdChanged(d_ptr->Id); + } + return; + } + + if (propName == QStringLiteral("IsActive")) { + const bool &IsActive = qvariant_cast(value); + if (d_ptr->IsActive != IsActive) { + d_ptr->IsActive = IsActive; + Q_EMIT IsActiveChanged(d_ptr->IsActive); + } + return; + } + + if (propName == QStringLiteral("IsDocked")) { + const bool &IsDocked = qvariant_cast(value); + if (d_ptr->IsDocked != IsDocked) { + d_ptr->IsDocked = IsDocked; + Q_EMIT IsDockedChanged(d_ptr->IsDocked); + } + return; + } + + if (propName == QStringLiteral("Menu")) { + const QString &Menu = qvariant_cast(value); + if (d_ptr->Menu != Menu) { + d_ptr->Menu = Menu; + Q_EMIT MenuChanged(d_ptr->Menu); + } + return; + } + + if (propName == QStringLiteral("Name")) { + const QString &Name = qvariant_cast(value); + if (d_ptr->Name != Name) { + d_ptr->Name = Name; + Q_EMIT NameChanged(d_ptr->Name); + } + return; + } + + if (propName == QStringLiteral("WindowInfos")) { + const WindowInfoMap &WindowInfos = qvariant_cast(value); + if (d_ptr->WindowInfos != WindowInfos) { + d_ptr->WindowInfos = WindowInfos; + Q_EMIT WindowInfosChanged(d_ptr->WindowInfos); + } + return; + } + + qWarning() << "property not handle: " << propName; + return; +} + +uint Dock_Entry::currentWindow() +{ + return qvariant_cast(property("CurrentWindow")); +} + +QString Dock_Entry::desktopFile() +{ + return qvariant_cast(property("DesktopFile")); +} + +QString Dock_Entry::icon() +{ + return qvariant_cast(property("Icon")); +} + +QString Dock_Entry::id() +{ + return qvariant_cast(property("Id")); +} + +bool Dock_Entry::isActive() +{ + return qvariant_cast(property("IsActive")); +} + +bool Dock_Entry::isDocked() +{ + return qvariant_cast(property("IsDocked")); +} + +QString Dock_Entry::menu() +{ + return qvariant_cast(property("Menu")); +} + +QString Dock_Entry::name() +{ + return qvariant_cast(property("Name")); +} + +WindowInfoMap Dock_Entry::windowInfos() +{ + return qvariant_cast(property("WindowInfos")); +} + +void Dock_Entry::CallQueued(const QString &callName, const QList &args) +{ + if (d_ptr->m_waittingCalls.contains(callName)) { + d_ptr->m_waittingCalls[callName] = args; + return; + } + if (d_ptr->m_processingCalls.contains(callName)) { + d_ptr->m_waittingCalls.insert(callName, args); + } else { + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args)); + connect(watcher, &QDBusPendingCallWatcher::finished, this, &Dock_Entry::onPendingCallFinished); + d_ptr->m_processingCalls.insert(callName, watcher); + } +} + +void Dock_Entry::onPendingCallFinished(QDBusPendingCallWatcher *w) +{ + w->deleteLater(); + const auto callName = d_ptr->m_processingCalls.key(w); + Q_ASSERT(!callName.isEmpty()); + if (callName.isEmpty()) + return; + + d_ptr->m_processingCalls.remove(callName); + if (!d_ptr->m_waittingCalls.contains(callName)) + return; + + const auto args = d_ptr->m_waittingCalls.take(callName); + CallQueued(callName, args); +} + +#endif diff --git a/frame/dbus/entryinterface.h b/frame/dbus/entryinterface.h new file mode 100644 index 000000000..2e0b84a7f --- /dev/null +++ b/frame/dbus/entryinterface.h @@ -0,0 +1,275 @@ +/* + * Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd. + * + * Author: donghualin + * + * Maintainer: donghualin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DOCK_ENTRY_H +#define DOCK_ENTRY_H + +#ifdef USE_AM + +#define WINDOWLIST_H +#define WINDOWINFOLIST_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef QList WindowList; + +void registerWindowListMetaType(); + +class WindowInfo +{ +public: + friend QDebug operator<<(QDebug argument, const WindowInfo &info); + friend QDBusArgument &operator<<(QDBusArgument &argument, const WindowInfo &info); + friend const QDBusArgument &operator>>(const QDBusArgument &argument, WindowInfo &info); + + bool operator==(const WindowInfo &rhs) const; + +public: + bool attention; + QString title; +}; + +Q_DECLARE_METATYPE(WindowInfo) + +typedef QMap WindowInfoMap; +Q_DECLARE_METATYPE(WindowInfoMap) + +void registerWindowInfoMetaType(); +void registerWindowInfoMapMetaType(); + +/* + * Proxy class for interface com.deepin.dde.daemon.Dock.Entry + */ +class EntryPrivate; + +class Dock_Entry : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + static inline const char *staticInterfaceName() + { return "org.deepin.dde.daemon.Dock1.Entry"; } + +public: + explicit Dock_Entry(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~Dock_Entry(); + + Q_PROPERTY(uint CurrentWindow READ currentWindow NOTIFY CurrentWindowChanged) + uint currentWindow(); + + Q_PROPERTY(QString DesktopFile READ desktopFile NOTIFY DesktopFileChanged) + QString desktopFile(); + + Q_PROPERTY(QString Icon READ icon NOTIFY IconChanged) + QString icon(); + + Q_PROPERTY(QString Id READ id NOTIFY IdChanged) + QString id(); + + Q_PROPERTY(bool IsActive READ isActive NOTIFY IsActiveChanged) + bool isActive(); + + Q_PROPERTY(bool IsDocked READ isDocked NOTIFY IsDockedChanged) + bool isDocked(); + + Q_PROPERTY(QString Menu READ menu NOTIFY MenuChanged) + QString menu(); + + Q_PROPERTY(QString Name READ name NOTIFY NameChanged) + QString name(); + + Q_PROPERTY(WindowInfoMap WindowInfos READ windowInfos NOTIFY WindowInfosChanged) + WindowInfoMap windowInfos(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<> Activate(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("Activate"), argumentList); + } + + inline void ActivateQueued(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + CallQueued(QStringLiteral("Activate"), argumentList); + } + + inline QDBusPendingReply<> Check() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("Check"), argumentList); + } + + inline void CheckQueued() + { + QList argumentList; + CallQueued(QStringLiteral("Check"), argumentList); + } + + inline QDBusPendingReply<> ForceQuit() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("ForceQuit"), argumentList); + } + + inline void ForceQuitQueued() + { + QList argumentList; + CallQueued(QStringLiteral("ForceQuit"), argumentList); + } + + inline QDBusPendingReply GetAllowedCloseWindows() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("GetAllowedCloseWindows"), argumentList); + } + + inline QDBusPendingReply<> HandleDragDrop(uint in0, const QStringList &in1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + return asyncCallWithArgumentList(QStringLiteral("HandleDragDrop"), argumentList); + } + + inline void HandleDragDropQueued(uint in0, const QStringList &in1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + CallQueued(QStringLiteral("HandleDragDrop"), argumentList); + } + + inline QDBusPendingReply<> HandleMenuItem(uint in0, const QString &in1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + return asyncCallWithArgumentList(QStringLiteral("HandleMenuItem"), argumentList); + } + + inline void HandleMenuItemQueued(uint in0, const QString &in1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + CallQueued(QStringLiteral("HandleMenuItem"), argumentList); + } + + inline QDBusPendingReply<> NewInstance(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("NewInstance"), argumentList); + } + + inline void NewInstanceQueued(uint in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + CallQueued(QStringLiteral("NewInstance"), argumentList); + } + + inline QDBusPendingReply<> PresentWindows() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("PresentWindows"), argumentList); + } + + inline void PresentWindowsQueued() + { + QList argumentList; + CallQueued(QStringLiteral("PresentWindows"), argumentList); + } + + inline QDBusPendingReply<> RequestDock() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("RequestDock"), argumentList); + } + + inline void RequestDockQueued() + { + QList argumentList; + CallQueued(QStringLiteral("RequestDock"), argumentList); + } + + inline QDBusPendingReply<> RequestUndock() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("RequestUndock"), argumentList); + } + + inline void RequestUndockQueued() + { + QList argumentList; + CallQueued(QStringLiteral("RequestUndock"), argumentList); + } + +Q_SIGNALS: // SIGNALS + // begin property changed signals + void IsActiveChanged(bool value) const; + void IsDockedChanged(bool value) const; + void MenuChanged(const QString &value) const; + void IconChanged(const QString &value) const; + void NameChanged(const QString &value) const; + void DesktopFileChanged(const QString &value) const; + void CurrentWindowChanged(uint32_t value) const; + + void WindowInfosChanged(WindowInfoMap value) const; + void IdChanged(const QString &value) const; + +private: + QVariant asyncProperty(const QString &propertyName); + +public Q_SLOTS: + void CallQueued(const QString &callName, const QList &args); + +private Q_SLOTS: + void onPendingCallFinished(QDBusPendingCallWatcher *w); + void onPropertyChanged(const QString &propName, const QVariant &value); + +private: + EntryPrivate *d_ptr; +}; + +namespace org { + namespace deepin { + namespace dde { + namespace daemon { + namespace dock { + typedef ::Dock_Entry DockEntry; + } + } + } + } +} + +#endif // USE_AM + +#endif // DOCK_ENTRY_H diff --git a/frame/util/dbusutil.h b/frame/util/dbusutil.h new file mode 100644 index 000000000..a4d7b3da5 --- /dev/null +++ b/frame/util/dbusutil.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd. + * + * Author: donghualin + * + * Maintainer: donghualin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef DBUSUTIL_H +#define DBUSUTIL_H + +#ifdef USE_AM +#include "dockinterface.h" +#include "entryinterface.h" +#else +#include +#include +#endif + +#ifdef USE_AM +using DockInter = org::deepin::dde::daemon::DdeDock; +using DockEntryInter = org::deepin::dde::daemon::dock::DockEntry; +#else +using DockInter = com::deepin::dde::daemon::Dock; +using DockEntryInter = com::deepin::dde::daemon::dock::Entry; +#endif + +inline const QString dockServiceName() +{ +#ifdef USE_AM + return QString("org.deepin.dde.daemon.Dock1"); +#else + return QString("com.deepin.dde.daemon.Dock"); +#endif +} + +inline const QString dockServicePath() +{ +#ifdef USE_AM + return QString("/org/deepin/dde/daemon/Dock1"); +#else + return QString("/com/deepin/dde/daemon/Dock"); +#endif +} + +#endif // DBUSUTIL_H diff --git a/plugins/tray/CMakeLists.txt b/plugins/tray/CMakeLists.txt index 012e29b75..aee5dbd38 100644 --- a/plugins/tray/CMakeLists.txt +++ b/plugins/tray/CMakeLists.txt @@ -12,6 +12,7 @@ file(GLOB_RECURSE SRCS "*.h" "*.cpp" "../../widgets/*.h" "../../widgets/*.cpp" "../../frame/dbus/sni/*.h" "../../frame/dbus/sni/*.cpp" "../../frame/dbus/dbusmenu.h" "../../frame/dbus/dbusmenu.cpp" "../../frame/dbus/dbusmenumanager.h" "../../frame/dbus/dbusmenumanager.cpp" + "../../frame/dbus/dockinterface.h" "../../frame/dbus/dockinterface.cpp" "../../widgets/*.h" "../../widgets/*.cpp" "../../frame/util/imageutil.h" "../../frame/util/imageutil.cpp" "../../frame/util/menudialog.h" "../../frame/util/menudialog.cpp"