fix: 修复Dock模块窗口属性异常的问题
修复Dock模块窗口属性WindowInfo异常的问题 log: Task: https://pms.uniontech.com/task-view-136759.html Influence: 无 Change-Id: I9bf9e532ec003d4ba7d35d6a5ed0af4e3b5d299d
This commit is contained in:
		@ -12,7 +12,7 @@ DockRect::DockRect()
 | 
			
		||||
 | 
			
		||||
QDebug operator<<(QDebug debug, const DockRect &rect)
 | 
			
		||||
{
 | 
			
		||||
    debug << QString("Rect(%1, %2, %3, %4)").arg(rect.X)
 | 
			
		||||
    debug << QString("DockRect(%1, %2, %3, %4)").arg(rect.X)
 | 
			
		||||
                                                .arg(rect.Y)
 | 
			
		||||
                                                .arg(rect.Width)
 | 
			
		||||
                                                .arg(rect.Height);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										51
									
								
								src/frameworkdbus/types/exportwindowinfo.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/frameworkdbus/types/exportwindowinfo.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,51 @@
 | 
			
		||||
#include "exportwindowinfo.h"
 | 
			
		||||
 | 
			
		||||
#include <QtDebug>
 | 
			
		||||
 | 
			
		||||
ExportWindowInfo::ExportWindowInfo()
 | 
			
		||||
 : m_xid(0)
 | 
			
		||||
 , m_flash(false)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ExportWindowInfo::ExportWindowInfo(uint32_t xid, const QString &title, bool flash)
 | 
			
		||||
 : m_xid(xid)
 | 
			
		||||
 , m_title(title)
 | 
			
		||||
 , m_flash(flash)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QDebug operator<<(QDebug debug, const ExportWindowInfo &info)
 | 
			
		||||
{
 | 
			
		||||
    debug << QString("ExportWindowInfo(%1, %2, %3)").arg(info.m_xid)
 | 
			
		||||
                                                .arg(info.m_title)
 | 
			
		||||
                                                .arg(info.m_flash);
 | 
			
		||||
 | 
			
		||||
    return debug;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QDBusArgument &operator<<(QDBusArgument &arg, const ExportWindowInfo &info)
 | 
			
		||||
{
 | 
			
		||||
    arg.beginStructure();
 | 
			
		||||
    arg << info.m_xid << info.m_title << info.m_flash;
 | 
			
		||||
    arg.endStructure();
 | 
			
		||||
 | 
			
		||||
    return arg;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const QDBusArgument &operator>>(const QDBusArgument &arg, ExportWindowInfo &info)
 | 
			
		||||
{
 | 
			
		||||
    arg.beginStructure();
 | 
			
		||||
    arg >> info.m_xid >> info.m_title >> info.m_flash;
 | 
			
		||||
    arg.endStructure();
 | 
			
		||||
 | 
			
		||||
    return arg;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void registerExportWindowInfoMetaType()
 | 
			
		||||
{
 | 
			
		||||
    qRegisterMetaType<ExportWindowInfo>("ExportWindowInfo");
 | 
			
		||||
    qDBusRegisterMetaType<ExportWindowInfo>();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										31
									
								
								src/frameworkdbus/types/exportwindowinfo.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/frameworkdbus/types/exportwindowinfo.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
#ifndef EXPORTWINDOWINFO_H
 | 
			
		||||
#define EXPORTWINDOWINFO_H
 | 
			
		||||
 | 
			
		||||
#include <QRect>
 | 
			
		||||
#include <QDBusMetaType>
 | 
			
		||||
 | 
			
		||||
struct ExportWindowInfo
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    ExportWindowInfo();
 | 
			
		||||
    ExportWindowInfo(uint32_t xid, const QString &title, bool flash);
 | 
			
		||||
 | 
			
		||||
    friend QDebug operator<<(QDebug debug, const ExportWindowInfo &rect);
 | 
			
		||||
    friend const QDBusArgument &operator>>(const QDBusArgument &arg, ExportWindowInfo &rect);
 | 
			
		||||
    friend QDBusArgument &operator<<(QDBusArgument &arg, const ExportWindowInfo &rect);
 | 
			
		||||
 | 
			
		||||
    uint32_t getXid() {return m_xid;}
 | 
			
		||||
    QString getTitle() {return m_title;}
 | 
			
		||||
    bool getFlash() {return m_flash;}
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    uint32_t m_xid;
 | 
			
		||||
    QString m_title;
 | 
			
		||||
    bool m_flash;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_METATYPE(ExportWindowInfo)
 | 
			
		||||
 | 
			
		||||
void registerExportWindowInfoMetaType();
 | 
			
		||||
 | 
			
		||||
#endif // EXPORTWINDOWINFO_H
 | 
			
		||||
							
								
								
									
										18
									
								
								src/frameworkdbus/types/exportwindowinfolist.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/frameworkdbus/types/exportwindowinfolist.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
#include "exportwindowinfolist.h"
 | 
			
		||||
 | 
			
		||||
void sortExprotWindowInfoList(ExportWindowInfoList &list)
 | 
			
		||||
{
 | 
			
		||||
    qSort(list.begin(), list.end(), compareWindowXid);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void registerExportWindowInfoListMetaType()
 | 
			
		||||
{
 | 
			
		||||
    qRegisterMetaType<ExportWindowInfoList>("ExportWindowInfoList");
 | 
			
		||||
    qDBusRegisterMetaType<ExportWindowInfoList>();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 按xid进行排序
 | 
			
		||||
bool compareWindowXid(ExportWindowInfo &info1, ExportWindowInfo &info2)
 | 
			
		||||
{
 | 
			
		||||
    return info1.getXid() < info2.getXid();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								src/frameworkdbus/types/exportwindowinfolist.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/frameworkdbus/types/exportwindowinfolist.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
#ifndef EXPORTWINDOWINFOLIST_H
 | 
			
		||||
#define EXPORTWINDOWINFOLIST_H
 | 
			
		||||
#include "exportwindowinfo.h"
 | 
			
		||||
 | 
			
		||||
#include <QtCore/QList>
 | 
			
		||||
#include <QDBusMetaType>
 | 
			
		||||
 | 
			
		||||
typedef QList<ExportWindowInfo> ExportWindowInfoList;
 | 
			
		||||
 | 
			
		||||
bool compareWindowXid(ExportWindowInfo &info1, ExportWindowInfo &info2);
 | 
			
		||||
 | 
			
		||||
void sortExprotWindowInfoList(ExportWindowInfoList &list);
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_METATYPE(ExportWindowInfoList)
 | 
			
		||||
 | 
			
		||||
void registerExportWindowInfoListMetaType();
 | 
			
		||||
 | 
			
		||||
#endif // EXPORTWINDOWINFOLIST_H
 | 
			
		||||
@ -27,7 +27,11 @@ DBusAdaptorEntry::DBusAdaptorEntry(QObject *parent)
 | 
			
		||||
 | 
			
		||||
    // constructor
 | 
			
		||||
    setAutoRelaySignals(true);
 | 
			
		||||
    //qDBusRegisterMetaType<ExportWindowInfo>();
 | 
			
		||||
    if (QMetaType::type("ExportWindowInfo") == QMetaType::UnknownType)
 | 
			
		||||
        registerExportWindowInfoMetaType();
 | 
			
		||||
 | 
			
		||||
    if (QMetaType::type("ExportWindowInfoList") == QMetaType::UnknownType)
 | 
			
		||||
        registerExportWindowInfoListMetaType();
 | 
			
		||||
 | 
			
		||||
    Entry *entry = static_cast<Entry *>(QObject::parent());
 | 
			
		||||
    if (entry) {
 | 
			
		||||
@ -38,12 +42,12 @@ DBusAdaptorEntry::DBusAdaptorEntry(QObject *parent)
 | 
			
		||||
        connect(entry, &Entry::nameChanged, this, &DBusAdaptorEntry::NameChanged);
 | 
			
		||||
        connect(entry, &Entry::desktopFileChanged, this, &DBusAdaptorEntry::DesktopFileChanged);
 | 
			
		||||
        connect(entry, &Entry::currentWindowChanged, this, &DBusAdaptorEntry::CurrentWindowChanged);
 | 
			
		||||
        connect(entry, &Entry::windowInfosChanged, this, &DBusAdaptorEntry::WindowInfosChanged);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DBusAdaptorEntry::~DBusAdaptorEntry()
 | 
			
		||||
{
 | 
			
		||||
    // destructor
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint DBusAdaptorEntry::currentWindow() const
 | 
			
		||||
@ -86,12 +90,11 @@ QString DBusAdaptorEntry::name() const
 | 
			
		||||
    return parent()->getName();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
QList<ExportWindowInfo> DBusAdaptorEntry::windowInfos()
 | 
			
		||||
ExportWindowInfoList DBusAdaptorEntry::windowInfos()
 | 
			
		||||
{
 | 
			
		||||
    return parent()->getExportWindowInfos();
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
Entry *DBusAdaptorEntry::parent() const
 | 
			
		||||
{
 | 
			
		||||
    return static_cast<Entry *>(QObject::parent());
 | 
			
		||||
@ -152,26 +155,3 @@ void DBusAdaptorEntry::RequestUndock()
 | 
			
		||||
    parent()->requestUndock();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
QDBusArgument &operator <<(QDBusArgument &argument, const ExportWindowInfo &info)
 | 
			
		||||
{
 | 
			
		||||
    argument.beginStructure();
 | 
			
		||||
    argument << info.xid << info.title << info.flash;
 | 
			
		||||
    argument.endStructure();
 | 
			
		||||
    return argument;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const QDBusArgument &operator >>(const QDBusArgument &argument, ExportWindowInfo &info)
 | 
			
		||||
{
 | 
			
		||||
    argument.beginStructure();
 | 
			
		||||
    argument >> info.xid >> info.title >> info.flash;
 | 
			
		||||
    argument.endStructure();
 | 
			
		||||
    return argument;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QDebug operator<<(QDebug deg, const ExportWindowInfo &info)
 | 
			
		||||
{
 | 
			
		||||
    qDebug() << "xid: " << info.xid << " title:" << info.title << " flash:" << info.flash;
 | 
			
		||||
 | 
			
		||||
    return deg;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -23,6 +23,7 @@
 | 
			
		||||
#define DBUSADAPTORENTRY_H
 | 
			
		||||
 | 
			
		||||
#include "entry.h"
 | 
			
		||||
#include "exportwindowinfolist.h"
 | 
			
		||||
 | 
			
		||||
#include <QtCore/QObject>
 | 
			
		||||
#include <QtCore/QMetaObject>
 | 
			
		||||
@ -37,12 +38,6 @@
 | 
			
		||||
 | 
			
		||||
#include <DBusExtendedAbstractInterface>
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_METATYPE(ExportWindowInfo)
 | 
			
		||||
 | 
			
		||||
QDBusArgument &operator <<(QDBusArgument &argument, const ExportWindowInfo &info);
 | 
			
		||||
const QDBusArgument &operator >>(const QDBusArgument &argument, ExportWindowInfo &info);
 | 
			
		||||
QDebug operator<<(QDebug deg, const ExportWindowInfo &info);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Adaptor class for interface org.deepin.dde.daemon.Dock1.Entry
 | 
			
		||||
 */
 | 
			
		||||
@ -51,40 +46,41 @@ class DBusAdaptorEntry: public QDBusAbstractAdaptor
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
    Q_CLASSINFO("D-Bus Interface", "org.deepin.dde.daemon.Dock1.Entry")
 | 
			
		||||
    Q_CLASSINFO("D-Bus Introspection", ""
 | 
			
		||||
"  <interface name=\"org.deepin.dde.daemon.Dock1.Entry\">\n"
 | 
			
		||||
"    <method name=\"Activate\">\n"
 | 
			
		||||
"      <arg direction=\"in\" type=\"u\" name=\"timestamp\"/>\n"
 | 
			
		||||
"    </method>\n"
 | 
			
		||||
"    <method name=\"Check\"/>\n"
 | 
			
		||||
"    <method name=\"ForceQuit\"/>\n"
 | 
			
		||||
"    <method name=\"GetAllowedCloseWindows\">\n"
 | 
			
		||||
"      <arg direction=\"out\" type=\"au\" name=\"windows\"/>\n"
 | 
			
		||||
"    </method>\n"
 | 
			
		||||
"    <method name=\"HandleDragDrop\">\n"
 | 
			
		||||
"      <arg direction=\"in\" type=\"u\" name=\"timestamp\"/>\n"
 | 
			
		||||
"      <arg direction=\"in\" type=\"as\" name=\"files\"/>\n"
 | 
			
		||||
"    </method>\n"
 | 
			
		||||
"    <method name=\"HandleMenuItem\">\n"
 | 
			
		||||
"      <arg direction=\"in\" type=\"u\" name=\"timestamp\"/>\n"
 | 
			
		||||
"      <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
 | 
			
		||||
"    </method>\n"
 | 
			
		||||
"    <method name=\"NewInstance\">\n"
 | 
			
		||||
"      <arg direction=\"in\" type=\"u\" name=\"timestamp\"/>\n"
 | 
			
		||||
"    </method>\n"
 | 
			
		||||
"    <method name=\"PresentWindows\"/>\n"
 | 
			
		||||
"    <method name=\"RequestDock\"/>\n"
 | 
			
		||||
"    <method name=\"RequestUndock\"/>\n"
 | 
			
		||||
"    <property access=\"read\" type=\"s\" name=\"Name\"/>\n"
 | 
			
		||||
"    <property access=\"read\" type=\"s\" name=\"Icon\"/>\n"
 | 
			
		||||
"    <property access=\"read\" type=\"s\" name=\"Id\"/>\n"
 | 
			
		||||
"    <property access=\"read\" type=\"b\" name=\"IsActive\"/>\n"
 | 
			
		||||
"    <property access=\"read\" type=\"u\" name=\"CurrentWindow\"/>\n"
 | 
			
		||||
"    <property access=\"read\" type=\"b\" name=\"IsDocked\"/>\n"
 | 
			
		||||
"    <property access=\"read\" type=\"s\" name=\"Menu\"/>\n"
 | 
			
		||||
"    <property access=\"read\" type=\"s\" name=\"DesktopFile\"/>\n"
 | 
			
		||||
"    <property access=\"read\" type=\"a(usb)\" name=\"WindowInfos\"/>\n"
 | 
			
		||||
"  </interface>\n"
 | 
			
		||||
        "")
 | 
			
		||||
                                       "  <interface name=\"org.deepin.dde.daemon.Dock1.Entry\">\n"
 | 
			
		||||
                                       "    <method name=\"Activate\">\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"u\" name=\"timestamp\"/>\n"
 | 
			
		||||
                                       "    </method>\n"
 | 
			
		||||
                                       "    <method name=\"Check\"/>\n"
 | 
			
		||||
                                       "    <method name=\"ForceQuit\"/>\n"
 | 
			
		||||
                                       "    <method name=\"GetAllowedCloseWindows\">\n"
 | 
			
		||||
                                       "      <arg direction=\"out\" type=\"au\" name=\"windows\"/>\n"
 | 
			
		||||
                                       "    </method>\n"
 | 
			
		||||
                                       "    <method name=\"HandleDragDrop\">\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"u\" name=\"timestamp\"/>\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"as\" name=\"files\"/>\n"
 | 
			
		||||
                                       "    </method>\n"
 | 
			
		||||
                                       "    <method name=\"HandleMenuItem\">\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"u\" name=\"timestamp\"/>\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
 | 
			
		||||
                                       "    </method>\n"
 | 
			
		||||
                                       "    <method name=\"NewInstance\">\n"
 | 
			
		||||
                                       "      <arg direction=\"in\" type=\"u\" name=\"timestamp\"/>\n"
 | 
			
		||||
                                       "    </method>\n"
 | 
			
		||||
                                       "    <method name=\"PresentWindows\"/>\n"
 | 
			
		||||
                                       "    <method name=\"RequestDock\"/>\n"
 | 
			
		||||
                                       "    <method name=\"RequestUndock\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"s\" name=\"Name\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"s\" name=\"Icon\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"s\" name=\"Id\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"b\" name=\"IsActive\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"u\" name=\"CurrentWindow\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"b\" name=\"IsDocked\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"s\" name=\"Menu\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"s\" name=\"DesktopFile\"/>\n"
 | 
			
		||||
                                       "    <property access=\"read\" type=\"a(usb)\" name=\"WindowInfos\"/>\n"
 | 
			
		||||
                                       "    <annotation value=\"ExportWindowInfoList\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
 | 
			
		||||
                                       "  </interface>\n"
 | 
			
		||||
                                       "")
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    DBusAdaptorEntry(QObject *parent);
 | 
			
		||||
@ -115,8 +111,8 @@ public: // PROPERTIES
 | 
			
		||||
    Q_PROPERTY(QString Name READ name NOTIFY NameChanged)
 | 
			
		||||
    QString name() const;
 | 
			
		||||
 | 
			
		||||
    //Q_PROPERTY(QString WindowInfos READ windowInfos)
 | 
			
		||||
    //QList<ExportWindowInfo> windowInfos();
 | 
			
		||||
    Q_PROPERTY(ExportWindowInfoList WindowInfos READ windowInfos NOTIFY WindowInfosChanged)
 | 
			
		||||
    ExportWindowInfoList windowInfos();
 | 
			
		||||
 | 
			
		||||
    Entry *parent() const;
 | 
			
		||||
 | 
			
		||||
@ -140,6 +136,7 @@ Q_SIGNALS: // SIGNALS
 | 
			
		||||
    void NameChanged(QString value);
 | 
			
		||||
    void DesktopFileChanged(QString value);
 | 
			
		||||
    void CurrentWindowChanged(uint32_t value);
 | 
			
		||||
    void WindowInfosChanged(ExportWindowInfoList value);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -149,7 +149,7 @@ void DBusHandler::listenKWindowSignals(WindowInfoK *windowInfo)
 | 
			
		||||
        if (entry->getCurrentWindowInfo() == windowInfo)
 | 
			
		||||
            entry->updateName();
 | 
			
		||||
 | 
			
		||||
        entry->updateWindowInfos();
 | 
			
		||||
        entry->updateExportWindowInfos();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Icon changed
 | 
			
		||||
@ -169,7 +169,7 @@ void DBusHandler::listenKWindowSignals(WindowInfoK *windowInfo)
 | 
			
		||||
        if (!entry)
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
        entry->updateWindowInfos();
 | 
			
		||||
        entry->updateExportWindowInfos();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Geometry changed
 | 
			
		||||
 | 
			
		||||
@ -1008,11 +1008,12 @@ void Dock::attachOrDetachWindow(WindowInfoBase *info)
 | 
			
		||||
    } else {
 | 
			
		||||
        // attach
 | 
			
		||||
        if (info->getEntryInnerId().isEmpty()) {
 | 
			
		||||
            // 识别窗口并创建entryInnerId
 | 
			
		||||
            // 窗口entryInnerId为空表示未识别,需要识别窗口并创建entryInnerId
 | 
			
		||||
            qInfo() << "attach operate: window " << winId << " entryInnerId is empty, now call IdentifyWindow";
 | 
			
		||||
            QString innerId;
 | 
			
		||||
            AppInfo *appInfo = windowIdentify->identifyWindow(info, innerId);
 | 
			
		||||
            info->setEntryInnerId(innerId);   // windowBaseInfo entryInnerId is AppInfo innerId, for binding window and appInfo
 | 
			
		||||
            // 窗口entryInnerId即AppInfo的innerId, 用来将窗口和应用绑定关系
 | 
			
		||||
            info->setEntryInnerId(innerId);
 | 
			
		||||
            info->setAppInfo(appInfo);
 | 
			
		||||
            markAppLaunched(appInfo);
 | 
			
		||||
        } else {
 | 
			
		||||
 | 
			
		||||
@ -33,16 +33,16 @@
 | 
			
		||||
#define XCB XCBUtils::instance()
 | 
			
		||||
 | 
			
		||||
Entry::Entry(Dock *_dock, AppInfo *_app, QString _innerId, QObject *parent)
 | 
			
		||||
 : QObject(parent)
 | 
			
		||||
 , dock(_dock)
 | 
			
		||||
 , app(nullptr)
 | 
			
		||||
 , menu(nullptr)
 | 
			
		||||
 , isActive(false)
 | 
			
		||||
 , isDocked(false)
 | 
			
		||||
 , innerId(_innerId)
 | 
			
		||||
 , current(nullptr)
 | 
			
		||||
 , currentWindow(0)
 | 
			
		||||
 , winIconPreferred(false)
 | 
			
		||||
    : QObject(parent)
 | 
			
		||||
    , dock(_dock)
 | 
			
		||||
    , app(nullptr)
 | 
			
		||||
    , menu(nullptr)
 | 
			
		||||
    , isActive(false)
 | 
			
		||||
    , isDocked(false)
 | 
			
		||||
    , innerId(_innerId)
 | 
			
		||||
    , current(nullptr)
 | 
			
		||||
    , currentWindow(0)
 | 
			
		||||
    , winIconPreferred(false)
 | 
			
		||||
{
 | 
			
		||||
    setApp(_app);
 | 
			
		||||
    id = dock->allocEntryId();
 | 
			
		||||
@ -413,26 +413,40 @@ bool Entry::hasWindow()
 | 
			
		||||
    return windowInfos.size() > 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Entry::updateWindowInfos()
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Entry::updateExportWindowInfos 同步更新导出窗口信息
 | 
			
		||||
 */
 | 
			
		||||
void Entry::updateExportWindowInfos()
 | 
			
		||||
{
 | 
			
		||||
    QList<ExportWindowInfo> infos;
 | 
			
		||||
    bool changed = false;
 | 
			
		||||
    ExportWindowInfoList infos;
 | 
			
		||||
    for (auto info : windowInfos) {
 | 
			
		||||
        XWindow xid = info->getXid();
 | 
			
		||||
        QString title = info->getTitle();
 | 
			
		||||
        bool flash = info->isDemandingAttention();
 | 
			
		||||
        infos.push_back({xid, title, flash});
 | 
			
		||||
        if (!changed) {
 | 
			
		||||
            for (auto info : exportWindowInfos) {
 | 
			
		||||
                if (info.title != title || info.flash != flash)
 | 
			
		||||
                    changed = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool changed = false;
 | 
			
		||||
    if (infos.size() == exportWindowInfos.size()) {
 | 
			
		||||
        sortExprotWindowInfoList(infos);
 | 
			
		||||
        sortExprotWindowInfoList(exportWindowInfos);
 | 
			
		||||
        for (int i = 0; i < infos.size(); i++) {
 | 
			
		||||
            if (infos[i].getXid() != exportWindowInfos[i].getXid()
 | 
			
		||||
                    || infos[i].getFlash() != exportWindowInfos[i].getFlash()
 | 
			
		||||
                    || infos[i].getTitle() != exportWindowInfos[i].getTitle()) {
 | 
			
		||||
                changed = true;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        changed = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (changed) {
 | 
			
		||||
        exportWindowInfos = infos;
 | 
			
		||||
        Q_EMIT windowInfosChanged(infos);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    exportWindowInfos = infos;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 分离窗口, 返回是否需要从任务栏remove
 | 
			
		||||
@ -456,7 +470,7 @@ bool Entry::detachWindow(WindowInfoBase *info)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    updateWindowInfos();
 | 
			
		||||
    updateExportWindowInfos();
 | 
			
		||||
    updateIcon();
 | 
			
		||||
    updateIsActive();
 | 
			
		||||
    updateMenu();
 | 
			
		||||
@ -476,7 +490,7 @@ bool Entry::attachWindow(WindowInfoBase *info)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    windowInfos[winId] = info;
 | 
			
		||||
    updateWindowInfos();
 | 
			
		||||
    updateExportWindowInfos();
 | 
			
		||||
    updateIsActive();
 | 
			
		||||
 | 
			
		||||
    if (!current) {
 | 
			
		||||
@ -504,7 +518,7 @@ void Entry::deleteWindow(XWindow xid)
 | 
			
		||||
    WindowInfoBase *info = windowInfos[xid];
 | 
			
		||||
    windowInfos.remove(xid);
 | 
			
		||||
    for (int i = 0; i < exportWindowInfos.size(); i++) {
 | 
			
		||||
        if (exportWindowInfos[i].xid == xid) {
 | 
			
		||||
        if (exportWindowInfos[i].getXid() == xid) {
 | 
			
		||||
            exportWindowInfos.removeAt(i);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
@ -693,7 +707,7 @@ QVector<XWindow> Entry::getAllowedClosedWindowIds()
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QList<ExportWindowInfo> Entry::getExportWindowInfos()
 | 
			
		||||
ExportWindowInfoList Entry::getExportWindowInfos()
 | 
			
		||||
{
 | 
			
		||||
    return exportWindowInfos;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -25,17 +25,12 @@
 | 
			
		||||
#include "appinfo.h"
 | 
			
		||||
#include "appmenu.h"
 | 
			
		||||
#include "windowinfobase.h"
 | 
			
		||||
#include "exportwindowinfolist.h"
 | 
			
		||||
 | 
			
		||||
#include <QMap>
 | 
			
		||||
#include <QVector>
 | 
			
		||||
#include <QObject>
 | 
			
		||||
 | 
			
		||||
struct ExportWindowInfo {
 | 
			
		||||
    XWindow xid;
 | 
			
		||||
    QString title;
 | 
			
		||||
    bool flash;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// 单个应用类
 | 
			
		||||
class Dock;
 | 
			
		||||
class Entry: public QObject
 | 
			
		||||
@ -76,7 +71,7 @@ public:
 | 
			
		||||
    WindowInfoBase *findNextLeader();
 | 
			
		||||
    QString getExec(bool oneLine);
 | 
			
		||||
    bool hasWindow();
 | 
			
		||||
    void updateWindowInfos();
 | 
			
		||||
    void updateExportWindowInfos();
 | 
			
		||||
    bool detachWindow(WindowInfoBase *info);
 | 
			
		||||
    bool attachWindow(WindowInfoBase *info);
 | 
			
		||||
    void launchApp(uint32_t timestamp);
 | 
			
		||||
@ -98,7 +93,7 @@ public:
 | 
			
		||||
    bool getIsActive();
 | 
			
		||||
    QString getMenu();
 | 
			
		||||
    QVector<XWindow> getAllowedClosedWindowIds();
 | 
			
		||||
    QList<ExportWindowInfo> getExportWindowInfos();
 | 
			
		||||
    ExportWindowInfoList getExportWindowInfos();
 | 
			
		||||
 | 
			
		||||
public Q_SLOTS:
 | 
			
		||||
    QVector<WindowInfoBase *> getAllowedCloseWindows();
 | 
			
		||||
@ -111,6 +106,7 @@ Q_SIGNALS:
 | 
			
		||||
    void nameChanged(QString value);
 | 
			
		||||
    void desktopFileChanged(QString value);
 | 
			
		||||
    void currentWindowChanged(uint32_t value);
 | 
			
		||||
    void windowInfosChanged(const ExportWindowInfoList &value);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    // 右键菜单项
 | 
			
		||||
@ -140,7 +136,7 @@ private:
 | 
			
		||||
 | 
			
		||||
    // Dbus属性直接放到interface上
 | 
			
		||||
    QMap<XWindow, WindowInfoBase *> windowInfos; // 该应用所有窗口
 | 
			
		||||
    QList<ExportWindowInfo> exportWindowInfos;
 | 
			
		||||
    ExportWindowInfoList exportWindowInfos;
 | 
			
		||||
    WindowInfoBase *current; // 当前窗口
 | 
			
		||||
    XWindow currentWindow; //当前窗口Id
 | 
			
		||||
    bool winIconPreferred;
 | 
			
		||||
 | 
			
		||||
@ -118,6 +118,10 @@ AppInfo *WindowIdentify::identifyWindow(WindowInfoBase *winInfo, QString &innerI
 | 
			
		||||
AppInfo *WindowIdentify::identifyWindowX11(WindowInfoX *winInfo, QString &innerId)
 | 
			
		||||
{
 | 
			
		||||
    AppInfo *appInfo = nullptr;
 | 
			
		||||
    if (winInfo->getInnerId().isEmpty()) {
 | 
			
		||||
        qInfo() << "identifyWindowX11: window innerId is empty";
 | 
			
		||||
        return appInfo;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (auto iter = identifyWindowFuns.begin(); iter != identifyWindowFuns.end(); iter++) {
 | 
			
		||||
        QString name = iter.key();
 | 
			
		||||
 | 
			
		||||
@ -245,6 +245,11 @@ void WindowInfoX::updateHasXEmbedInfo()
 | 
			
		||||
    hasXEmbedInfo = XCB->hasXEmbedInfo(xid);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief WindowInfoX::genInnerId 生成innerId
 | 
			
		||||
 * @param winInfo
 | 
			
		||||
 * @return
 | 
			
		||||
 */
 | 
			
		||||
QString WindowInfoX::genInnerId(WindowInfoX *winInfo)
 | 
			
		||||
{
 | 
			
		||||
    XWindow winId = winInfo->getXid();
 | 
			
		||||
 | 
			
		||||
@ -93,9 +93,16 @@ WindowPatterns::WindowPatterns()
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief WindowPatterns::match 匹配窗口
 | 
			
		||||
 * @param winInfo
 | 
			
		||||
 * @return
 | 
			
		||||
 */
 | 
			
		||||
QString WindowPatterns::match(WindowInfoX *winInfo)
 | 
			
		||||
{
 | 
			
		||||
    for (auto pattern : patterns) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    return "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -47,7 +47,7 @@ class WindowPatterns
 | 
			
		||||
    struct WindowPattern {
 | 
			
		||||
        QVector<QVector<QString>> rules;    // rules
 | 
			
		||||
        QString result;                     // ret
 | 
			
		||||
        QVector< RuleValueParse> parseRules;
 | 
			
		||||
        QVector<RuleValueParse> parseRules;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
@ -369,7 +369,7 @@ void X11Manager::handlePropertyNotifyEvent(XWindow xid, XCBAtom atom)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if (atom == XCB->getAtom("_NET_WM_STATE")) {
 | 
			
		||||
        entry->updateWindowInfos();
 | 
			
		||||
        entry->updateExportWindowInfos();
 | 
			
		||||
    } else if (atom == XCB->getAtom("_NET_WM_ICON")) {
 | 
			
		||||
        if (entry->getCurrentWindowInfo() == winInfo) {
 | 
			
		||||
            entry->updateIcon();
 | 
			
		||||
@ -378,7 +378,7 @@ void X11Manager::handlePropertyNotifyEvent(XWindow xid, XCBAtom atom)
 | 
			
		||||
        if (entry->getCurrentWindowInfo() == winInfo) {
 | 
			
		||||
            entry->updateName();
 | 
			
		||||
        }
 | 
			
		||||
        entry->updateWindowInfos();
 | 
			
		||||
        entry->updateExportWindowInfos();
 | 
			
		||||
    } else if (atom == XCB->getAtom("_NET_WM_ALLOWED_ACTIONS")) {
 | 
			
		||||
        entry->updateMenu();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user