规范任务栏代码,增加代码整洁度和安全性
Log: 规范任务栏模块代码 Task: https://pms.uniontech.com/task-view-150885.html Influence: 无 Change-Id: I385fbb71cf4c1408ffd4c6684128b412a187ab28
This commit is contained in:
parent
e9e79e3ac9
commit
e557f374c5
@ -496,7 +496,9 @@ WMClass XCBUtils::getWMClass(XWindow xid)
|
||||
if (reply.instance_name)
|
||||
ret.instanceName.assign(reply.instance_name);
|
||||
|
||||
xcb_icccm_get_wm_class_reply_wipe(&reply);
|
||||
if (reply.class_name || reply.instance_name) {
|
||||
xcb_icccm_get_wm_class_reply_wipe(&reply);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ QString AppMenu::getMenuJsonStr()
|
||||
objItem["itemIconInactive"] = item.iconInactive;
|
||||
objItem["showCheckMark"] = item.showCheckMark;
|
||||
objItem["itemSubMenu"] = item.subMenu ? item.subMenu->getMenuJsonStr() : "";
|
||||
array.push_back(QJsonValue(objItem));
|
||||
array.push_back(objItem);
|
||||
}
|
||||
obj["items"] = QJsonValue(array);
|
||||
obj["checkableMenu"] = checkableMenu;
|
||||
|
@ -203,13 +203,14 @@ void Dock::undockEntry(Entry *entry)
|
||||
QString desktopFile = entry->getFileName();
|
||||
QString filebase(desktopFile.data(), desktopFile.size() - 9);
|
||||
if (desktopFile.contains(scratchDir)) {
|
||||
for (auto &ext : QStringList() << ".desktop" << ".sh" << ".png") {
|
||||
QStringList suffixs {".desktop", ".sh", ".png"};
|
||||
for (auto &ext : suffixs) {
|
||||
QString fileName = filebase + ext;
|
||||
QFile file(fileName);
|
||||
if (file.exists())
|
||||
if (file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (entry->hasWindow()) {
|
||||
|
@ -579,7 +579,6 @@ void Entry::forceQuit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Entry::presentWindows()
|
||||
|
@ -221,9 +221,9 @@ void X11Manager::handleClientListChanged()
|
||||
QString wmName(XCB->getWMName(xid).c_str());
|
||||
if (pid != 0 || (wmClass.className.size() > 0 && wmClass.instanceName.size() > 0)
|
||||
|| wmName.size() > 0 || XCB->getWMCommand(xid).size() > 0) {
|
||||
WindowInfoBase *base = static_cast<WindowInfoBase *>(info);
|
||||
if (base) {
|
||||
Q_EMIT requestAttachOrDetachWindow(base);
|
||||
|
||||
if (info) {
|
||||
Q_EMIT requestAttachOrDetachWindow(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -248,9 +248,8 @@ void X11Manager::handleActiveWindowChangedX()
|
||||
{
|
||||
XWindow active = XCB->getActiveWindow();
|
||||
WindowInfoX *info = findWindowByXid(active);
|
||||
WindowInfoBase *base = static_cast<WindowInfoBase *>(info);
|
||||
if (base) {
|
||||
Q_EMIT requestHandleActiveWindowChange(base);
|
||||
if (info) {
|
||||
Q_EMIT requestHandleActiveWindowChange(info);
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,8 +381,9 @@ void X11Manager::handlePropertyNotifyEvent(XWindow xid, XCBAtom atom)
|
||||
needAttachOrDetach = true;
|
||||
}
|
||||
|
||||
if (needAttachOrDetach)
|
||||
dock->attachOrDetachWindow(winInfo);
|
||||
if (needAttachOrDetach && winInfo) {
|
||||
Q_EMIT requestAttachOrDetachWindow(winInfo);
|
||||
}
|
||||
|
||||
Entry *entry = dock->getEntryByWindowId(xid);
|
||||
if (!entry)
|
||||
|
Loading…
Reference in New Issue
Block a user