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