style: 修改成员变量命名
类成员变量前统一增加m_标记 log: 代码格式化 Influence: 无 Task: https://pms.uniontech.com/task-view-96831.html Change-Id: I2432dd5667bc195da1a64cdbb7cd933052ba7baa
This commit is contained in:
@ -312,8 +312,7 @@ int main(int argc, char* argv[])
|
||||
qWarning() << "error app prefix:" << QString::fromStdString(app.prefix);
|
||||
}
|
||||
|
||||
if(pid != -1)
|
||||
{
|
||||
if(pid != -1) {
|
||||
Methods::ProcessStatus processSuccess;
|
||||
processSuccess.code = 0;
|
||||
processSuccess.id = task.id;
|
||||
|
@ -27,13 +27,13 @@
|
||||
#include <QCryptographicHash>
|
||||
|
||||
AppInfo::AppInfo(DesktopInfo &info)
|
||||
: isValid(true)
|
||||
: m_isValid(true)
|
||||
{
|
||||
init(info);
|
||||
}
|
||||
|
||||
AppInfo::AppInfo(const QString &_fileName)
|
||||
: isValid(true)
|
||||
: m_isValid(true)
|
||||
{
|
||||
DesktopInfo info(_fileName.toStdString());
|
||||
init(info);
|
||||
@ -42,26 +42,26 @@ AppInfo::AppInfo(const QString &_fileName)
|
||||
void AppInfo::init(DesktopInfo &info)
|
||||
{
|
||||
if (!info.isValidDesktop()) {
|
||||
isValid = false;
|
||||
m_isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string xDeepinVendor= info.getKeyFile()->getStr(MainSection, "X-Deepin-Vendor");
|
||||
if (xDeepinVendor == "deepin") {
|
||||
name = info.getGenericName().c_str();
|
||||
if (name.isEmpty())
|
||||
name = info.getName().c_str();
|
||||
m_name = info.getGenericName().c_str();
|
||||
if (m_name.isEmpty())
|
||||
m_name = info.getName().c_str();
|
||||
} else {
|
||||
name = info.getName().c_str();
|
||||
m_name = info.getName().c_str();
|
||||
}
|
||||
|
||||
innerId = genInnerIdWithDesktopInfo(info);
|
||||
fileName = info.getFileName().c_str();
|
||||
id = info.getId().c_str();
|
||||
icon = info.getIcon().c_str();
|
||||
installed = info.isInstalled();
|
||||
m_innerId = genInnerIdWithDesktopInfo(info);
|
||||
m_fileName = info.getFileName().c_str();
|
||||
m_id = info.getId().c_str();
|
||||
m_icon = info.getIcon().c_str();
|
||||
m_installed = info.isInstalled();
|
||||
for (const auto & action : info.getActions()) {
|
||||
actions.push_back(action);
|
||||
m_actions.push_back(action);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,29 +34,29 @@ public:
|
||||
explicit AppInfo(const QString &_fileName);
|
||||
|
||||
void init(DesktopInfo &info);
|
||||
QString getFileName() {return fileName;}
|
||||
QString getIcon() {return icon;}
|
||||
QString getId() {return id;}
|
||||
QString getInnerId() {return innerId;}
|
||||
QString getName() {return name;}
|
||||
QVector<DesktopAction> getActions() {return actions;}
|
||||
QString getIdentifyMethod() {return identifyMethod;}
|
||||
void setIdentifyMethod(QString method) {identifyMethod = method;}
|
||||
bool isInstalled() {return installed;}
|
||||
bool isValidApp() {return isValid;}
|
||||
QString getFileName() {return m_fileName;}
|
||||
QString getIcon() {return m_icon;}
|
||||
QString getId() {return m_id;}
|
||||
QString getInnerId() {return m_innerId;}
|
||||
QString getName() {return m_name;}
|
||||
QVector<DesktopAction> getActions() {return m_actions;}
|
||||
QString getIdentifyMethod() {return m_identifyMethod;}
|
||||
void setIdentifyMethod(QString method) {m_identifyMethod = method;}
|
||||
bool isInstalled() {return m_installed;}
|
||||
bool isValidApp() {return m_isValid;}
|
||||
|
||||
private:
|
||||
QString genInnerIdWithDesktopInfo(DesktopInfo &info);
|
||||
|
||||
QString fileName;
|
||||
QString id;
|
||||
QString icon;
|
||||
QString identifyMethod;
|
||||
QString innerId;
|
||||
QString name;
|
||||
QVector<DesktopAction> actions;
|
||||
bool installed;
|
||||
bool isValid;
|
||||
QString m_fileName;
|
||||
QString m_id;
|
||||
QString m_icon;
|
||||
QString m_identifyMethod;
|
||||
QString m_innerId;
|
||||
QString m_name;
|
||||
QVector<DesktopAction> m_actions;
|
||||
bool m_installed;
|
||||
bool m_isValid;
|
||||
};
|
||||
|
||||
#endif // APPINFO_H
|
||||
|
@ -25,10 +25,10 @@
|
||||
#include <QJsonDocument>
|
||||
|
||||
AppMenu::AppMenu()
|
||||
: checkableMenu(false)
|
||||
, singleCheck(false)
|
||||
, itemcount(0)
|
||||
, dirty(false)
|
||||
: m_checkableMenu(false)
|
||||
, m_singleCheck(false)
|
||||
, m_itemCount(0)
|
||||
, m_dirty(false)
|
||||
{
|
||||
|
||||
}
|
||||
@ -41,7 +41,7 @@ void AppMenu::appendItem(AppMenuItem item)
|
||||
{
|
||||
if (!item.text.isEmpty()) {
|
||||
item.id = allocateId();
|
||||
items.push_back(item);
|
||||
m_items.push_back(item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ void AppMenu::appendItem(AppMenuItem item)
|
||||
*/
|
||||
void AppMenu::handleAction(uint32_t timestamp, QString itemId)
|
||||
{
|
||||
for (auto &item : items) {
|
||||
for (auto &item : m_items) {
|
||||
if (item.id == itemId) {
|
||||
item.action(timestamp);
|
||||
break;
|
||||
@ -62,14 +62,14 @@ void AppMenu::handleAction(uint32_t timestamp, QString itemId)
|
||||
|
||||
void AppMenu::setDirtyStatus(bool isDirty)
|
||||
{
|
||||
dirty = isDirty;
|
||||
m_dirty = isDirty;
|
||||
}
|
||||
|
||||
QString AppMenu::getMenuJsonStr()
|
||||
{
|
||||
QJsonObject obj;
|
||||
QJsonArray array;
|
||||
for (auto item : items) {
|
||||
for (auto item : m_items) {
|
||||
QJsonObject objItem;
|
||||
objItem["itemId"] = item.id;
|
||||
objItem["itemText"] = item.text;
|
||||
@ -84,8 +84,8 @@ QString AppMenu::getMenuJsonStr()
|
||||
array.push_back(objItem);
|
||||
}
|
||||
obj["items"] = QJsonValue(array);
|
||||
obj["checkableMenu"] = checkableMenu;
|
||||
obj["singleCheck"] = singleCheck;
|
||||
obj["checkableMenu"] = m_checkableMenu;
|
||||
obj["singleCheck"] = m_singleCheck;
|
||||
|
||||
QString ret = QJsonDocument(obj).toJson();
|
||||
return ret;
|
||||
@ -93,7 +93,5 @@ QString AppMenu::getMenuJsonStr()
|
||||
|
||||
QString AppMenu::allocateId()
|
||||
{
|
||||
return QString::number(itemcount++);
|
||||
return QString::number(m_itemCount++);
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,7 +58,6 @@ struct AppMenuItem
|
||||
AppMenuAction action;
|
||||
};
|
||||
|
||||
|
||||
// 应用菜单类
|
||||
class AppMenu
|
||||
{
|
||||
@ -73,12 +72,13 @@ public:
|
||||
private:
|
||||
QString allocateId();
|
||||
|
||||
QVector<AppMenuItem> items; // json:"items"
|
||||
bool checkableMenu; // json:"checkableMenu"
|
||||
bool singleCheck; // json:"singleCheck"
|
||||
private:
|
||||
QVector<AppMenuItem> m_items; // json:"items"
|
||||
bool m_checkableMenu; // json:"checkableMenu"
|
||||
bool m_singleCheck; // json:"singleCheck"
|
||||
|
||||
int itemcount;
|
||||
bool dirty;
|
||||
int m_itemCount;
|
||||
bool m_dirty;
|
||||
};
|
||||
|
||||
#endif // APPMENU_H
|
||||
|
@ -26,71 +26,71 @@
|
||||
|
||||
DBusHandler::DBusHandler(Dock *_dock, QObject *parent)
|
||||
: QObject(parent)
|
||||
, dock(_dock)
|
||||
, session(QDBusConnection::sessionBus())
|
||||
, launcherEnd(new LauncherBackEnd("org.deepin.dde.daemon.Launcher1", "/org/deepin/dde/daemon/Launcher1", session, this))
|
||||
, launcherFront(new LauncherFront("org.deepin.dde.Launcher1", "/org/deepin/dde/Launcher1", session, this))
|
||||
, wm(new com::deepin::WM("com.deepin.wm", "/com/deepin/wm", session, this))
|
||||
, wmSwitcher(new com::deepin::WMSwitcher("com.deepin.wmWMSwitcher", "/com/deepin/WMSwitcher", session, this))
|
||||
, kwaylandManager(nullptr)
|
||||
, m_dock(_dock)
|
||||
, m_session(QDBusConnection::sessionBus())
|
||||
, m_launcherEnd(new LauncherBackEnd("org.deepin.dde.daemon.Launcher1", "/org/deepin/dde/daemon/Launcher1", m_session, this))
|
||||
, m_launcherFront(new LauncherFront("org.deepin.dde.Launcher1", "/org/deepin/dde/Launcher1", m_session, this))
|
||||
, m_wm(new com::deepin::WM("com.deepin.wm", "/com/deepin/wm", m_session, this))
|
||||
, m_wmSwitcher(new com::deepin::WMSwitcher("com.deepin.wmWMSwitcher", "/com/deepin/WMSwitcher", m_session, this))
|
||||
, m_kwaylandManager(nullptr)
|
||||
{
|
||||
// 关联org.deepin.dde.daemon.Launcher1事件 ItemChanged
|
||||
connect(launcherEnd, &LauncherBackEnd::ItemChanged, this, &DBusHandler::handleLauncherItemChanged);
|
||||
connect(m_launcherEnd, &LauncherBackEnd::ItemChanged, this, &DBusHandler::handleLauncherItemChanged);
|
||||
|
||||
// 关联org.deepin.dde.Launcher1事件 VisibleChanged
|
||||
connect(launcherFront, &LauncherFront::VisibleChanged, this, [&](bool visible) {
|
||||
dock->setDdeLauncherVisible(visible);
|
||||
dock->updateHideState(false);
|
||||
connect(m_launcherFront, &LauncherFront::VisibleChanged, this, [&](bool visible) {
|
||||
m_dock->setDdeLauncherVisible(visible);
|
||||
m_dock->updateHideState(false);
|
||||
});
|
||||
|
||||
// 关联com.deepin.WMSwitcher事件 WMChanged
|
||||
connect(wmSwitcher, &__WMSwitcher::WMChanged, this, [&](QString name) {dock->setWMName(name);});
|
||||
connect(m_wmSwitcher, &__WMSwitcher::WMChanged, this, [&](QString name) {m_dock->setWMName(name);});
|
||||
}
|
||||
|
||||
// 关联com.deepin.daemon.KWayland.WindowManager事件
|
||||
void DBusHandler::listenWaylandWMSignals()
|
||||
{
|
||||
kwaylandManager = new com::deepin::daemon::kwayland::WindowManager("com.deepin.daemon.KWayland", "/com/deepin/daemon/KWayland/WindowManager", session, this);
|
||||
m_kwaylandManager = new com::deepin::daemon::kwayland::WindowManager("com.deepin.daemon.KWayland", "/com/deepin/daemon/KWayland/WindowManager", m_session, this);
|
||||
|
||||
// ActiveWindowchanged
|
||||
connect(kwaylandManager, &__KwaylandManager::ActiveWindowChanged, this, &DBusHandler::handleWlActiveWindowChange);
|
||||
connect(m_kwaylandManager, &__KwaylandManager::ActiveWindowChanged, this, &DBusHandler::handleWlActiveWindowChange);
|
||||
// WindowCreated
|
||||
connect(kwaylandManager, &__KwaylandManager::WindowCreated, this, [&] (const QString &ObjPath) {
|
||||
dock->registerWindowWayland(ObjPath);
|
||||
connect(m_kwaylandManager, &__KwaylandManager::WindowCreated, this, [&] (const QString &ObjPath) {
|
||||
m_dock->registerWindowWayland(ObjPath);
|
||||
});
|
||||
// WindowRemove
|
||||
connect(kwaylandManager, &__KwaylandManager::WindowRemove, this, [&] (const QString &ObjPath) {
|
||||
dock->unRegisterWindowWayland(ObjPath);
|
||||
connect(m_kwaylandManager, &__KwaylandManager::WindowRemove, this, [&] (const QString &ObjPath) {
|
||||
m_dock->unRegisterWindowWayland(ObjPath);
|
||||
});
|
||||
}
|
||||
|
||||
void DBusHandler::loadClientList()
|
||||
{
|
||||
if (!kwaylandManager)
|
||||
if (!m_kwaylandManager)
|
||||
return;
|
||||
|
||||
// 加载已存在的窗口
|
||||
QDBusPendingReply<QVariantList> windowList = kwaylandManager->Windows();
|
||||
QDBusPendingReply<QVariantList> windowList = m_kwaylandManager->Windows();
|
||||
QVariantList windows = windowList.value();
|
||||
for (QVariant windowPath : windows)
|
||||
dock->registerWindowWayland(windowPath.toString());
|
||||
m_dock->registerWindowWayland(windowPath.toString());
|
||||
}
|
||||
|
||||
void DBusHandler::handleLauncherItemChanged(const QString &status, LauncherItemInfo itemInfo, qlonglong categoryID)
|
||||
{
|
||||
qInfo() << "handleLauncherItemChanged status:" << status << " Name:" << itemInfo.name << " ID:" << itemInfo.id;
|
||||
if (status == "deleted") {
|
||||
dock->handleLauncherItemDeleted(itemInfo.path);
|
||||
m_dock->handleLauncherItemDeleted(itemInfo.path);
|
||||
} else if (status == "created") {
|
||||
// don't need to download to dock when app reinstall
|
||||
} else if (status == "updated") {
|
||||
dock->handleLauncherItemUpdated(itemInfo.path);
|
||||
m_dock->handleLauncherItemUpdated(itemInfo.path);
|
||||
}
|
||||
}
|
||||
|
||||
QString DBusHandler::getCurrentWM()
|
||||
{
|
||||
return wmSwitcher->CurrentWM().value();
|
||||
return m_wmSwitcher->CurrentWM().value();
|
||||
}
|
||||
|
||||
// TODO 扩展ApplicationManager Launch接口,允许带参数启动应用,暂时调用StartManager接口
|
||||
@ -115,8 +115,8 @@ void DBusHandler::markAppLaunched(const QString &filePath)
|
||||
bool DBusHandler::wlShowingDesktop()
|
||||
{
|
||||
bool ret = false;
|
||||
if (kwaylandManager)
|
||||
ret = kwaylandManager->IsShowingDesktop().value();
|
||||
if (m_kwaylandManager)
|
||||
ret = m_kwaylandManager->IsShowingDesktop().value();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -124,8 +124,8 @@ bool DBusHandler::wlShowingDesktop()
|
||||
uint DBusHandler::wlActiveWindow()
|
||||
{
|
||||
uint ret = 0;
|
||||
if (kwaylandManager)
|
||||
ret = kwaylandManager->ActiveWindow().value();
|
||||
if (m_kwaylandManager)
|
||||
ret = m_kwaylandManager->ActiveWindow().value();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -136,14 +136,14 @@ void DBusHandler::handleWlActiveWindowChange()
|
||||
if (activeWinInternalId == 0)
|
||||
return;
|
||||
|
||||
WindowInfoK *info = dock->handleActiveWindowChangedK(activeWinInternalId);
|
||||
WindowInfoK *info = m_dock->handleActiveWindowChangedK(activeWinInternalId);
|
||||
if (info && info->getXid() != 0) {
|
||||
WindowInfoBase *base = static_cast<WindowInfoBase *>(info);
|
||||
if (base) {
|
||||
dock->handleActiveWindowChanged(base);
|
||||
m_dock->handleActiveWindowChanged(base);
|
||||
}
|
||||
} else {
|
||||
dock->updateHideState(false);
|
||||
m_dock->updateHideState(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ void DBusHandler::listenKWindowSignals(WindowInfoK *windowInfo)
|
||||
// Title changed
|
||||
connect(window, &PlasmaWindow::TitleChanged, this, [=] {
|
||||
windowInfo->updateTitle();
|
||||
auto entry = dock->getEntryByWindowId(windowInfo->getXid());
|
||||
auto entry = m_dock->getEntryByWindowId(windowInfo->getXid());
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
@ -169,7 +169,7 @@ void DBusHandler::listenKWindowSignals(WindowInfoK *windowInfo)
|
||||
// Icon changed
|
||||
connect(window, &PlasmaWindow::IconChanged, this, [=] {
|
||||
windowInfo->updateIcon();
|
||||
auto entry = dock->getEntryByWindowId(windowInfo->getXid());
|
||||
auto entry = m_dock->getEntryByWindowId(windowInfo->getXid());
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
@ -179,7 +179,7 @@ void DBusHandler::listenKWindowSignals(WindowInfoK *windowInfo)
|
||||
// DemandingAttention changed
|
||||
connect(window, &PlasmaWindow::DemandsAttentionChanged, this, [=] {
|
||||
windowInfo->updateDemandingAttention();
|
||||
auto entry = dock->getEntryByWindowId(windowInfo->getXid());
|
||||
auto entry = m_dock->getEntryByWindowId(windowInfo->getXid());
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
@ -191,13 +191,13 @@ void DBusHandler::listenKWindowSignals(WindowInfoK *windowInfo)
|
||||
if (!windowInfo->updateGeometry())
|
||||
return;
|
||||
|
||||
dock->handleWindowGeometryChanged();
|
||||
m_dock->handleWindowGeometryChanged();
|
||||
});
|
||||
}
|
||||
|
||||
PlasmaWindow *DBusHandler::createPlasmaWindow(QString objPath)
|
||||
{
|
||||
return new PlasmaWindow("com.deepin.daemon.KWayland", objPath, session, this);
|
||||
return new PlasmaWindow("com.deepin.daemon.KWayland", objPath, m_session, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,7 +211,7 @@ void DBusHandler::removePlasmaWindowHandler(PlasmaWindow *window)
|
||||
|
||||
void DBusHandler::presentWindows(QList<uint> windows)
|
||||
{
|
||||
wm->PresentWindows(windows);
|
||||
m_wm->PresentWindows(windows);
|
||||
}
|
||||
|
||||
// TODO: 待优化点, 查看Bamf根据windowId获取对应应用desktopFile路径实现方式, 移除bamf依赖
|
||||
|
@ -78,14 +78,14 @@ private Q_SLOTS:
|
||||
void handleWlActiveWindowChange();
|
||||
|
||||
private:
|
||||
Dock *dock;
|
||||
QDBusConnection session;
|
||||
Dock *m_dock;
|
||||
QDBusConnection m_session;
|
||||
|
||||
LauncherBackEnd *launcherEnd;
|
||||
LauncherFront *launcherFront;
|
||||
com::deepin::WM *wm;
|
||||
com::deepin::WMSwitcher *wmSwitcher;
|
||||
com::deepin::daemon::kwayland::WindowManager *kwaylandManager;
|
||||
LauncherBackEnd *m_launcherEnd;
|
||||
LauncherFront *m_launcherFront;
|
||||
com::deepin::WM *m_wm;
|
||||
com::deepin::WMSwitcher *m_wmSwitcher;
|
||||
com::deepin::daemon::kwayland::WindowManager *m_kwaylandManager;
|
||||
};
|
||||
|
||||
#endif // DBUSHANDLER_H
|
||||
|
@ -28,21 +28,21 @@
|
||||
|
||||
DockManager::DockManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
, dock(new Dock(this))
|
||||
, m_dock(new Dock(this))
|
||||
{
|
||||
qInfo() << "DockManager";
|
||||
adaptor = new DBusAdaptorDock(dock);
|
||||
m_adaptor = new DBusAdaptorDock(m_dock);
|
||||
QDBusConnection con = QDBusConnection::sessionBus();
|
||||
if (!con.registerService(dbusService)) {
|
||||
qWarning() << "register service Dock1 error:" << con.lastError().message();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!con.registerObject(dbusPath, dock, QDBusConnection::ExportAdaptors)) {
|
||||
if (!con.registerObject(dbusPath, m_dock, QDBusConnection::ExportAdaptors)) {
|
||||
qWarning() << "register object Dock1 error:" << con.lastError().message();
|
||||
}
|
||||
|
||||
dock->serviceRestarted();
|
||||
m_dock->serviceRestarted();
|
||||
}
|
||||
|
||||
DockManager::~DockManager()
|
||||
|
@ -36,13 +36,9 @@ public:
|
||||
explicit DockManager(QObject *parent = nullptr);
|
||||
~DockManager();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
private:
|
||||
Dock *dock;
|
||||
DBusAdaptorDock *adaptor;
|
||||
Dock *m_dock;
|
||||
DBusAdaptorDock *m_adaptor;
|
||||
};
|
||||
|
||||
#endif // DOCKMANAGER_H
|
||||
|
@ -34,21 +34,21 @@
|
||||
|
||||
Entry::Entry(Dock *_dock, AppInfo *_app, QString _innerId, QObject *parent)
|
||||
: QObject(parent)
|
||||
, dock(_dock)
|
||||
, app(nullptr)
|
||||
, menu(nullptr)
|
||||
, isActive(false)
|
||||
, isDocked(false)
|
||||
, innerId(_innerId)
|
||||
, m_dock(_dock)
|
||||
, m_app(nullptr)
|
||||
, m_menu(nullptr)
|
||||
, m_isActive(false)
|
||||
, m_isDocked(false)
|
||||
, m_innerId(_innerId)
|
||||
, m_current(nullptr)
|
||||
, m_currentWindow(0)
|
||||
, m_winIconPreferred(false)
|
||||
, m_mode(getCurrentMode())
|
||||
{
|
||||
setApp(_app);
|
||||
id = dock->allocEntryId();
|
||||
name = getName();
|
||||
icon = getIcon();
|
||||
m_id = m_dock->allocEntryId();
|
||||
m_name = getName();
|
||||
m_icon = getIcon();
|
||||
}
|
||||
|
||||
Entry::~Entry()
|
||||
@ -59,25 +59,25 @@ Entry::~Entry()
|
||||
}
|
||||
m_windowInfoMap.clear();
|
||||
|
||||
if (app) {
|
||||
delete app;
|
||||
app = nullptr;
|
||||
if (m_app) {
|
||||
delete m_app;
|
||||
m_app = nullptr;
|
||||
}
|
||||
|
||||
if (menu) {
|
||||
delete menu;
|
||||
menu = nullptr;
|
||||
if (m_menu) {
|
||||
delete m_menu;
|
||||
m_menu = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Entry::isValid()
|
||||
{
|
||||
return app ? app->isValidApp() : false;
|
||||
return m_app ? m_app->isValidApp() : false;
|
||||
}
|
||||
|
||||
QString Entry::getId() const
|
||||
{
|
||||
return id;
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QString Entry::path() const
|
||||
@ -88,8 +88,8 @@ QString Entry::path() const
|
||||
QString Entry::getName()
|
||||
{
|
||||
QString ret;
|
||||
if (app) {
|
||||
ret = app->getName();
|
||||
if (m_app) {
|
||||
ret = m_app->getName();
|
||||
}
|
||||
|
||||
if (ret.isEmpty() && m_current) {
|
||||
@ -121,19 +121,19 @@ QString Entry::getIcon()
|
||||
}
|
||||
}
|
||||
|
||||
if (app) {
|
||||
icon = app->getIcon();
|
||||
if (icon.size() > 0) {
|
||||
return icon;
|
||||
if (m_app) {
|
||||
m_icon = m_app->getIcon();
|
||||
if (m_icon.size() > 0) {
|
||||
return m_icon;
|
||||
}
|
||||
}
|
||||
|
||||
return m_current->getIcon();
|
||||
}
|
||||
|
||||
if (app) {
|
||||
if (m_app) {
|
||||
// no window
|
||||
return app->getIcon();
|
||||
return m_app->getIcon();
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -141,43 +141,43 @@ QString Entry::getIcon()
|
||||
|
||||
QString Entry::getInnerId()
|
||||
{
|
||||
return innerId;
|
||||
return m_innerId;
|
||||
}
|
||||
|
||||
void Entry::setInnerId(QString _innerId)
|
||||
{
|
||||
innerId = _innerId;
|
||||
m_innerId = _innerId;
|
||||
}
|
||||
|
||||
QString Entry::getFileName()
|
||||
{
|
||||
return app ? app->getFileName() : QString();
|
||||
return m_app ? m_app->getFileName() : QString();
|
||||
}
|
||||
|
||||
AppInfo *Entry::getApp()
|
||||
{
|
||||
return app;
|
||||
return m_app;
|
||||
}
|
||||
|
||||
void Entry::setApp(AppInfo *appinfo)
|
||||
{
|
||||
if (app == appinfo) {
|
||||
if (m_app == appinfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (app) {
|
||||
delete app;
|
||||
if (m_app) {
|
||||
delete m_app;
|
||||
}
|
||||
|
||||
app = appinfo;
|
||||
m_app = appinfo;
|
||||
if (!appinfo) {
|
||||
m_winIconPreferred = true;
|
||||
setPropDesktopFile("");
|
||||
} else {
|
||||
m_winIconPreferred = false;
|
||||
setPropDesktopFile(appinfo->getFileName());
|
||||
QString id = app->getId();
|
||||
auto perferredApps = dock->getWinIconPreferredApps();
|
||||
QString id = m_app->getId();
|
||||
auto perferredApps = m_dock->getWinIconPreferredApps();
|
||||
if (perferredApps.contains(id)) {
|
||||
m_winIconPreferred = true;
|
||||
return;
|
||||
@ -191,13 +191,13 @@ void Entry::setApp(AppInfo *appinfo)
|
||||
|
||||
bool Entry::getIsDocked() const
|
||||
{
|
||||
return isDocked;
|
||||
return m_isDocked;
|
||||
}
|
||||
|
||||
void Entry::setIsDocked(bool value)
|
||||
{
|
||||
if (value != isDocked) {
|
||||
isDocked = value;
|
||||
if (value != m_isDocked) {
|
||||
m_isDocked = value;
|
||||
Q_EMIT isDockedChanged(value);
|
||||
}
|
||||
}
|
||||
@ -237,11 +237,11 @@ void Entry::stopExport()
|
||||
void Entry::setMenu(AppMenu *_menu)
|
||||
{
|
||||
_menu->setDirtyStatus(true);
|
||||
if (menu)
|
||||
delete menu;
|
||||
if (m_menu)
|
||||
delete m_menu;
|
||||
|
||||
menu = _menu;
|
||||
Q_EMIT menuChanged(menu->getMenuJsonStr());
|
||||
m_menu = _menu;
|
||||
Q_EMIT menuChanged(m_menu->getMenuJsonStr());
|
||||
}
|
||||
|
||||
void Entry::updateMenu()
|
||||
@ -257,15 +257,15 @@ void Entry::updateMenu()
|
||||
appMenu->appendItem(getMenuItemAllWindows());
|
||||
|
||||
// menu item dock or undock
|
||||
qInfo() << "entry " << id << " docked? " << isDocked;
|
||||
if (isDocked)
|
||||
qInfo() << "entry " << m_id << " docked? " << m_isDocked;
|
||||
if (m_isDocked)
|
||||
appMenu->appendItem(getMenuItemUndock());
|
||||
else
|
||||
appMenu->appendItem(getMenuItemDock());
|
||||
|
||||
if (hasWindow()) {
|
||||
if (dock->getForceQuitAppStatus() != ForceQuitAppMode::Disabled) {
|
||||
if (app && app->getIdentifyMethod() == "Andriod")
|
||||
if (m_dock->getForceQuitAppStatus() != ForceQuitAppMode::Disabled) {
|
||||
if (m_app && m_app->getIdentifyMethod() == "Andriod")
|
||||
appMenu->appendItem(getMenuItemForceQuitAndroid());
|
||||
else
|
||||
appMenu->appendItem(getMenuItemForceQuit());
|
||||
@ -290,13 +290,13 @@ int Entry::getCurrentMode()
|
||||
return ENTRY_NORMAL;
|
||||
|
||||
// 对于未驻留的应用则做如下处理
|
||||
if (static_cast<DisplayMode>(dock->getDisplayMode()) == DisplayMode::Efficient) {
|
||||
if (static_cast<DisplayMode>(m_dock->getDisplayMode()) == DisplayMode::Efficient) {
|
||||
// 高效模式下,只有存在子窗口的,则让其为nornal,没有子窗口的,一般不让其显示
|
||||
return hasWindow() ? ENTRY_NORMAL : ENTRY_NONE;
|
||||
}
|
||||
// 时尚模式下对未驻留应用做如下处理
|
||||
// 如果开启了最近打开应用的功能,则显示到最近打开区域(ENTRY_RECENT)
|
||||
if (dock->showRecent())
|
||||
if (m_dock->showRecent())
|
||||
return ENTRY_RECENT;
|
||||
|
||||
// 未开启最近使用应用的功能,如果有子窗口,则显示成通用的(ENTRY_NORMAL),如果没有子窗口,则不显示(ENTRY_NONE)
|
||||
@ -314,14 +314,14 @@ void Entry::updateMode()
|
||||
|
||||
void Entry::forceUpdateIcon()
|
||||
{
|
||||
icon = getIcon();
|
||||
Q_EMIT iconChanged(icon);
|
||||
m_icon = getIcon();
|
||||
Q_EMIT iconChanged(m_icon);
|
||||
}
|
||||
|
||||
void Entry::updateIsActive()
|
||||
{
|
||||
bool isActive = false;
|
||||
auto activeWin = dock->getActiveWindow();
|
||||
auto activeWin = m_dock->getActiveWindow();
|
||||
if (activeWin) {
|
||||
// 判断活跃窗口是否属于当前应用
|
||||
isActive = m_windowInfoMap.find(activeWin->getXid()) != m_windowInfoMap.end();
|
||||
@ -350,32 +350,32 @@ WindowInfoBase *Entry::getWindowInfoByWinId(XWindow windowId)
|
||||
|
||||
void Entry::setPropIsDocked(bool docked)
|
||||
{
|
||||
if (isDocked != docked) {
|
||||
isDocked = docked;
|
||||
if (m_isDocked != docked) {
|
||||
m_isDocked = docked;
|
||||
Q_EMIT isDockedChanged(docked);
|
||||
}
|
||||
}
|
||||
|
||||
void Entry::setPropIcon(QString value)
|
||||
{
|
||||
if (value != icon) {
|
||||
icon = value;
|
||||
if (value != m_icon) {
|
||||
m_icon = value;
|
||||
Q_EMIT iconChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
void Entry::setPropName(QString value)
|
||||
{
|
||||
if (value != name) {
|
||||
name = value;
|
||||
if (value != m_name) {
|
||||
m_name = value;
|
||||
Q_EMIT nameChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
void Entry::setPropIsActive(bool active)
|
||||
{
|
||||
if (isActive != active) {
|
||||
isActive = active;
|
||||
if (m_isActive != active) {
|
||||
m_isActive = active;
|
||||
Q_EMIT isActiveChanged(active);
|
||||
}
|
||||
}
|
||||
@ -490,7 +490,7 @@ bool Entry::detachWindow(WindowInfoBase *info)
|
||||
}
|
||||
|
||||
if (m_windowInfoMap.isEmpty()) {
|
||||
if (!isDocked) {
|
||||
if (!m_isDocked) {
|
||||
// 既无窗口也非驻留应用,并且不是最近打开,无需在任务栏显示
|
||||
return true;
|
||||
}
|
||||
@ -523,8 +523,8 @@ bool Entry::isShowOnDock() const
|
||||
|
||||
// 1.时尚模式下,如果开启了显示最近使用,则不管是否有子窗口,都在任务栏上显示
|
||||
// 如果没有开启显示最近使用,则只显示有子窗口的
|
||||
if (static_cast<DisplayMode>(dock->getDisplayMode()) == DisplayMode::Fashion)
|
||||
return (dock->showRecent() || m_exportWindowInfos.size() > 0);
|
||||
if (static_cast<DisplayMode>(m_dock->getDisplayMode()) == DisplayMode::Fashion)
|
||||
return (m_dock->showRecent() || m_exportWindowInfos.size() > 0);
|
||||
|
||||
// 2.高效模式下,只有该应用有打开窗口才显示
|
||||
return m_exportWindowInfos.size() > 0;
|
||||
@ -556,7 +556,7 @@ bool Entry::attachWindow(WindowInfoBase *info)
|
||||
|
||||
if (!lastShowOnDock && isShowOnDock()) {
|
||||
// 新打开的窗口始终显示到最后
|
||||
Q_EMIT dock->entryAdded(QDBusObjectPath(path()), -1);
|
||||
Q_EMIT m_dock->entryAdded(QDBusObjectPath(path()), -1);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -564,7 +564,7 @@ bool Entry::attachWindow(WindowInfoBase *info)
|
||||
|
||||
void Entry::launchApp(uint32_t timestamp)
|
||||
{
|
||||
dock->launchApp(app->getFileName(), timestamp, QStringList());
|
||||
m_dock->launchApp(m_app->getFileName(), timestamp, QStringList());
|
||||
}
|
||||
|
||||
bool Entry::containsWindow(XWindow xid)
|
||||
@ -575,40 +575,40 @@ bool Entry::containsWindow(XWindow xid)
|
||||
// 处理菜单项
|
||||
void Entry::handleMenuItem(uint32_t timestamp, QString itemId)
|
||||
{
|
||||
menu->handleAction(timestamp, itemId);
|
||||
m_menu->handleAction(timestamp, itemId);
|
||||
}
|
||||
|
||||
// 处理拖拽事件
|
||||
void Entry::handleDragDrop(uint32_t timestamp, QStringList files)
|
||||
{
|
||||
dock->launchApp(app->getFileName(), timestamp, files);
|
||||
m_dock->launchApp(m_app->getFileName(), timestamp, files);
|
||||
}
|
||||
|
||||
// 驻留
|
||||
void Entry::requestDock(bool dockToEnd)
|
||||
{
|
||||
if (dock->dockEntry(this, dockToEnd)) {
|
||||
dock->saveDockedApps();
|
||||
if (m_dock->dockEntry(this, dockToEnd)) {
|
||||
m_dock->saveDockedApps();
|
||||
}
|
||||
}
|
||||
|
||||
// 取消驻留
|
||||
void Entry::requestUndock(bool dockToEnd)
|
||||
{
|
||||
dock->undockEntry(this, dockToEnd);
|
||||
m_dock->undockEntry(this, dockToEnd);
|
||||
}
|
||||
|
||||
void Entry::newInstance(uint32_t timestamp)
|
||||
{
|
||||
QStringList files;
|
||||
dock->launchApp(app->getFileName(), timestamp, files);
|
||||
m_dock->launchApp(m_app->getFileName(), timestamp, files);
|
||||
}
|
||||
|
||||
// 检查应用窗口分离、合并状态
|
||||
void Entry::check()
|
||||
{
|
||||
for (auto iter = m_windowInfoMap.begin(); iter != m_windowInfoMap.end(); iter++) {
|
||||
dock->attachOrDetachWindow(iter.value());
|
||||
m_dock->attachOrDetachWindow(iter.value());
|
||||
}
|
||||
}
|
||||
|
||||
@ -645,7 +645,7 @@ void Entry::presentWindows()
|
||||
windows.push_back(iter.key());
|
||||
}
|
||||
|
||||
dock->presentWindows(windows);
|
||||
m_dock->presentWindows(windows);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -654,9 +654,9 @@ void Entry::presentWindows()
|
||||
*/
|
||||
void Entry::active(uint32_t timestamp)
|
||||
{
|
||||
if (dock->getHideMode() == HideMode::SmartHide) {
|
||||
dock->setPropHideState(HideState::Show);
|
||||
dock->updateHideState(false);
|
||||
if (m_dock->getHideMode() == HideMode::SmartHide) {
|
||||
m_dock->setPropHideState(HideState::Show);
|
||||
m_dock->updateHideState(false);
|
||||
}
|
||||
|
||||
// 无窗口则直接启动
|
||||
@ -671,12 +671,12 @@ void Entry::active(uint32_t timestamp)
|
||||
}
|
||||
|
||||
WindowInfoBase *winInfo = m_current;
|
||||
if (dock->isWaylandEnv()) {
|
||||
if (m_dock->isWaylandEnv()) {
|
||||
// wayland环境
|
||||
if (!dock->isActiveWindow(winInfo)) {
|
||||
if (!m_dock->isActiveWindow(winInfo)) {
|
||||
winInfo->activate();
|
||||
} else {
|
||||
bool showing = dock->isShowingDesktop();
|
||||
bool showing = m_dock->isShowingDesktop();
|
||||
if (showing || winInfo->isMinimized()) {
|
||||
winInfo->activate();
|
||||
} else if (m_windowInfoMap.size() == 1) {
|
||||
@ -691,9 +691,9 @@ void Entry::active(uint32_t timestamp)
|
||||
} else {
|
||||
// X11环境
|
||||
XWindow xid = winInfo->getXid();
|
||||
WindowInfoBase *activeWin = dock->getActiveWindow();
|
||||
WindowInfoBase *activeWin = m_dock->getActiveWindow();
|
||||
if (activeWin && xid != activeWin->getXid()) {
|
||||
dock->doActiveWindow(xid);
|
||||
m_dock->doActiveWindow(xid);
|
||||
} else {
|
||||
bool found = false;
|
||||
XWindow hiddenAtom = XCB->getAtom("_NET_WM_STATE_HIDDEN");
|
||||
@ -706,11 +706,11 @@ void Entry::active(uint32_t timestamp)
|
||||
|
||||
if (found) {
|
||||
// 激活隐藏窗口
|
||||
dock->doActiveWindow(xid);
|
||||
m_dock->doActiveWindow(xid);
|
||||
} else if (m_windowInfoMap.size() == 1) {
|
||||
// 窗口图标化
|
||||
XCB->minimizeWindow(xid);
|
||||
} else if (dock->getActiveWindow() && dock->getActiveWindow()->getXid() == xid) {
|
||||
} else if (m_dock->getActiveWindow() && m_dock->getActiveWindow()->getXid() == xid) {
|
||||
WindowInfoBase *nextWin = findNextLeader();
|
||||
if (nextWin) {
|
||||
nextWin->activate();
|
||||
@ -722,13 +722,13 @@ void Entry::active(uint32_t timestamp)
|
||||
|
||||
void Entry::activeWindow(quint32 winId)
|
||||
{
|
||||
if (dock->isWaylandEnv()) {
|
||||
if (m_dock->isWaylandEnv()) {
|
||||
if (!m_windowInfoMap.contains(winId))
|
||||
return;
|
||||
|
||||
WindowInfoBase *winInfo = m_windowInfoMap[winId];
|
||||
if (dock->isActiveWindow(winInfo)) {
|
||||
bool showing = dock->isShowingDesktop();
|
||||
if (m_dock->isActiveWindow(winInfo)) {
|
||||
bool showing = m_dock->isShowingDesktop();
|
||||
if (showing || winInfo->isMinimized()) {
|
||||
winInfo->activate();
|
||||
} else if (m_windowInfoMap.size() == 1) {
|
||||
@ -743,7 +743,7 @@ void Entry::activeWindow(quint32 winId)
|
||||
winInfo->activate();
|
||||
}
|
||||
} else {
|
||||
dock->doActiveWindow(winId);
|
||||
m_dock->doActiveWindow(winId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -759,17 +759,17 @@ XWindow Entry::getCurrentWindow()
|
||||
|
||||
QString Entry::getDesktopFile()
|
||||
{
|
||||
return desktopFile;
|
||||
return m_desktopFile;
|
||||
}
|
||||
|
||||
bool Entry::getIsActive()
|
||||
{
|
||||
return isActive;
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
QString Entry::getMenu()
|
||||
{
|
||||
return menu->getMenuJsonStr();
|
||||
return m_menu->getMenuJsonStr();
|
||||
}
|
||||
|
||||
QVector<XWindow> Entry::getAllowedClosedWindowIds()
|
||||
@ -805,14 +805,14 @@ QVector<WindowInfoBase *> Entry::getAllowedCloseWindows()
|
||||
QVector<AppMenuItem> Entry::getMenuItemDesktopActions()
|
||||
{
|
||||
QVector<AppMenuItem> ret;
|
||||
if (!app) {
|
||||
if (!m_app) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (auto action : app->getActions()) {
|
||||
for (auto action : m_app->getActions()) {
|
||||
AppMenuAction fn = [=](uint32_t timestamp) {
|
||||
qInfo() << "do MenuItem: " << action.name.c_str();
|
||||
dock->launchAppAction(app->getFileName(), action.section.c_str(), timestamp);
|
||||
m_dock->launchAppAction(m_app->getFileName(), action.section.c_str(), timestamp);
|
||||
};
|
||||
|
||||
AppMenuItem item;
|
||||
@ -881,7 +881,7 @@ AppMenuItem Entry::getMenuItemCloseAll()
|
||||
|
||||
AppMenuItem Entry::getMenuItemForceQuit()
|
||||
{
|
||||
bool active = dock->getForceQuitAppStatus() != ForceQuitAppMode::Deactivated;
|
||||
bool active = m_dock->getForceQuitAppStatus() != ForceQuitAppMode::Deactivated;
|
||||
AppMenuAction fn = [this](uint32_t) {
|
||||
qInfo() << "do MenuItem: Force Quit";
|
||||
forceQuit();
|
||||
@ -897,7 +897,7 @@ AppMenuItem Entry::getMenuItemForceQuit()
|
||||
//dock栏上Android程序的Force Quit功能
|
||||
AppMenuItem Entry::getMenuItemForceQuitAndroid()
|
||||
{
|
||||
bool active = dock->getForceQuitAppStatus() != ForceQuitAppMode::Deactivated;
|
||||
bool active = m_dock->getForceQuitAppStatus() != ForceQuitAppMode::Deactivated;
|
||||
auto allowedCloseWindows = getAllowedCloseWindows();
|
||||
AppMenuAction fn = [](uint32_t){};
|
||||
if (allowedCloseWindows.size() > 0) {
|
||||
@ -969,8 +969,8 @@ bool Entry::killProcess(int pid)
|
||||
|
||||
bool Entry::setPropDesktopFile(QString value)
|
||||
{
|
||||
if (value != desktopFile) {
|
||||
desktopFile = value;
|
||||
if (value != m_desktopFile) {
|
||||
m_desktopFile = value;
|
||||
Q_EMIT desktopFileChanged(value);
|
||||
return true;
|
||||
}
|
||||
|
@ -132,18 +132,18 @@ private:
|
||||
int getCurrentMode();
|
||||
|
||||
private:
|
||||
Dock *dock;
|
||||
AppInfo *app;
|
||||
AppMenu *menu;
|
||||
Dock *m_dock;
|
||||
AppInfo *m_app;
|
||||
AppMenu *m_menu;
|
||||
|
||||
bool isActive;
|
||||
bool isDocked;
|
||||
bool m_isActive;
|
||||
bool m_isDocked;
|
||||
|
||||
QString id;
|
||||
QString name;
|
||||
QString icon;
|
||||
QString innerId;
|
||||
QString desktopFile;
|
||||
QString m_id;
|
||||
QString m_name;
|
||||
QString m_icon;
|
||||
QString m_innerId;
|
||||
QString m_desktopFile;
|
||||
|
||||
// Dbus属性直接放到interface上
|
||||
QMap<XWindow, WindowInfoBase *> m_windowInfoMap; // 该应用所有窗口
|
||||
|
@ -27,8 +27,8 @@
|
||||
|
||||
WaylandManager::WaylandManager(Dock *_dock, QObject *parent)
|
||||
: QObject(parent)
|
||||
, dock(_dock)
|
||||
, mutex(QMutex(QMutex::NonRecursive))
|
||||
, m_dock(_dock)
|
||||
, m_mutex(QMutex(QMutex::NonRecursive))
|
||||
{
|
||||
|
||||
}
|
||||
@ -44,7 +44,7 @@ void WaylandManager::registerWindow(const QString &objPath)
|
||||
if (findWindowByObjPath(objPath))
|
||||
return;
|
||||
|
||||
PlasmaWindow *plasmaWindow = dock->createPlasmaWindow(objPath);
|
||||
PlasmaWindow *plasmaWindow = m_dock->createPlasmaWindow(objPath);
|
||||
if (!plasmaWindow) {
|
||||
qWarning() << "registerWindowWayland: createPlasmaWindow failed";
|
||||
return;
|
||||
@ -61,11 +61,11 @@ void WaylandManager::registerWindow(const QString &objPath)
|
||||
winId = realId;
|
||||
|
||||
WindowInfoK *winInfo = new WindowInfoK(plasmaWindow, winId);
|
||||
dock->listenKWindowSignals(winInfo);
|
||||
m_dock->listenKWindowSignals(winInfo);
|
||||
insertWindow(objPath, winInfo);
|
||||
dock->attachOrDetachWindow(winInfo);
|
||||
m_dock->attachOrDetachWindow(winInfo);
|
||||
if (winId) {
|
||||
windowInfoMap[winId] = winInfo;
|
||||
m_windowInfoMap[winId] = winInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,16 +77,16 @@ void WaylandManager::unRegisterWindow(const QString &objPath)
|
||||
if (!winInfo)
|
||||
return;
|
||||
|
||||
dock->removePlasmaWindowHandler(winInfo->getPlasmaWindow());
|
||||
dock->detachWindow(winInfo);
|
||||
m_dock->removePlasmaWindowHandler(winInfo->getPlasmaWindow());
|
||||
m_dock->detachWindow(winInfo);
|
||||
deleteWindow(objPath);
|
||||
}
|
||||
|
||||
WindowInfoK *WaylandManager::handleActiveWindowChangedK(uint activeWin)
|
||||
{
|
||||
WindowInfoK *winInfo = nullptr;
|
||||
QMutexLocker locker(&mutex);
|
||||
for (auto iter = kWinInfos.begin(); iter != kWinInfos.end(); iter++) {
|
||||
QMutexLocker locker(&m_mutex);
|
||||
for (auto iter = m_kWinInfos.begin(); iter != m_kWinInfos.end(); iter++) {
|
||||
if (iter.value()->getInnerId() == activeWin) {
|
||||
winInfo = iter.value();
|
||||
break;
|
||||
@ -99,7 +99,7 @@ WindowInfoK *WaylandManager::handleActiveWindowChangedK(uint activeWin)
|
||||
WindowInfoK *WaylandManager::findWindowByXid(XWindow xid)
|
||||
{
|
||||
WindowInfoK *winInfo = nullptr;
|
||||
for (auto iter = kWinInfos.begin(); iter != kWinInfos.end(); iter++) {
|
||||
for (auto iter = m_kWinInfos.begin(); iter != m_kWinInfos.end(); iter++) {
|
||||
if (iter.value()->getXid() == xid) {
|
||||
winInfo = iter.value();
|
||||
break;
|
||||
@ -111,20 +111,20 @@ WindowInfoK *WaylandManager::findWindowByXid(XWindow xid)
|
||||
|
||||
WindowInfoK *WaylandManager::findWindowByObjPath(QString objPath)
|
||||
{
|
||||
if (kWinInfos.find(objPath) == kWinInfos.end())
|
||||
if (m_kWinInfos.find(objPath) == m_kWinInfos.end())
|
||||
return nullptr;
|
||||
|
||||
return kWinInfos[objPath];
|
||||
return m_kWinInfos[objPath];
|
||||
}
|
||||
|
||||
void WaylandManager::insertWindow(QString objPath, WindowInfoK *windowInfo)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
kWinInfos[objPath] = windowInfo;
|
||||
QMutexLocker locker(&m_mutex);
|
||||
m_kWinInfos[objPath] = windowInfo;
|
||||
}
|
||||
|
||||
void WaylandManager::deleteWindow(QString objPath)
|
||||
{
|
||||
kWinInfos.remove(objPath);
|
||||
m_kWinInfos.remove(objPath);
|
||||
}
|
||||
|
||||
|
@ -47,10 +47,10 @@ public:
|
||||
void deleteWindow(QString objPath);
|
||||
|
||||
private:
|
||||
Dock *dock;
|
||||
QMap<QString, WindowInfoK *> kWinInfos; // dbusObjectPath -> kwayland window Info
|
||||
QMap<XWindow, WindowInfoK *> windowInfoMap;
|
||||
QMutex mutex;
|
||||
Dock *m_dock;
|
||||
QMap<QString, WindowInfoK *> m_kWinInfos; // dbusObjectPath -> kwayland window Info
|
||||
QMap<XWindow, WindowInfoK *> m_windowInfoMap;
|
||||
QMutex m_mutex;
|
||||
};
|
||||
|
||||
#endif // WAYLANDMANAGER_H
|
||||
|
@ -82,20 +82,20 @@ static QMap<QString, QString> crxAppIdMap = {
|
||||
|
||||
WindowIdentify::WindowIdentify(Dock *_dock, QObject *parent)
|
||||
: QObject(parent)
|
||||
, dock(_dock)
|
||||
, m_dock(_dock)
|
||||
{
|
||||
identifyWindowFuns["Android"] = identifyWindowAndroid;
|
||||
identifyWindowFuns["PidEnv"] = identifyWindowByPidEnv;
|
||||
identifyWindowFuns["CmdlineTurboBooster"] = identifyWindowByCmdlineTurboBooster;
|
||||
identifyWindowFuns["Cmdline-XWalk"] = identifyWindowByCmdlineXWalk;
|
||||
identifyWindowFuns["FlatpakAppID"] = identifyWindowByFlatpakAppID;
|
||||
identifyWindowFuns["CrxId"] = identifyWindowByCrxId;
|
||||
identifyWindowFuns["Rule"] = identifyWindowByRule;
|
||||
identifyWindowFuns["Bamf"] = identifyWindowByBamf;
|
||||
identifyWindowFuns["Pid"] = identifyWindowByPid;
|
||||
identifyWindowFuns["Scratch"] = identifyWindowByScratch;
|
||||
identifyWindowFuns["GtkAppId"] = identifyWindowByGtkAppId;
|
||||
identifyWindowFuns["WmClass"] = identifyWindowByWmClass;
|
||||
m_identifyWindowFuns["Android"] = identifyWindowAndroid;
|
||||
m_identifyWindowFuns["PidEnv"] = identifyWindowByPidEnv;
|
||||
m_identifyWindowFuns["CmdlineTurboBooster"] = identifyWindowByCmdlineTurboBooster;
|
||||
m_identifyWindowFuns["Cmdline-XWalk"] = identifyWindowByCmdlineXWalk;
|
||||
m_identifyWindowFuns["FlatpakAppID"] = identifyWindowByFlatpakAppID;
|
||||
m_identifyWindowFuns["CrxId"] = identifyWindowByCrxId;
|
||||
m_identifyWindowFuns["Rule"] = identifyWindowByRule;
|
||||
m_identifyWindowFuns["Bamf"] = identifyWindowByBamf;
|
||||
m_identifyWindowFuns["Pid"] = identifyWindowByPid;
|
||||
m_identifyWindowFuns["Scratch"] = identifyWindowByScratch;
|
||||
m_identifyWindowFuns["GtkAppId"] = identifyWindowByGtkAppId;
|
||||
m_identifyWindowFuns["WmClass"] = identifyWindowByWmClass;
|
||||
|
||||
}
|
||||
|
||||
@ -121,11 +121,11 @@ AppInfo *WindowIdentify::identifyWindowX11(WindowInfoX *winInfo, QString &innerI
|
||||
return appInfo;
|
||||
}
|
||||
|
||||
for (auto iter = identifyWindowFuns.begin(); iter != identifyWindowFuns.end(); iter++) {
|
||||
for (auto iter = m_identifyWindowFuns.begin(); iter != m_identifyWindowFuns.end(); iter++) {
|
||||
QString name = iter.key();
|
||||
IdentifyFunc func = iter.value();
|
||||
qInfo() << "identifyWindowX11: try " << name;
|
||||
appInfo = func(dock, winInfo, innerId);
|
||||
appInfo = func(m_dock, winInfo, innerId);
|
||||
if (appInfo) { // TODO: if name == "Pid", appInfo may by nullptr
|
||||
// 识别成功
|
||||
qInfo() << "identify Window by " << name << " innerId " << appInfo->getInnerId() << " success!";
|
||||
@ -149,7 +149,7 @@ AppInfo *WindowIdentify::identifyWindowX11(WindowInfoX *winInfo, QString &innerI
|
||||
AppInfo *WindowIdentify::identifyWindowWayland(WindowInfoK *winInfo, QString &innerId)
|
||||
{
|
||||
// TODO: 对桌面调起的文管应用做规避处理,需要在此处添加,因为初始化时appId和title为空
|
||||
if (winInfo->getAppId() == "dde-desktop" && dock->shouldShowOnDock(winInfo)) {
|
||||
if (winInfo->getAppId() == "dde-desktop" && m_dock->shouldShowOnDock(winInfo)) {
|
||||
winInfo->setAppId("dde-file-manager");
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ AppInfo *WindowIdentify::identifyWindowWayland(WindowInfoK *winInfo, QString &in
|
||||
} else {
|
||||
// bamf
|
||||
XWindow winId = winInfo->getXid();
|
||||
QString desktop = dock->getDesktopFromWindowByBamf(winId);
|
||||
QString desktop = m_dock->getDesktopFromWindowByBamf(winId);
|
||||
if (!desktop.isEmpty()) {
|
||||
appInfo = new AppInfo(desktop);
|
||||
}
|
||||
@ -530,15 +530,3 @@ QString WindowIdentify::getAndroidUengineName(XWindow winId)
|
||||
// TODO 获取AndroidUengineName
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,15 +60,14 @@ public:
|
||||
static AppInfo *identifyWindowByGtkAppId(Dock *_dock, WindowInfoX *winInfo, QString &innerId);
|
||||
static AppInfo *identifyWindowByWmClass(Dock *_dock, WindowInfoX *winInfo, QString &innerId);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
private:
|
||||
AppInfo *fixAutostartAppInfo(QString fileName);
|
||||
static int32_t getAndroidUengineId(XWindow winId);
|
||||
static QString getAndroidUengineName(XWindow winId);
|
||||
|
||||
Dock *dock;
|
||||
QMap<QString, IdentifyFunc> identifyWindowFuns;
|
||||
private:
|
||||
Dock *m_dock;
|
||||
QMap<QString, IdentifyFunc> m_identifyWindowFuns;
|
||||
};
|
||||
|
||||
#endif // IDENTIFYWINDOW_H
|
||||
|
@ -36,13 +36,13 @@
|
||||
|
||||
WindowInfoX::WindowInfoX(XWindow _xid)
|
||||
: WindowInfoBase ()
|
||||
, x(0)
|
||||
, y(0)
|
||||
, width(0)
|
||||
, height(0)
|
||||
, hasWMTransientFor(false)
|
||||
, hasXEmbedInfo(false)
|
||||
, updateCalled(false)
|
||||
, m_x(0)
|
||||
, m_y(0)
|
||||
, m_width(0)
|
||||
, m_height(0)
|
||||
, m_hasWMTransientFor(false)
|
||||
, m_hasXEmbedInfo(false)
|
||||
, m_updateCalled(false)
|
||||
{
|
||||
xid = _xid;
|
||||
createdTime = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()).count(); // 获取当前时间,精确到纳秒
|
||||
@ -56,15 +56,15 @@ WindowInfoX::~WindowInfoX()
|
||||
bool WindowInfoX::shouldSkip()
|
||||
{
|
||||
qInfo() << "window " << xid << " shouldSkip?";
|
||||
if (!updateCalled) {
|
||||
if (!m_updateCalled) {
|
||||
update();
|
||||
updateCalled = true;
|
||||
m_updateCalled = true;
|
||||
}
|
||||
|
||||
if (hasWmStateSkipTaskBar() || isValidModal() || shouldSkipWithWMClass())
|
||||
return true;
|
||||
|
||||
for (auto atom : wmWindowType) {
|
||||
for (auto atom : m_wmWindowType) {
|
||||
if (atom == XCB->getAtom("_NET_WM_WINDOW_TYPE_DIALOG") && !isActionMinimizeAllowed())
|
||||
return true;
|
||||
|
||||
@ -109,7 +109,7 @@ void WindowInfoX::minimize()
|
||||
|
||||
bool WindowInfoX::isMinimized()
|
||||
{
|
||||
return containAtom(wmState, XCB->getAtom("_NET_WM_STATE_HIDDEN"));
|
||||
return containAtom(m_wmState, XCB->getAtom("_NET_WM_STATE_HIDDEN"));
|
||||
}
|
||||
|
||||
int64_t WindowInfoX::getCreatedTime()
|
||||
@ -129,12 +129,12 @@ bool WindowInfoX::allowClose()
|
||||
// 2. 或者设置了 functions 字段并且 设置了 MotifFunctionAll 标志位;
|
||||
// 3. 或者设置了 functions 字段并且 设置了 MotifFunctionClose 标志位。
|
||||
// 相关定义在 motif-2.3.8/lib/Xm/MwmUtil.h 。
|
||||
if ((motifWmHints.flags & MotifHintFunctions) == 0
|
||||
|| (motifWmHints.functions & MotifFunctionAll) != 0
|
||||
|| (motifWmHints.functions & MotifFunctionClose) != 0)
|
||||
if ((m_motifWmHints.flags & MotifHintFunctions) == 0
|
||||
|| (m_motifWmHints.functions & MotifFunctionAll) != 0
|
||||
|| (m_motifWmHints.functions & MotifFunctionClose) != 0)
|
||||
return true;
|
||||
|
||||
for (auto action : wmAllowedActions) {
|
||||
for (auto action : m_wmAllowedActions) {
|
||||
if (action == XCB->getAtom("_NET_WM_ACTION_CLOSE")) {
|
||||
return true;
|
||||
}
|
||||
@ -147,10 +147,10 @@ QString WindowInfoX::getDisplayName()
|
||||
{
|
||||
XWindow winId = xid;
|
||||
//QString role = wmRole;
|
||||
QString className(wmClass.className.c_str());
|
||||
QString className(m_wmClass.className.c_str());
|
||||
QString instance;
|
||||
if (wmClass.instanceName.size() > 0) {
|
||||
int pos = QString(wmClass.instanceName.c_str()).lastIndexOf('/');
|
||||
if (m_wmClass.instanceName.size() > 0) {
|
||||
int pos = QString(m_wmClass.instanceName.c_str()).lastIndexOf('/');
|
||||
if (pos != -1)
|
||||
instance.remove(0, pos + 1);
|
||||
}
|
||||
@ -166,7 +166,7 @@ QString WindowInfoX::getDisplayName()
|
||||
return instance;
|
||||
|
||||
|
||||
QString _wmName = wmName;
|
||||
QString _wmName = m_wmName;
|
||||
if (!_wmName.isEmpty()) {
|
||||
int pos = _wmName.lastIndexOf('-');
|
||||
if (pos != -1 && !_wmName.startsWith("-")) {
|
||||
@ -196,60 +196,60 @@ QString WindowInfoX::uuid()
|
||||
|
||||
QString WindowInfoX::getGtkAppId()
|
||||
{
|
||||
return gtkAppId;
|
||||
return m_gtkAppId;
|
||||
}
|
||||
|
||||
QString WindowInfoX::getFlatpakAppId()
|
||||
{
|
||||
return flatpakAppId;
|
||||
return m_flatpakAppId;
|
||||
}
|
||||
|
||||
QString WindowInfoX::getWmRole()
|
||||
{
|
||||
return wmRole;
|
||||
return m_wmRole;
|
||||
}
|
||||
|
||||
WMClass WindowInfoX::getWMClass()
|
||||
{
|
||||
return wmClass;
|
||||
return m_wmClass;
|
||||
}
|
||||
|
||||
QString WindowInfoX::getWMName()
|
||||
{
|
||||
return wmName;
|
||||
return m_wmName;
|
||||
}
|
||||
|
||||
ConfigureEvent *WindowInfoX::getLastConfigureEvent()
|
||||
{
|
||||
return lastConfigureNotifyEvent;
|
||||
return m_lastConfigureNotifyEvent;
|
||||
}
|
||||
|
||||
void WindowInfoX::setLastConfigureEvent(ConfigureEvent *event)
|
||||
{
|
||||
lastConfigureNotifyEvent = event;
|
||||
m_lastConfigureNotifyEvent = event;
|
||||
}
|
||||
|
||||
bool WindowInfoX::isGeometryChanged(int _x, int _y, int _width, int _height)
|
||||
{
|
||||
return !(_x == x && _y == y && _width == width && _height == height);
|
||||
return !(_x == m_x && _y == m_y && _width == m_width && _height == m_height);
|
||||
}
|
||||
|
||||
void WindowInfoX::setGtkAppId(QString _gtkAppId)
|
||||
{
|
||||
gtkAppId = _gtkAppId;
|
||||
m_gtkAppId = _gtkAppId;
|
||||
}
|
||||
|
||||
void WindowInfoX::updateMotifWmHints()
|
||||
{
|
||||
// get from XCB
|
||||
motifWmHints = XCB->getWindowMotifWMHints(xid);
|
||||
m_motifWmHints = XCB->getWindowMotifWMHints(xid);
|
||||
}
|
||||
|
||||
// XEmbed info
|
||||
// 一般 tray icon 会带有 _XEMBED_INFO 属性
|
||||
void WindowInfoX::updateHasXEmbedInfo()
|
||||
{
|
||||
hasXEmbedInfo = XCB->hasXEmbedInfo(xid);
|
||||
m_hasXEmbedInfo = XCB->hasXEmbedInfo(xid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,39 +308,39 @@ QString WindowInfoX::genInnerId(WindowInfoX *winInfo)
|
||||
// 更新窗口类型
|
||||
void WindowInfoX::updateWmWindowType()
|
||||
{
|
||||
wmWindowType.clear();
|
||||
m_wmWindowType.clear();
|
||||
for (auto ty : XCB->getWMWindoType(xid)) {
|
||||
wmWindowType.push_back(ty);
|
||||
m_wmWindowType.push_back(ty);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新窗口许可动作
|
||||
void WindowInfoX::updateWmAllowedActions()
|
||||
{
|
||||
wmAllowedActions.clear();
|
||||
m_wmAllowedActions.clear();
|
||||
for (auto action : XCB->getWMAllowedActions(xid)) {
|
||||
wmAllowedActions.push_back(action);
|
||||
m_wmAllowedActions.push_back(action);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowInfoX::updateWmState()
|
||||
{
|
||||
wmState.clear();
|
||||
m_wmState.clear();
|
||||
for (auto a : XCB->getWMState(xid)) {
|
||||
wmState.push_back(a);
|
||||
m_wmState.push_back(a);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowInfoX::updateWmClass()
|
||||
{
|
||||
wmClass = XCB->getWMClass(xid);
|
||||
m_wmClass = XCB->getWMClass(xid);
|
||||
}
|
||||
|
||||
void WindowInfoX::updateWmName()
|
||||
{
|
||||
auto name = XCB->getWMName(xid);
|
||||
if (!name.empty())
|
||||
wmName = name.c_str();
|
||||
m_wmName = name.c_str();
|
||||
|
||||
title = getTitle();
|
||||
}
|
||||
@ -353,7 +353,7 @@ void WindowInfoX::updateIcon()
|
||||
void WindowInfoX::updateHasWmTransientFor()
|
||||
{
|
||||
if (XCB->getWMTransientFor(xid) == 1)
|
||||
hasWMTransientFor = true;
|
||||
m_hasWMTransientFor = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -379,22 +379,22 @@ QString WindowInfoX::getIconFromWindow()
|
||||
|
||||
bool WindowInfoX::isActionMinimizeAllowed()
|
||||
{
|
||||
return containAtom(wmAllowedActions, XCB->getAtom("_NET_WM_ACTION_MINIMIZE"));
|
||||
return containAtom(m_wmAllowedActions, XCB->getAtom("_NET_WM_ACTION_MINIMIZE"));
|
||||
}
|
||||
|
||||
bool WindowInfoX::hasWmStateDemandsAttention()
|
||||
{
|
||||
return containAtom(wmState, XCB->getAtom("_NET_WM_STATE_DEMANDS_ATTENTION"));
|
||||
return containAtom(m_wmState, XCB->getAtom("_NET_WM_STATE_DEMANDS_ATTENTION"));
|
||||
}
|
||||
|
||||
bool WindowInfoX::hasWmStateSkipTaskBar()
|
||||
{
|
||||
return containAtom(wmState, XCB->getAtom("_NET_WM_STATE_SKIP_TASKBAR"));
|
||||
return containAtom(m_wmState, XCB->getAtom("_NET_WM_STATE_SKIP_TASKBAR"));
|
||||
}
|
||||
|
||||
bool WindowInfoX::hasWmStateModal()
|
||||
{
|
||||
return containAtom(wmState, XCB->getAtom("_NET_WM_STATE_MODAL"));
|
||||
return containAtom(m_wmState, XCB->getAtom("_NET_WM_STATE_MODAL"));
|
||||
}
|
||||
|
||||
bool WindowInfoX::isValidModal()
|
||||
@ -406,9 +406,9 @@ bool WindowInfoX::isValidModal()
|
||||
bool WindowInfoX::shouldSkipWithWMClass()
|
||||
{
|
||||
bool ret = false;
|
||||
if (wmClass.instanceName == "explorer.exe" && wmClass.className == "Wine")
|
||||
if (m_wmClass.instanceName == "explorer.exe" && m_wmClass.className == "Wine")
|
||||
ret = true;
|
||||
else if (wmClass.className == "dde-launcher")
|
||||
else if (m_wmClass.className == "dde-launcher")
|
||||
ret = true;
|
||||
|
||||
return ret;
|
||||
@ -437,7 +437,7 @@ void WindowInfoX::updateProcessInfo()
|
||||
|
||||
bool WindowInfoX::getUpdateCalled()
|
||||
{
|
||||
return updateCalled;
|
||||
return m_updateCalled;
|
||||
}
|
||||
|
||||
void WindowInfoX::setInnerId(QString _innerId)
|
||||
@ -447,7 +447,7 @@ void WindowInfoX::setInnerId(QString _innerId)
|
||||
|
||||
QString WindowInfoX::getTitle()
|
||||
{
|
||||
QString name = wmName;
|
||||
QString name = m_wmName;
|
||||
if (name.isEmpty())
|
||||
name = getDisplayName();
|
||||
|
||||
|
@ -86,24 +86,27 @@ private:
|
||||
bool isValidModal();
|
||||
bool shouldSkipWithWMClass();
|
||||
|
||||
int16_t x, y;
|
||||
uint16_t width, height;
|
||||
QVector<XCBAtom> wmState;
|
||||
QVector<XCBAtom> wmWindowType;
|
||||
QVector<XCBAtom> wmAllowedActions;
|
||||
bool hasWMTransientFor;
|
||||
WMClass wmClass;
|
||||
QString wmName;
|
||||
bool hasXEmbedInfo;
|
||||
private:
|
||||
int16_t m_x;
|
||||
int16_t m_y;
|
||||
uint16_t m_width;
|
||||
uint16_t m_height;
|
||||
QVector<XCBAtom> m_wmState;
|
||||
QVector<XCBAtom> m_wmWindowType;
|
||||
QVector<XCBAtom> m_wmAllowedActions;
|
||||
bool m_hasWMTransientFor;
|
||||
WMClass m_wmClass;
|
||||
QString m_wmName;
|
||||
bool m_hasXEmbedInfo;
|
||||
|
||||
// 自定义atom属性
|
||||
QString gtkAppId;
|
||||
QString flatpakAppId;
|
||||
QString wmRole;
|
||||
MotifWMHints motifWmHints;
|
||||
QString m_gtkAppId;
|
||||
QString m_flatpakAppId;
|
||||
QString m_wmRole;
|
||||
MotifWMHints m_motifWmHints;
|
||||
|
||||
bool updateCalled;
|
||||
ConfigureEvent *lastConfigureNotifyEvent;
|
||||
bool m_updateCalled;
|
||||
ConfigureEvent *m_lastConfigureNotifyEvent;
|
||||
};
|
||||
|
||||
#endif // WINDOWINFOX_H
|
||||
|
@ -160,7 +160,7 @@ WindowPatterns::WindowPatterns()
|
||||
*/
|
||||
QString WindowPatterns::match(WindowInfoX *winInfo)
|
||||
{
|
||||
for (auto pattern : patterns) {
|
||||
for (auto pattern : m_patterns) {
|
||||
bool patternOk = true;
|
||||
for (auto rule : pattern.parseRules) {
|
||||
if (!rule.match(winInfo)) {
|
||||
@ -195,7 +195,7 @@ void WindowPatterns::loadWindowPatterns()
|
||||
if (arr.size() == 0)
|
||||
return;
|
||||
|
||||
patterns.clear();
|
||||
m_patterns.clear();
|
||||
for (auto iterp = arr.begin(); iterp != arr.end(); iterp++) {
|
||||
// 过滤非Object
|
||||
if (!(*iterp).isObject())
|
||||
@ -226,11 +226,11 @@ void WindowPatterns::loadWindowPatterns()
|
||||
for (const auto &item : pattern.rules) {
|
||||
qInfo() << item[0] << " " << item[1];
|
||||
}
|
||||
patterns.push_back(pattern);
|
||||
m_patterns.push_back(pattern);
|
||||
}
|
||||
|
||||
// 解析patterns
|
||||
for (auto &pattern : patterns) {
|
||||
for (auto &pattern : m_patterns) {
|
||||
for (int i=0; i < pattern.rules.size(); i++) {
|
||||
RuleValueParse ruleValue = parseRule(pattern.rules[i]);
|
||||
pattern.parseRules.push_back(ruleValue);
|
||||
|
@ -58,7 +58,9 @@ public:
|
||||
private:
|
||||
void loadWindowPatterns();
|
||||
RuleValueParse parseRule(QVector<QString> rule);
|
||||
QVector<WindowPattern> patterns;
|
||||
|
||||
private:
|
||||
QVector<WindowPattern> m_patterns;
|
||||
|
||||
};
|
||||
|
||||
|
@ -41,11 +41,11 @@
|
||||
|
||||
X11Manager::X11Manager(Dock *_dock, QObject *parent)
|
||||
: QObject(parent)
|
||||
, dock(_dock)
|
||||
, mutex(QMutex(QMutex::NonRecursive))
|
||||
, listenXEvent(true)
|
||||
, m_dock(_dock)
|
||||
, m_mutex(QMutex(QMutex::NonRecursive))
|
||||
, m_listenXEvent(true)
|
||||
{
|
||||
rootWindow = XCB->getRootWindow();
|
||||
m_rootWindow = XCB->getRootWindow();
|
||||
}
|
||||
|
||||
void X11Manager::listenXEventUseXlib()
|
||||
@ -98,7 +98,7 @@ void X11Manager::listenXEventUseXlib()
|
||||
attr.event_mask &= ~SubstructureRedirectMask;
|
||||
XSelectInput(dpy, w, attr.event_mask);
|
||||
|
||||
while (listenXEvent) {
|
||||
while (m_listenXEvent) {
|
||||
XEvent event;
|
||||
XNextEvent (dpy, &event);
|
||||
|
||||
@ -178,8 +178,8 @@ WindowInfoX *X11Manager::registerWindow(XWindow xid)
|
||||
qInfo() << "registWindow: windowId=" << xid;
|
||||
WindowInfoX *ret = nullptr;
|
||||
do {
|
||||
if (windowInfoMap.find(xid) != windowInfoMap.end()) {
|
||||
ret = windowInfoMap[xid];
|
||||
if (m_windowInfoMap.find(xid) != m_windowInfoMap.end()) {
|
||||
ret = m_windowInfoMap[xid];
|
||||
break;
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ WindowInfoX *X11Manager::registerWindow(XWindow xid)
|
||||
break;
|
||||
|
||||
listenWindowXEvent(winInfo);
|
||||
windowInfoMap[xid] = winInfo;
|
||||
m_windowInfoMap[xid] = winInfo;
|
||||
ret = winInfo;
|
||||
} while (0);
|
||||
|
||||
@ -199,16 +199,16 @@ WindowInfoX *X11Manager::registerWindow(XWindow xid)
|
||||
void X11Manager::unregisterWindow(XWindow xid)
|
||||
{
|
||||
qInfo() << "unregisterWindow: windowId=" << xid;
|
||||
if (windowInfoMap.find(xid) != windowInfoMap.end()) {
|
||||
windowInfoMap.remove(xid);
|
||||
if (m_windowInfoMap.find(xid) != m_windowInfoMap.end()) {
|
||||
m_windowInfoMap.remove(xid);
|
||||
}
|
||||
}
|
||||
|
||||
WindowInfoX *X11Manager::findWindowByXid(XWindow xid)
|
||||
{
|
||||
WindowInfoX *ret = nullptr;
|
||||
if (windowInfoMap.find(xid) != windowInfoMap.end())
|
||||
ret = windowInfoMap[xid];
|
||||
if (m_windowInfoMap.find(xid) != m_windowInfoMap.end())
|
||||
ret = m_windowInfoMap[xid];
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -219,12 +219,12 @@ void X11Manager::handleClientListChanged()
|
||||
for (auto atom : XCB->getClientList())
|
||||
newClientList.insert(atom);
|
||||
|
||||
for (auto atom : dock->getClientList())
|
||||
for (auto atom : m_dock->getClientList())
|
||||
oldClientList.insert(atom);
|
||||
|
||||
addClientList = newClientList - oldClientList;
|
||||
rmClientList = oldClientList - newClientList;
|
||||
dock->setClientList(newClientList.toList());
|
||||
m_dock->setClientList(newClientList.toList());
|
||||
|
||||
// 处理新增窗口
|
||||
for (auto xid : addClientList) {
|
||||
@ -246,15 +246,15 @@ void X11Manager::handleClientListChanged()
|
||||
|
||||
// 处理需要移除的窗口
|
||||
for (auto xid : rmClientList) {
|
||||
WindowInfoX *info = windowInfoMap[xid];
|
||||
WindowInfoX *info = m_windowInfoMap[xid];
|
||||
if (info) {
|
||||
dock->detachWindow(info);
|
||||
m_dock->detachWindow(info);
|
||||
unregisterWindow(xid);
|
||||
} else {
|
||||
// no window
|
||||
auto entry = dock->getEntryByWindowId(xid);
|
||||
if (entry && !dock->isDocked(entry->getFileName())) {
|
||||
dock->removeAppEntry(entry);
|
||||
auto entry = m_dock->getEntryByWindowId(xid);
|
||||
if (entry && !m_dock->isDocked(entry->getFileName())) {
|
||||
m_dock->removeAppEntry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -272,7 +272,7 @@ void X11Manager::handleActiveWindowChangedX()
|
||||
void X11Manager::listenRootWindowXEvent()
|
||||
{
|
||||
uint32_t eventMask = EventMask::XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY;
|
||||
XCB->registerEvents(rootWindow, eventMask);
|
||||
XCB->registerEvents(m_rootWindow, eventMask);
|
||||
handleActiveWindowChangedX();
|
||||
handleClientListChanged();
|
||||
}
|
||||
@ -308,7 +308,7 @@ void X11Manager::handleDestroyNotifyEvent(XWindow xid)
|
||||
if (!winInfo)
|
||||
return;
|
||||
|
||||
dock->detachWindow(winInfo);
|
||||
m_dock->detachWindow(winInfo);
|
||||
unregisterWindow(xid);
|
||||
}
|
||||
|
||||
@ -323,8 +323,8 @@ void X11Manager::handleMapNotifyEvent(XWindow xid)
|
||||
//QTimer::singleShot(2 * 1000, this, [=] {
|
||||
qInfo() << "handleMapNotifyEvent: pass 2s, now call idnetifyWindow, windowId=" << winInfo->getXid();
|
||||
QString innerId;
|
||||
AppInfo *appInfo = dock->identifyWindow(winInfo, innerId);
|
||||
dock->markAppLaunched(appInfo);
|
||||
AppInfo *appInfo = m_dock->identifyWindow(winInfo, innerId);
|
||||
m_dock->markAppLaunched(appInfo);
|
||||
//});
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ void X11Manager::handleMapNotifyEvent(XWindow xid)
|
||||
void X11Manager::handleConfigureNotifyEvent(XWindow xid, int x, int y, int width, int height)
|
||||
{
|
||||
WindowInfoX *winInfo = findWindowByXid(xid);
|
||||
if (!winInfo || dock->getDockHideMode() != HideMode::SmartHide)
|
||||
if (!winInfo || m_dock->getDockHideMode() != HideMode::SmartHide)
|
||||
return;
|
||||
|
||||
WMClass wmClass = winInfo->getWMClass();
|
||||
@ -345,7 +345,7 @@ void X11Manager::handleConfigureNotifyEvent(XWindow xid, int x, int y, int width
|
||||
// property changed event
|
||||
void X11Manager::handlePropertyNotifyEvent(XWindow xid, XCBAtom atom)
|
||||
{
|
||||
if (xid == rootWindow) {
|
||||
if (xid == m_rootWindow) {
|
||||
handleRootWindowPropertyNotifyEvent(atom);
|
||||
return;
|
||||
}
|
||||
@ -392,7 +392,7 @@ void X11Manager::handlePropertyNotifyEvent(XWindow xid, XCBAtom atom)
|
||||
|
||||
if (!newInnerId.isEmpty() && winInfo->getUpdateCalled() && winInfo->getInnerId() != newInnerId) {
|
||||
// winInfo.innerId changed
|
||||
dock->detachWindow(winInfo);
|
||||
m_dock->detachWindow(winInfo);
|
||||
winInfo->setInnerId(newInnerId);
|
||||
needAttachOrDetach = true;
|
||||
}
|
||||
@ -401,7 +401,7 @@ void X11Manager::handlePropertyNotifyEvent(XWindow xid, XCBAtom atom)
|
||||
Q_EMIT requestAttachOrDetachWindow(winInfo);
|
||||
}
|
||||
|
||||
Entry *entry = dock->getEntryByWindowId(xid);
|
||||
Entry *entry = m_dock->getEntryByWindowId(xid);
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
@ -444,28 +444,28 @@ void X11Manager::addWindowLastConfigureEvent(XWindow xid, ConfigureEvent *event)
|
||||
{
|
||||
delWindowLastConfigureEvent(xid);
|
||||
|
||||
QMutexLocker locker(&mutex);
|
||||
QMutexLocker locker(&m_mutex);
|
||||
QTimer *timer = new QTimer();
|
||||
timer->setInterval(configureNotifyDelay);
|
||||
windowLastConfigureEventMap[xid] = QPair(event, timer);
|
||||
m_windowLastConfigureEventMap[xid] = QPair(event, timer);
|
||||
}
|
||||
|
||||
QPair<ConfigureEvent *, QTimer *> X11Manager::getWindowLastConfigureEvent(XWindow xid)
|
||||
{
|
||||
QPair<ConfigureEvent *, QTimer *> ret;
|
||||
QMutexLocker locker(&mutex);
|
||||
if (windowLastConfigureEventMap.find(xid) != windowLastConfigureEventMap.end())
|
||||
ret = windowLastConfigureEventMap[xid];
|
||||
QMutexLocker locker(&m_mutex);
|
||||
if (m_windowLastConfigureEventMap.find(xid) != m_windowLastConfigureEventMap.end())
|
||||
ret = m_windowLastConfigureEventMap[xid];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void X11Manager::delWindowLastConfigureEvent(XWindow xid)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
if (windowLastConfigureEventMap.find(xid) != windowLastConfigureEventMap.end()) {
|
||||
QPair<ConfigureEvent*, QTimer*> item = windowLastConfigureEventMap[xid];
|
||||
windowLastConfigureEventMap.remove(xid);
|
||||
QMutexLocker locker(&m_mutex);
|
||||
if (m_windowLastConfigureEventMap.find(xid) != m_windowLastConfigureEventMap.end()) {
|
||||
QPair<ConfigureEvent*, QTimer*> item = m_windowLastConfigureEventMap[xid];
|
||||
m_windowLastConfigureEventMap.remove(xid);
|
||||
delete item.first;
|
||||
item.second->deleteLater();
|
||||
}
|
||||
|
@ -68,12 +68,13 @@ private:
|
||||
QPair<ConfigureEvent*, QTimer*> getWindowLastConfigureEvent(XWindow xid);
|
||||
void delWindowLastConfigureEvent(XWindow xid);
|
||||
|
||||
QMap<XWindow, WindowInfoX *> windowInfoMap;
|
||||
Dock *dock;
|
||||
QMap<XWindow, QPair<ConfigureEvent*, QTimer*>> windowLastConfigureEventMap; // 手动回收ConfigureEvent和QTimer
|
||||
QMutex mutex;
|
||||
XWindow rootWindow; // 根窗口
|
||||
bool listenXEvent; // 监听X事件
|
||||
private:
|
||||
QMap<XWindow, WindowInfoX *> m_windowInfoMap;
|
||||
Dock *m_dock;
|
||||
QMap<XWindow, QPair<ConfigureEvent*, QTimer*>> m_windowLastConfigureEventMap; // 手动回收ConfigureEvent和QTimer
|
||||
QMutex m_mutex;
|
||||
XWindow m_rootWindow; // 根窗口
|
||||
bool m_listenXEvent; // 监听X事件
|
||||
};
|
||||
|
||||
#endif // X11MANAGER_H
|
||||
|
@ -57,44 +57,43 @@ class ApplicationManager : public QObject, public QDBusContext
|
||||
Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), ApplicationManager)
|
||||
|
||||
public:
|
||||
ApplicationManager(QObject *parent = nullptr);
|
||||
~ApplicationManager() override;
|
||||
static ApplicationManager* instance();
|
||||
|
||||
void addApplication(const QList<QSharedPointer<Application>> &list);
|
||||
void launchAutostartApps();
|
||||
void processInstanceStatus(Methods::ProcessStatus instanceStatus);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void AutostartChanged(QString status, QString filePath);
|
||||
|
||||
public: // PROPERTIES
|
||||
QList<QDBusObjectPath> instances() const;
|
||||
QList<QDBusObjectPath> list() const;
|
||||
|
||||
public Q_SLOTS: // METHODS
|
||||
QDBusObjectPath GetInformation(const QString &id);
|
||||
QList<QDBusObjectPath> GetInstances(const QString &id);
|
||||
QDBusObjectPath Launch(const QString &id, QStringList files);
|
||||
|
||||
// com.deepin.StartManager
|
||||
//bool Launch(QString desktopFile); deprecated
|
||||
bool AddAutostart(QString fileName);
|
||||
bool RemoveAutostart(QString fileName);
|
||||
QStringList AutostartList();
|
||||
QString DumpMemRecord();
|
||||
//QString GetApps();
|
||||
bool IsAutostart(QString fileName);
|
||||
bool IsMemSufficient();
|
||||
//bool Launch(QString desktopFile); deprecated
|
||||
void LaunchApp(QString desktopFile, uint32_t timestamp, QStringList files);
|
||||
QDBusObjectPath Launch(const QString &id, QStringList files);
|
||||
bool RemoveAutostart(QString fileName);
|
||||
bool IsPidVirtualMachine(uint32_t pid);
|
||||
void LaunchAppAction(QString desktopFile, QString action, uint32_t timestamp);
|
||||
void RunCommand(QString exe, QStringList args);
|
||||
void TryAgain(bool launch);
|
||||
|
||||
protected:
|
||||
ApplicationManager(QObject *parent = nullptr);
|
||||
~ApplicationManager() override;
|
||||
|
||||
QList<QDBusObjectPath> instances() const;
|
||||
QList<QDBusObjectPath> list() const;
|
||||
QDBusObjectPath GetInformation(const QString &id);
|
||||
QList<QDBusObjectPath> GetInstances(const QString &id);
|
||||
// com.deepin.StartManager
|
||||
//QString GetApps();
|
||||
void LaunchApp(QString desktopFile, uint32_t timestamp, QStringList files);
|
||||
void LaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
||||
//bool LaunchWithTimestamp(QString desktopFile, uint32_t timestamp); deprecated
|
||||
void RunCommand(QString exe, QStringList args);
|
||||
void RunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
||||
void TryAgain(bool launch);
|
||||
bool IsPidVirtualMachine(uint32_t pid);
|
||||
bool IsProcessExist(uint32_t pid);
|
||||
};
|
||||
|
||||
|
@ -81,7 +81,6 @@ int main(int argc, char *argv[])
|
||||
new AppManager(ApplicationManager::instance());
|
||||
new LauncherManager(ApplicationManager::instance());
|
||||
new DockManager(ApplicationManager::instance());
|
||||
new StartManager(ApplicationManager::instance());
|
||||
new ApplicationManagerAdaptor(ApplicationManager::instance());
|
||||
|
||||
QDBusConnection::sessionBus().registerService("org.desktopspec.Application");
|
||||
|
Reference in New Issue
Block a user