2022-04-24 14:52:13 +08:00
|
|
|
|
/*
|
2022-05-15 12:10:42 +08:00
|
|
|
|
* Copyright (C) 2021 ~ 2022 Deepin Technology Co., Ltd.
|
2022-04-24 14:52:13 +08:00
|
|
|
|
*
|
|
|
|
|
* Author: weizhixiang <weizhixiang@uniontech.com>
|
|
|
|
|
*
|
|
|
|
|
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "dock.h"
|
|
|
|
|
#include "windowidentify.h"
|
|
|
|
|
#include "windowinfok.h"
|
|
|
|
|
#include "xcbutils.h"
|
|
|
|
|
#include "dbushandler.h"
|
|
|
|
|
#include "appinfo.h"
|
|
|
|
|
#include "waylandmanager.h"
|
|
|
|
|
#include "x11manager.h"
|
|
|
|
|
#include "windowinfobase.h"
|
|
|
|
|
#include "dbusplasmawindow.h"
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
#include "macro.h"
|
|
|
|
|
|
2022-04-24 14:52:13 +08:00
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QMap>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
|
|
#define SETTING DockSettings::instance()
|
|
|
|
|
#define XCB XCBUtils::instance()
|
|
|
|
|
|
|
|
|
|
Dock::Dock(QObject *parent)
|
|
|
|
|
: SynModule(parent)
|
2022-08-04 21:22:22 +08:00
|
|
|
|
, m_entriesSum(0)
|
|
|
|
|
, m_windowIdentify(new WindowIdentify(this))
|
|
|
|
|
, m_entries(new Entries(this))
|
|
|
|
|
, m_ddeLauncherVisible(false)
|
|
|
|
|
, m_hideState(HideState::Unknown)
|
|
|
|
|
, m_activeWindow(nullptr)
|
|
|
|
|
, m_activeWindowOld(nullptr)
|
|
|
|
|
, m_dbusHandler(new DBusHandler(this))
|
|
|
|
|
, m_windowOperateMutex(QMutex(QMutex::NonRecursive))
|
2022-07-27 15:37:58 +08:00
|
|
|
|
, m_showRecent(false)
|
|
|
|
|
, m_showMultiWindow(false)
|
2022-04-24 14:52:13 +08:00
|
|
|
|
{
|
|
|
|
|
registeModule("dock");
|
|
|
|
|
|
|
|
|
|
QString sessionType {getenv("XDG_SESSION_TYPE")};
|
2022-06-07 20:21:25 +08:00
|
|
|
|
qInfo() << "sessionType=" << sessionType;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
if (sessionType.contains("wayland")) {
|
|
|
|
|
// wayland env
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_isWayland = true;
|
|
|
|
|
m_waylandManager = new WaylandManager(this);
|
|
|
|
|
m_dbusHandler->listenWaylandWMSignals();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
} else if (sessionType.contains("x11")) {
|
|
|
|
|
// x11 env
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_isWayland = false;
|
|
|
|
|
m_x11Manager = new X11Manager(this);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initSettings();
|
|
|
|
|
initEntries();
|
|
|
|
|
|
|
|
|
|
// 初始化智能隐藏定时器
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_smartHideTimer = new QTimer(this);
|
|
|
|
|
m_smartHideTimer->setSingleShot(true);
|
|
|
|
|
connect(m_smartHideTimer, &QTimer::timeout, this, &Dock::smartHideModeTimerExpired);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (!m_isWayland) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
std::thread thread([&] {
|
|
|
|
|
// Xlib方式
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_x11Manager->listenXEventUseXlib();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
// XCB方式
|
|
|
|
|
//listenXEventUseXCB();
|
|
|
|
|
});
|
|
|
|
|
thread.detach();
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_x11Manager->listenRootWindowXEvent();
|
|
|
|
|
connect(m_x11Manager, &X11Manager::requestUpdateHideState, this, &Dock::updateHideState);
|
|
|
|
|
connect(m_x11Manager, &X11Manager::requestHandleActiveWindowChange, this, &Dock::handleActiveWindowChanged);
|
|
|
|
|
connect(m_x11Manager, &X11Manager::requestAttachOrDetachWindow, this, &Dock::attachOrDetachWindow);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dock::~Dock()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::dockEntry 驻留应用
|
|
|
|
|
* @param entry 应用实例
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-08-08 13:20:42 +08:00
|
|
|
|
bool Dock::dockEntry(Entry *entry, bool moveToEnd)
|
2022-04-24 14:52:13 +08:00
|
|
|
|
{
|
|
|
|
|
if (entry->getIsDocked())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
AppInfo *app = entry->getApp();
|
|
|
|
|
auto needScratchDesktop = [&]{
|
|
|
|
|
if (!app) {
|
|
|
|
|
qInfo() << "needScratchDesktop: yes, appInfo is nil";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (app->isInstalled()) {
|
|
|
|
|
qInfo() << "needScratchDesktop: no, desktop is installed";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (app->getFileName().contains(scratchDir)) {
|
|
|
|
|
qInfo() << "needScratchDesktop: no, desktop in scratchDir";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (needScratchDesktop()) {
|
|
|
|
|
// 创建scratch Desktop file
|
|
|
|
|
QDir dir;
|
|
|
|
|
if (!dir.mkpath(scratchDir)) {
|
|
|
|
|
qWarning() << "create scratch Desktopfile failed";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QFile file;
|
|
|
|
|
QString newDesktopFile;
|
|
|
|
|
if (app) {
|
|
|
|
|
QString newFile = scratchDir + app->getInnerId() + ".desktop";
|
2022-07-29 18:21:21 +08:00
|
|
|
|
// 在目标文件存在的情况下,先删除,防止出现驻留不成功的情况
|
|
|
|
|
if (QFile::exists(newFile))
|
|
|
|
|
QFile::remove(newFile);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
if (file.copy(app->getFileName(), newFile))
|
|
|
|
|
newDesktopFile = newFile;
|
|
|
|
|
} else {
|
|
|
|
|
WindowInfoBase *current = entry->getCurrentWindowInfo();
|
|
|
|
|
if (current) {
|
|
|
|
|
QString appId = current->getInnerId();
|
|
|
|
|
QString title = current->getDisplayName();
|
|
|
|
|
QString icon = current->getIcon();
|
|
|
|
|
if (icon.isEmpty())
|
|
|
|
|
icon = "application-default-icon";
|
|
|
|
|
|
|
|
|
|
QString scriptContent = entry->getExec(false);
|
|
|
|
|
QString scriptFile = scratchDir + appId + ".sh";
|
|
|
|
|
file.setFileName(scriptFile);
|
|
|
|
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
|
|
|
file.write(scriptContent.toStdString().c_str(), scriptContent.size());
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// createScratchDesktopFile
|
|
|
|
|
QString cmd = scriptFile + " %U";
|
|
|
|
|
QString fileNmae = scratchDir + appId + ".desktop";
|
|
|
|
|
QString desktopContent = QString(dockedItemTemplate).arg(title).arg(cmd).arg(icon);
|
|
|
|
|
file.setFileName(fileNmae);
|
|
|
|
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
|
|
|
file.write(desktopContent.toStdString().c_str(), desktopContent.size());
|
|
|
|
|
file.close();
|
|
|
|
|
newDesktopFile = fileNmae;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (newDesktopFile.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
app = new AppInfo(newDesktopFile);
|
|
|
|
|
entry->setApp(app);
|
|
|
|
|
entry->updateIcon();
|
|
|
|
|
entry->setInnerId(app->getInnerId());
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-08 13:20:42 +08:00
|
|
|
|
// 如果是最近打开应用,通过右键菜单的方式驻留,且当前是时尚模式,那么就让entry驻留到末尾
|
|
|
|
|
if (moveToEnd && SETTING->getDisplayMode() == DisplayMode::Fashion)
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_entries->moveEntryToLast(entry);
|
2022-08-08 13:20:42 +08:00
|
|
|
|
|
2022-10-28 11:19:47 +08:00
|
|
|
|
entry->setIsDocked(true);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
entry->updateMenu();
|
2022-08-04 21:22:22 +08:00
|
|
|
|
entry->updateMode();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::undockEntry 取消驻留
|
|
|
|
|
* @param entry 应用实例
|
|
|
|
|
*/
|
2022-08-08 13:20:42 +08:00
|
|
|
|
void Dock::undockEntry(Entry *entry, bool moveToEnd)
|
2022-04-24 14:52:13 +08:00
|
|
|
|
{
|
|
|
|
|
if (!entry->getIsDocked()) {
|
|
|
|
|
qInfo() << "undockEntry: " << entry->getId() << " is not docked";
|
2022-07-27 15:37:58 +08:00
|
|
|
|
// 当应用图标在最近打开区域的时候,此时该应用是未驻留的应用,如果该最近打开应用没有打开窗口,将这个图标
|
|
|
|
|
// 拖动到回收站了,此时调用的是undock方法,根据需求,需要将该图标删除
|
2022-07-29 18:21:21 +08:00
|
|
|
|
if (!entry->hasWindow()) {
|
|
|
|
|
// 没有子窗口的情况下,从列表中移除
|
|
|
|
|
removeAppEntry(entry);
|
|
|
|
|
saveDockedApps();
|
|
|
|
|
}
|
2022-04-24 14:52:13 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!entry->getApp()) {
|
|
|
|
|
qInfo() << "undockEntry: entry appInfo is nullptr";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 移除scratchDir目录下相关文件
|
|
|
|
|
QString desktopFile = entry->getFileName();
|
|
|
|
|
QString filebase(desktopFile.data(), desktopFile.size() - 9);
|
|
|
|
|
if (desktopFile.contains(scratchDir)) {
|
2022-06-17 13:21:30 +08:00
|
|
|
|
QStringList suffixs {".desktop", ".sh", ".png"};
|
|
|
|
|
for (auto &ext : suffixs) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QString fileName = filebase + ext;
|
|
|
|
|
QFile file(fileName);
|
2022-06-17 13:21:30 +08:00
|
|
|
|
if (file.exists()) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
file.remove();
|
2022-06-17 13:21:30 +08:00
|
|
|
|
}
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (entry->hasWindow()) {
|
2022-08-04 21:22:22 +08:00
|
|
|
|
// 移除驻留后,如果当前应用存在子窗口,那么会将移除最近使用应用中最后一个没有子窗口的窗口
|
|
|
|
|
m_entries->removeLastRecent();
|
2022-08-08 13:20:42 +08:00
|
|
|
|
if (desktopFile.contains(scratchDir) && entry->getCurrentWindowInfo()) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QFileInfo info(desktopFile);
|
|
|
|
|
QString baseName = info.baseName();
|
|
|
|
|
if (baseName.startsWith(windowHashPrefix)) {
|
|
|
|
|
// desktop base starts with w:
|
|
|
|
|
// 由于有 Pid 识别方法在,在这里不能用 m.identifyWindow 再次识别
|
|
|
|
|
entry->setInnerId(entry->getCurrentWindowInfo()->getInnerId());
|
|
|
|
|
entry->setApp(nullptr); // 此处设置Entry的app为空, 在Entry中调用app相关信息前判断指针是否为空
|
|
|
|
|
} else {
|
|
|
|
|
// desktop base starts with d:
|
|
|
|
|
QString innerId;
|
2022-08-04 21:22:22 +08:00
|
|
|
|
AppInfo *app = m_windowIdentify->identifyWindow(entry->getCurrentWindowInfo(), innerId);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
// TODO update entry's innerId
|
|
|
|
|
entry->setApp(app);
|
|
|
|
|
entry->setInnerId(innerId);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-08 13:20:42 +08:00
|
|
|
|
// 如果存在窗口,在时尚模式下,就会移动到最近打开区域,此时让它移动到最后
|
|
|
|
|
if (moveToEnd && SETTING->getDisplayMode() == DisplayMode::Fashion)
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_entries->moveEntryToLast(entry);
|
2022-08-08 13:20:42 +08:00
|
|
|
|
|
2022-04-24 14:52:13 +08:00
|
|
|
|
entry->updateIcon();
|
2022-10-28 11:19:47 +08:00
|
|
|
|
entry->setIsDocked(false);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
entry->updateName();
|
|
|
|
|
entry->updateMenu();
|
|
|
|
|
} else {
|
|
|
|
|
// 直接移除
|
|
|
|
|
removeAppEntry(entry);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
// 更新模式, 是在应用区域还是在最近打开区域
|
|
|
|
|
entry->updateMode();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
saveDockedApps();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::allocEntryId 分配应用实例id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QString Dock::allocEntryId()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return QString("e%1T%2").arg(++m_entriesSum).arg(QString::number(QDateTime::currentSecsSinceEpoch(), 16));
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::shouldShowOnDock 判断是否应该显示到任务栏
|
|
|
|
|
* @param info
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool Dock::shouldShowOnDock(WindowInfoBase *info)
|
|
|
|
|
{
|
|
|
|
|
if (info->getWindowType() == "X11") {
|
|
|
|
|
XWindow winId = info->getXid();
|
2022-08-04 21:22:22 +08:00
|
|
|
|
bool isReg = m_x11Manager->findWindowByXid(winId);
|
|
|
|
|
bool isContainedInClientList = m_clientList.indexOf(winId) != -1;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool shouldSkip = info->shouldSkip();
|
|
|
|
|
bool isGood = XCB->isGoodWindow(winId);
|
|
|
|
|
qInfo() << "shouldShowOnDock X11: isReg:" << isReg << " isContainedInClientList:" << isContainedInClientList << " shouldSkip:" << shouldSkip << " isGood:" << isGood;
|
|
|
|
|
|
|
|
|
|
return isReg && isContainedInClientList && isGood && !shouldSkip;
|
|
|
|
|
} else if (info->getWindowType() == "Wayland") {
|
|
|
|
|
return !info->shouldSkip();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setDdeLauncherVisible 记录当前启动器是否可见
|
|
|
|
|
* @param visible
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setDdeLauncherVisible(bool visible)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_ddeLauncherVisible = visible;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getWMName 获取窗管名称
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QString Dock::getWMName()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_wmName;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setWMName 设置窗管名称
|
|
|
|
|
* @param name 窗管名称
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setWMName(QString name)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_wmName = name;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setSynConfig 同步配置 TODO
|
|
|
|
|
* @param ba 配置数据
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setSynConfig(QByteArray ba)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getSyncConfig 获取配置 TODO
|
|
|
|
|
* @return 配置数据
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QByteArray Dock::getSyncConfig()
|
|
|
|
|
{
|
|
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::createPlasmaWindow 创建wayland下窗口
|
|
|
|
|
* @param objPath
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
PlasmaWindow *Dock::createPlasmaWindow(QString objPath)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_dbusHandler->createPlasmaWindow(objPath);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::listenKWindowSignals
|
|
|
|
|
* @param windowInfo
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::listenKWindowSignals(WindowInfoK *windowInfo)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_dbusHandler->listenKWindowSignals(windowInfo);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::removePlasmaWindowHandler 关闭窗口后需求对应的connect
|
|
|
|
|
* @param window
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::removePlasmaWindowHandler(PlasmaWindow *window)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_dbusHandler->removePlasmaWindowHandler(window);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::presentWindows 显示窗口
|
|
|
|
|
* @param windows 窗口id
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::presentWindows(QList<uint> windows)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_dbusHandler->presentWindows(windows);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getDockHideMode 获取任务栏隐藏模式 一直显示/一直隐藏/智能隐藏
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
HideMode Dock::getDockHideMode()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getHideMode();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::isActiveWindow 判断是否为活动窗口
|
|
|
|
|
* @param win
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
bool Dock::isActiveWindow(const WindowInfoBase *win)
|
|
|
|
|
{
|
|
|
|
|
if (!win)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return win == getActiveWindow();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getActiveWindow 获取当前活跃窗口
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
WindowInfoBase *Dock::getActiveWindow()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (!m_activeWindow)
|
|
|
|
|
return m_activeWindowOld;
|
|
|
|
|
|
|
|
|
|
return m_activeWindow;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
|
void Dock::doActiveWindow(XWindow xid)
|
|
|
|
|
{
|
2022-06-02 14:20:42 +08:00
|
|
|
|
// 修改当前工作区为指定窗口的工作区
|
|
|
|
|
XWindow winWorkspace = XCB->getWMDesktop(xid);
|
|
|
|
|
XWindow currentWorkspace = XCB->getCurrentWMDesktop();
|
|
|
|
|
if (winWorkspace != currentWorkspace) {
|
|
|
|
|
qInfo() << "doActiveWindow: change currentWorkspace " << currentWorkspace << " to winWorkspace " << winWorkspace;
|
|
|
|
|
|
|
|
|
|
// 获取窗口时间
|
|
|
|
|
uint32_t timestamp = XCB->getWMUserTime(xid);
|
|
|
|
|
// 修改当前桌面工作区
|
|
|
|
|
XCB->changeCurrentDesktop(winWorkspace, timestamp);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
|
XCB->changeActiveWindow(xid);
|
2022-05-31 21:36:06 +08:00
|
|
|
|
QTimer::singleShot(50, [&] {
|
2022-05-24 21:49:47 +08:00
|
|
|
|
XCB->restackWindow(xid);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getClientList 获取窗口client列表
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QList<XWindow> Dock::getClientList()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return QList<XWindow>(m_clientList);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 17:20:39 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setClientList 设置窗口client列表
|
|
|
|
|
*/
|
|
|
|
|
void Dock::setClientList(QList<XWindow> value)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_clientList = value;
|
2022-05-31 17:20:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::closeWindow 关闭窗口
|
|
|
|
|
* @param windowId 窗口id
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::closeWindow(uint32_t windowId)
|
|
|
|
|
{
|
|
|
|
|
qInfo() << "Close Window " << windowId;
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (m_isWayland) {
|
|
|
|
|
WindowInfoK *info = m_waylandManager->findWindowByXid(windowId);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
if (info)
|
|
|
|
|
info->close(0);
|
|
|
|
|
} else {
|
|
|
|
|
XCB->requestCloseWindow(windowId, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getEntryIDs 获取所有应用Id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QStringList Dock::getEntryIDs()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_entries->getEntryIDs();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setFrontendWindowRect 设置任务栏Rect
|
|
|
|
|
* @param x
|
|
|
|
|
* @param y
|
|
|
|
|
* @param width
|
|
|
|
|
* @param height
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setFrontendWindowRect(int32_t x, int32_t y, uint width, uint height)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (m_frontendWindowRect == QRect(x, y, width, height)) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
qInfo() << "SetFrontendWindowRect: no changed";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_frontendWindowRect.setX(x);
|
|
|
|
|
m_frontendWindowRect.setY(y);
|
|
|
|
|
m_frontendWindowRect.setWidth(width);
|
|
|
|
|
m_frontendWindowRect.setHeight(height);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
updateHideState(false);
|
|
|
|
|
|
|
|
|
|
Q_EMIT frontendWindowRectChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::isDocked 应用是否驻留
|
|
|
|
|
* @param desktopFile
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool Dock::isDocked(const QString desktopFile)
|
|
|
|
|
{
|
|
|
|
|
auto entry = getDockedEntryByDesktopFile(desktopFile);
|
|
|
|
|
return !!entry;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::requestDock 驻留应用
|
|
|
|
|
* @param desktopFile desktopFile全路径
|
|
|
|
|
* @param index
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool Dock::requestDock(QString desktopFile, int index)
|
|
|
|
|
{
|
|
|
|
|
qInfo() << "RequestDock: " << desktopFile;
|
|
|
|
|
AppInfo *app = new AppInfo(desktopFile);
|
|
|
|
|
if (!app || !app->isValidApp()) {
|
|
|
|
|
qInfo() << "RequestDock: invalid desktopFile";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
Entry *entry = m_entries->getByInnerId(app->getInnerId());
|
2022-10-28 11:19:47 +08:00
|
|
|
|
if (!entry)
|
2022-04-24 14:52:13 +08:00
|
|
|
|
entry = new Entry(this, app, app->getInnerId());
|
|
|
|
|
|
|
|
|
|
if (!dockEntry(entry))
|
|
|
|
|
return false;
|
|
|
|
|
|
2022-10-28 11:19:47 +08:00
|
|
|
|
entry->startExport();
|
|
|
|
|
m_entries->append(entry);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
|
|
|
|
|
saveDockedApps();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::requestUndock 取消驻留应用
|
|
|
|
|
* @param desktopFile desktopFile文件全路径
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool Dock::requestUndock(QString desktopFile)
|
|
|
|
|
{
|
|
|
|
|
auto entry = getDockedEntryByDesktopFile(desktopFile);
|
|
|
|
|
if (!entry)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
undockEntry(entry);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
void Dock::setShowRecent(bool visible)
|
|
|
|
|
{
|
|
|
|
|
if (visible == m_showRecent)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
SETTING->setShowRecent(visible);
|
|
|
|
|
onShowRecentChanged(visible);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Dock::showRecent() const
|
|
|
|
|
{
|
|
|
|
|
return m_showRecent;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-27 15:37:58 +08:00
|
|
|
|
void Dock::setShowMultiWindow(bool visible)
|
|
|
|
|
{
|
|
|
|
|
if (m_showMultiWindow == visible)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
SETTING->setShowMultiWindow(visible);
|
|
|
|
|
onShowMultiWindowChanged(visible);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Dock::showMultiWindow() const
|
|
|
|
|
{
|
|
|
|
|
return m_showMultiWindow;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::moveEntry 移动驻留程序顺序
|
|
|
|
|
* @param oldIndex
|
|
|
|
|
* @param newIndex
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::moveEntry(int oldIndex, int newIndex)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_entries->move(oldIndex, newIndex);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
saveDockedApps();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::isOnDock 是否在任务栏
|
|
|
|
|
* @param desktopFile desktopFile文件全路径
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool Dock::isOnDock(QString desktopFile)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_entries->getByDesktopFilePath(desktopFile);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::queryWindowIdentifyMethod 查询窗口识别方式
|
|
|
|
|
* @param windowId 窗口id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QString Dock::queryWindowIdentifyMethod(XWindow windowId)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_entries->queryWindowIdentifyMethod(windowId);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getDockedAppsDesktopFiles 获取驻留应用desktop文件
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QStringList Dock::getDockedAppsDesktopFiles()
|
|
|
|
|
{
|
|
|
|
|
QStringList ret;
|
2022-08-04 21:22:22 +08:00
|
|
|
|
for (auto entry: m_entries->filterDockedEntries()) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
ret << entry->getFileName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getPluginSettings 获取任务栏插件配置
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QString Dock::getPluginSettings()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getPluginSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setPluginSettings 设置任务栏插件配置
|
|
|
|
|
* @param jsonStr
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setPluginSettings(QString jsonStr)
|
|
|
|
|
{
|
|
|
|
|
SETTING->setPluginSettings(jsonStr);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::mergePluginSettings 合并任务栏插件配置
|
|
|
|
|
* @param jsonStr
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::mergePluginSettings(QString jsonStr)
|
|
|
|
|
{
|
|
|
|
|
SETTING->mergePluginSettings(jsonStr);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::removePluginSettings 移除任务栏插件配置
|
|
|
|
|
* @param pluginName
|
|
|
|
|
* @param settingkeys
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::removePluginSettings(QString pluginName, QStringList settingkeys)
|
|
|
|
|
{
|
|
|
|
|
SETTING->removePluginSettings(pluginName, settingkeys);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::smartHideModeTimerExpired 设置智能隐藏
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::smartHideModeTimerExpired()
|
|
|
|
|
{
|
|
|
|
|
HideState state = shouldHideOnSmartHideMode() ? HideState::Hide : HideState::Show;
|
2022-06-09 14:12:44 +08:00
|
|
|
|
qInfo() << "smartHideModeTimerExpired, should hide ? " << int(state);
|
2022-05-24 21:49:47 +08:00
|
|
|
|
setPropHideState(state);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::initSettings 初始化配置
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::initSettings()
|
|
|
|
|
{
|
2022-06-07 20:21:25 +08:00
|
|
|
|
qInfo() << "init dock settings";
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_forceQuitAppStatus = SETTING->getForceQuitAppMode();
|
|
|
|
|
connect(SETTING, &DockSettings::hideModeChanged, this, [ this ](HideMode mode) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
this->updateHideState(false);
|
|
|
|
|
});
|
|
|
|
|
connect(SETTING, &DockSettings::displayModeChanged, this, [](DisplayMode mode) {
|
|
|
|
|
qInfo() << "display mode change to " << static_cast<int>(mode);
|
|
|
|
|
});
|
2022-05-19 13:13:55 +08:00
|
|
|
|
connect(SETTING, &DockSettings::positionModeChanged, this, [](PositionMode mode) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
qInfo() << "position mode change to " << static_cast<int>(mode);
|
|
|
|
|
});
|
2022-08-04 21:22:22 +08:00
|
|
|
|
connect(SETTING, &DockSettings::forceQuitAppChanged, this, [ this ](ForceQuitAppMode mode) {
|
2022-05-19 13:13:55 +08:00
|
|
|
|
qInfo() << "forceQuitApp change to " << int(mode);
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_forceQuitAppStatus = mode;
|
|
|
|
|
m_entries->updateEntriesMenu();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
});
|
2022-08-04 21:22:22 +08:00
|
|
|
|
connect(SETTING, &DockSettings::showRecentChanged, this, &Dock::onShowRecentChanged);
|
2022-07-27 15:37:58 +08:00
|
|
|
|
connect(SETTING, &DockSettings::showMultiWindowChanged, this, &Dock::onShowMultiWindowChanged);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::initEntries 初始化应用
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::initEntries()
|
|
|
|
|
{
|
2022-08-08 13:20:42 +08:00
|
|
|
|
loadAppInfos();
|
|
|
|
|
initClientList();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
2022-08-08 13:20:42 +08:00
|
|
|
|
* @brief Dock::loadAppInfos 加载本地驻留和最近使用的应用信息
|
2022-05-19 13:13:55 +08:00
|
|
|
|
*/
|
2022-08-08 13:20:42 +08:00
|
|
|
|
void Dock::loadAppInfos()
|
2022-04-24 14:52:13 +08:00
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
// 读取是否显示最近打开应用
|
|
|
|
|
m_showRecent = SETTING->showRecent();
|
2022-07-27 15:37:58 +08:00
|
|
|
|
// 读取是否显示多开窗口拆分
|
|
|
|
|
m_showMultiWindow = SETTING->showMultiWindow();
|
2022-08-08 13:20:42 +08:00
|
|
|
|
// 初始化驻留应用信息和最近使用的应用的信息
|
|
|
|
|
auto loadApps = [ this ](const QStringList &apps, bool isDocked) {
|
|
|
|
|
for (const QString &app : apps) {
|
|
|
|
|
QString path = app;
|
|
|
|
|
DesktopInfo info(path.toStdString());
|
|
|
|
|
if (!info.isValidDesktop())
|
|
|
|
|
continue;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
|
2022-08-08 13:20:42 +08:00
|
|
|
|
AppInfo *appInfo = new AppInfo(info);
|
|
|
|
|
Entry *entryObj = new Entry(this, appInfo, appInfo->getInnerId());
|
|
|
|
|
entryObj->setIsDocked(isDocked);
|
2022-07-27 15:37:58 +08:00
|
|
|
|
entryObj->updateMode();
|
2022-08-08 13:20:42 +08:00
|
|
|
|
entryObj->updateMenu();
|
|
|
|
|
entryObj->startExport();
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_entries->append(entryObj);
|
2022-08-08 13:20:42 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2022-04-24 14:52:13 +08:00
|
|
|
|
|
2022-08-08 13:20:42 +08:00
|
|
|
|
loadApps(SETTING->getDockedApps(), true);
|
|
|
|
|
QStringList recentApps = SETTING->getRecentApps();
|
|
|
|
|
if (recentApps.size() > MAX_UNOPEN_RECENT_COUNT) {
|
|
|
|
|
QStringList tempApps = recentApps;
|
|
|
|
|
recentApps.clear();
|
|
|
|
|
for (int i = 0; i < MAX_UNOPEN_RECENT_COUNT; i++)
|
|
|
|
|
recentApps << tempApps[i];
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
2022-08-08 13:20:42 +08:00
|
|
|
|
loadApps(recentApps, false);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
saveDockedApps();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::initClientList 初始化窗口列表,关联到对应应用
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::initClientList()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (m_isWayland) {
|
|
|
|
|
m_dbusHandler->loadClientList();
|
2022-08-08 13:20:42 +08:00
|
|
|
|
} else {
|
|
|
|
|
QList<XWindow> clients;
|
|
|
|
|
for (auto c : XCB->instance()->getClientList())
|
|
|
|
|
clients.push_back(c);
|
|
|
|
|
|
|
|
|
|
// 依次注册窗口
|
|
|
|
|
qSort(clients.begin(), clients.end());
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_clientList = clients;
|
|
|
|
|
for (auto winId : m_clientList) {
|
|
|
|
|
WindowInfoX *winInfo = m_x11Manager->registerWindow(winId);
|
2022-08-08 13:20:42 +08:00
|
|
|
|
attachOrDetachWindow(static_cast<WindowInfoBase *>(winInfo));
|
|
|
|
|
}
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::findWindowByXidX 通过id获取窗口信息
|
|
|
|
|
* @param xid
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
WindowInfoX *Dock::findWindowByXidX(XWindow xid)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_x11Manager->findWindowByXid(xid);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::findWindowByXidK 通过xid获取窗口 TODO wayland和x11下窗口尽量完全剥离, 不应该存在通过xid查询wayland窗口的情况
|
|
|
|
|
* @param xid
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
WindowInfoK *Dock::findWindowByXidK(XWindow xid)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_waylandManager->findWindowByXid(xid);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
2022-05-24 21:49:47 +08:00
|
|
|
|
* @brief Dock::isWindowDockOverlapX 判断X环境下窗口和任务栏是否重叠
|
2022-05-19 13:13:55 +08:00
|
|
|
|
* @param xid
|
|
|
|
|
* @return
|
2022-05-24 21:49:47 +08:00
|
|
|
|
* 计算重叠条件:
|
|
|
|
|
* 1 窗口类型非桌面desktop
|
|
|
|
|
* 2 窗口透明度非0
|
|
|
|
|
* 3 窗口显示在当前工作区域
|
|
|
|
|
* 4 窗口和任务栏rect存在重叠区域
|
2022-05-19 13:13:55 +08:00
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool Dock::isWindowDockOverlapX(XWindow xid)
|
|
|
|
|
{
|
2022-05-24 21:49:47 +08:00
|
|
|
|
// 检查窗口类型
|
|
|
|
|
auto desktopType = XCB->getAtom("_NET_WM_WINDOW_TYPE_DESKTOP");
|
|
|
|
|
for (auto ty : XCB->getWMWindoType(xid)) {
|
|
|
|
|
if (ty == desktopType) {
|
|
|
|
|
// 不处理桌面窗口属性
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO 检查窗口透明度
|
|
|
|
|
// 检查窗口是否显示
|
|
|
|
|
auto wmHiddenType = XCB->getAtom("_NET_WM_STATE_HIDDEN");
|
|
|
|
|
for (auto ty : XCB->getWMState(xid)) {
|
|
|
|
|
if (ty == wmHiddenType) {
|
|
|
|
|
// 不处理隐藏的窗口属性
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查窗口是否在当前工作区
|
|
|
|
|
uint32_t wmDesktop = XCB->getWMDesktop(xid);
|
|
|
|
|
uint32_t currentDesktop = XCB->getCurrentWMDesktop();
|
|
|
|
|
if (wmDesktop != currentDesktop) {
|
|
|
|
|
qInfo() << "isWindowDockOverlapX: wmDesktop:" << wmDesktop << " is not equal to currentDesktop:" << currentDesktop;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查窗口和任务栏窗口是否存在重叠
|
|
|
|
|
auto winRect = XCB->getWindowGeometry(xid);
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return hasInterSectionX(winRect, m_frontendWindowRect);
|
2022-05-24 21:49:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::hasInterSectionX 检查窗口重叠区域
|
|
|
|
|
* @param windowRect 活动窗口
|
|
|
|
|
* @param dockRect 任务栏窗口
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
bool Dock::hasInterSectionX(const Geometry &windowRect, QRect dockRect)
|
|
|
|
|
{
|
|
|
|
|
int ltX = MAX(windowRect.x, dockRect.x());
|
|
|
|
|
int ltY = MAX(windowRect.y, dockRect.y());
|
|
|
|
|
int rbX = MIN(windowRect.x + windowRect.width, dockRect.x() + dockRect.width());
|
|
|
|
|
int rbY = MIN(windowRect.y + windowRect.height, dockRect.y() + dockRect.height());
|
|
|
|
|
|
|
|
|
|
return (ltX < rbX) && (ltY < rbY);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::isWindowDockOverlapK 判断Wayland环境下窗口和任务栏是否重叠
|
|
|
|
|
* @param info
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool Dock::isWindowDockOverlapK(WindowInfoBase *info)
|
|
|
|
|
{
|
2022-05-19 13:13:55 +08:00
|
|
|
|
WindowInfoK *infoK = static_cast<WindowInfoK *>(info);
|
|
|
|
|
if (!infoK) {
|
|
|
|
|
qInfo() << "isWindowDockOverlapK: infoK is nullptr";
|
2022-04-24 14:52:13 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-26 13:06:53 +08:00
|
|
|
|
DockRect rect = infoK->getGeometry();
|
2022-05-19 13:13:55 +08:00
|
|
|
|
bool isActiveWin = infoK->getPlasmaWindow()->IsActive();
|
|
|
|
|
QString appId = infoK->getAppId();
|
|
|
|
|
if (!isActiveWin) {
|
|
|
|
|
qInfo() << "isWindowDockOverlapK: check window " << appId << " is not active";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-04-24 14:52:13 +08:00
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
QStringList appList = {"dde-desktop", "dde-lock", "dde-shutdown"};
|
|
|
|
|
if (appList.contains(appId)) {
|
|
|
|
|
qInfo() << "isWindowDockOverlapK: appId in white list";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return hasInterSectionK(rect, m_frontendWindowRect);
|
2022-05-19 13:13:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::hasInterSectionK Wayland环境下判断活动窗口和任务栏区域是否重叠
|
2022-05-24 21:49:47 +08:00
|
|
|
|
* @param windowRect 活动窗口
|
|
|
|
|
* @param dockRect 任务栏窗口
|
2022-05-19 13:13:55 +08:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-26 13:06:53 +08:00
|
|
|
|
bool Dock::hasInterSectionK(const DockRect &windowRect, QRect dockRect)
|
2022-05-19 13:13:55 +08:00
|
|
|
|
{
|
|
|
|
|
int position = getPosition();
|
|
|
|
|
int ltX = MAX(windowRect.X, dockRect.x());
|
|
|
|
|
int ltY = MAX(windowRect.Y, dockRect.y());
|
|
|
|
|
int rbX = MIN(windowRect.X + windowRect.Width, dockRect.x() + dockRect.width());
|
|
|
|
|
int rbY = MIN(windowRect.Y + windowRect.Height, dockRect.y() + dockRect.height());
|
|
|
|
|
|
|
|
|
|
if (position == int(PositionMode::Left) || position == int(PositionMode::Right)) {
|
|
|
|
|
return ltX <= rbX && ltY < rbY;
|
2022-05-26 13:06:53 +08:00
|
|
|
|
} else if (position == int(PositionMode::Top) || position == int(PositionMode::Bottom)) {
|
2022-05-19 13:13:55 +08:00
|
|
|
|
return ltX < rbX && ltY <= rbY;
|
|
|
|
|
} else {
|
|
|
|
|
return ltX < rbX && ltY < rbY;
|
|
|
|
|
}
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getDockedEntryByDesktopFile 获取应用实例
|
|
|
|
|
* @param desktopFile desktopFile文件全路径
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
Entry *Dock::getDockedEntryByDesktopFile(const QString &desktopFile)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_entries->getDockedEntryByDesktopFile(desktopFile);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::shouldHideOnSmartHideMode 判断智能隐藏模式下当前任务栏是否应该隐藏
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool Dock::shouldHideOnSmartHideMode()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (!m_activeWindow || m_ddeLauncherVisible)
|
2022-04-24 14:52:13 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (!m_isWayland) {
|
|
|
|
|
XWindow activeWinId = m_activeWindow->getXid();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
|
|
|
|
|
// dde launcher is invisible, but it is still active window
|
|
|
|
|
WMClass winClass = XCB->getWMClass(activeWinId);
|
|
|
|
|
if (winClass.instanceName.size() > 0 && winClass.instanceName.c_str() == ddeLauncherWMClass) {
|
|
|
|
|
qInfo() << "shouldHideOnSmartHideMode: active window is dde launcher";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVector<XWindow> list = getActiveWinGroup(activeWinId);
|
|
|
|
|
for (XWindow xid : list) {
|
2022-06-09 14:12:44 +08:00
|
|
|
|
if (isWindowDockOverlapX(xid)) {
|
|
|
|
|
qInfo() << "shouldHideOnSmartHideMode: window has overlap";
|
2022-04-24 14:52:13 +08:00
|
|
|
|
return true;
|
2022-06-09 14:12:44 +08:00
|
|
|
|
}
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-07-27 15:37:58 +08:00
|
|
|
|
|
|
|
|
|
return isWindowDockOverlapK(m_activeWindow);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getActiveWinGroup
|
|
|
|
|
* @param xid
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QVector<XWindow> Dock::getActiveWinGroup(XWindow xid)
|
|
|
|
|
{
|
|
|
|
|
QVector<XWindow> ret;
|
|
|
|
|
ret.push_back(xid);
|
|
|
|
|
|
|
|
|
|
std::list<XWindow> winList = XCB->getClientListStacking();
|
|
|
|
|
if (winList.empty()
|
|
|
|
|
|| !std::any_of(winList.begin(), winList.end(), [&](XWindow id) { return id == xid;}) // not found active window in clientListStacking"
|
|
|
|
|
|| *winList.begin() == 0) // root window
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
uint32_t apid = XCB->getWMPid(xid);
|
|
|
|
|
XWindow aleaderWin = XCB->getWMClientLeader(xid);
|
|
|
|
|
for (auto winId : winList) {
|
|
|
|
|
if (winId == xid)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
uint32_t pid = XCB->getWMPid(winId);
|
|
|
|
|
// same pid
|
|
|
|
|
if (apid != 0 && pid == apid) {
|
|
|
|
|
// ok
|
|
|
|
|
ret.push_back(winId);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WMClass wmClass = XCB->getWMClass(winId);
|
|
|
|
|
// same wmclass
|
|
|
|
|
if (wmClass.className.size() > 0 && wmClass.className.c_str() == frontendWindowWmClass) {
|
|
|
|
|
// skip over fronted window
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t leaderWin = XCB->getWMClientLeader(winId);
|
|
|
|
|
// same leaderWin
|
|
|
|
|
if (aleaderWin != 0 && aleaderWin == leaderWin) {
|
|
|
|
|
// ok
|
|
|
|
|
ret.push_back(winId);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// above window
|
|
|
|
|
XWindow aboveWinId = 0;
|
|
|
|
|
for (auto iter = winList.begin(); iter != winList.end(); iter++) {
|
|
|
|
|
if (*iter == winId) {
|
|
|
|
|
aboveWinId = *++iter;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (aboveWinId == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
XWindow aboveWinTransientFor = XCB->getWMTransientFor(aboveWinId);
|
|
|
|
|
if (aboveWinTransientFor != 0 && aboveWinTransientFor == winId) {
|
|
|
|
|
// ok
|
|
|
|
|
ret.push_back(winId);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::updateHideState 更新任务栏隐藏状态
|
|
|
|
|
* @param delay
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::updateHideState(bool delay)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (m_ddeLauncherVisible) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
qInfo() << "updateHideState: dde launcher is visible, show dock";
|
2022-05-24 21:49:47 +08:00
|
|
|
|
setPropHideState(HideState::Show);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HideMode mode = SETTING->getHideMode();
|
|
|
|
|
switch (mode) {
|
|
|
|
|
case HideMode::KeepShowing:
|
2022-05-24 21:49:47 +08:00
|
|
|
|
setPropHideState(HideState::Show);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
break;
|
|
|
|
|
case HideMode::KeepHidden:
|
2022-05-24 21:49:47 +08:00
|
|
|
|
setPropHideState(HideState::Hide);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
break;
|
|
|
|
|
case HideMode::SmartHide:
|
|
|
|
|
qInfo() << "reset smart hide mode timer " << delay;
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_smartHideTimer->start(delay ? smartHideTimerDelay : 0);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setPropHideMode 设置隐藏属性
|
|
|
|
|
* @param state
|
|
|
|
|
*/
|
2022-05-24 21:49:47 +08:00
|
|
|
|
void Dock::setPropHideState(HideState state)
|
2022-04-24 14:52:13 +08:00
|
|
|
|
{
|
|
|
|
|
if (state == HideState::Unknown) {
|
|
|
|
|
qInfo() << "setPropHideState: unknown mode";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (state != m_hideState) {
|
|
|
|
|
m_hideState = state;
|
|
|
|
|
Q_EMIT hideStateChanged(static_cast<int>(m_hideState));
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::attachOrDetachWindow 关联或分离窗口
|
|
|
|
|
* @param info
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::attachOrDetachWindow(WindowInfoBase *info)
|
|
|
|
|
{
|
|
|
|
|
if (!info)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
XWindow winId = info->getXid();
|
|
|
|
|
bool shouldDock = shouldShowOnDock(info);
|
|
|
|
|
qInfo() << "attachOrDetachWindow: shouldDock " << shouldDock;
|
|
|
|
|
|
|
|
|
|
// 顺序解析窗口合并或分离操作
|
2022-08-04 21:22:22 +08:00
|
|
|
|
QMutexLocker locker(&m_windowOperateMutex);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
Entry *entry = info->getEntry();
|
|
|
|
|
if (entry) {
|
|
|
|
|
// detach
|
|
|
|
|
if (!shouldDock)
|
|
|
|
|
detachWindow(info);
|
|
|
|
|
else
|
|
|
|
|
qInfo() << "detach operate: window " << winId << "don't need to detach";
|
|
|
|
|
} else {
|
|
|
|
|
// attach
|
|
|
|
|
if (info->getEntryInnerId().isEmpty()) {
|
2022-05-26 18:10:53 +08:00
|
|
|
|
// 窗口entryInnerId为空表示未识别,需要识别窗口并创建entryInnerId
|
2022-04-24 14:52:13 +08:00
|
|
|
|
qInfo() << "attach operate: window " << winId << " entryInnerId is empty, now call IdentifyWindow";
|
|
|
|
|
QString innerId;
|
2022-08-04 21:22:22 +08:00
|
|
|
|
AppInfo *appInfo = m_windowIdentify->identifyWindow(info, innerId);
|
2022-05-26 18:10:53 +08:00
|
|
|
|
// 窗口entryInnerId即AppInfo的innerId, 用来将窗口和应用绑定关系
|
|
|
|
|
info->setEntryInnerId(innerId);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
info->setAppInfo(appInfo);
|
|
|
|
|
markAppLaunched(appInfo);
|
|
|
|
|
} else {
|
|
|
|
|
qInfo() << "attach operate: window " << winId << "has been identified";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// winInfo初始化后影响判断是否在任务栏显示图标,需判断
|
|
|
|
|
if (shouldShowOnDock(info))
|
|
|
|
|
attachWindow(info);
|
|
|
|
|
}
|
2022-08-08 13:20:42 +08:00
|
|
|
|
|
|
|
|
|
// 在新增窗口后,同步最近打开应用到com.deepin.dde.dock.json的DConfig配置文件中
|
|
|
|
|
updateRecentApps();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::attachWindow 关联窗口
|
|
|
|
|
* @param info 窗口信息
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::attachWindow(WindowInfoBase *info)
|
|
|
|
|
{
|
2022-05-24 21:49:47 +08:00
|
|
|
|
// TODO: entries中存在innerid为空的entry, 导致后续新应用通过innerid获取应用一直能获取到
|
2022-08-04 21:22:22 +08:00
|
|
|
|
Entry *entry = m_entries->getByInnerId(info->getEntryInnerId());
|
2022-04-24 14:52:13 +08:00
|
|
|
|
if (entry) {
|
|
|
|
|
// entry existed
|
|
|
|
|
entry->attachWindow(info);
|
|
|
|
|
} else {
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_entries->removeLastRecent();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
entry = new Entry(this, info->getAppInfo(), info->getEntryInnerId());
|
|
|
|
|
if (entry->attachWindow(info)) {
|
|
|
|
|
entry->startExport();
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_entries->append(entry);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::detachWindow 分离窗口
|
|
|
|
|
* @param info 窗口信息
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::detachWindow(WindowInfoBase *info)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
Entry *entry = m_entries->getByWindowId(info->getXid());
|
2022-04-24 14:52:13 +08:00
|
|
|
|
if (!entry)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool needRemove = entry->detachWindow(info);
|
2022-08-08 13:20:42 +08:00
|
|
|
|
if (needRemove) {
|
|
|
|
|
// 如果是最近打开应用
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (m_entries->shouldInRecent()) {
|
2022-08-08 13:20:42 +08:00
|
|
|
|
// 更新entry的导出窗口信息
|
|
|
|
|
entry->updateExportWindowInfos();
|
|
|
|
|
// 更新entry的右键菜单的信息
|
|
|
|
|
entry->updateMenu();
|
|
|
|
|
// 更新entry的当前窗口的信息
|
|
|
|
|
entry->setCurrentWindowInfo(nullptr);
|
|
|
|
|
// 移除应用后,同时更新最近打开的应用
|
|
|
|
|
updateRecentApps();
|
2022-08-04 21:22:22 +08:00
|
|
|
|
// 如果是高效模式,则发送消息或者关闭了显示最近应用的功能,则从任务栏移除
|
|
|
|
|
if (SETTING->getDisplayMode() == DisplayMode::Efficient
|
|
|
|
|
|| !m_showRecent) {
|
2022-08-08 13:20:42 +08:00
|
|
|
|
Q_EMIT entryRemoved(entry->getId());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
removeAppEntry(entry);
|
|
|
|
|
// 移除应用后,同时更新最近打开的应用
|
|
|
|
|
updateRecentApps();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::launchApp 启动应用
|
|
|
|
|
* @param timestamp 时间
|
|
|
|
|
* @param files 应用打开文件
|
|
|
|
|
*/
|
2022-05-24 21:49:47 +08:00
|
|
|
|
void Dock::launchApp(const QString desktopFile, uint32_t timestamp, QStringList files)
|
2022-04-24 14:52:13 +08:00
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_dbusHandler->launchApp(desktopFile, timestamp, files);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::launchAppAction 启动应用响应
|
|
|
|
|
* @param timestamp
|
|
|
|
|
* @param file
|
|
|
|
|
* @param section
|
|
|
|
|
*/
|
2022-05-24 21:49:47 +08:00
|
|
|
|
void Dock::launchAppAction(const QString desktopFile, QString action, uint32_t timestamp)
|
2022-04-24 14:52:13 +08:00
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_dbusHandler->launchAppAction(desktopFile, action, timestamp);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::is3DWM 当前窗口模式 2D/3D
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool Dock::is3DWM()
|
|
|
|
|
{
|
|
|
|
|
bool ret = false;
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (m_wmName.isEmpty())
|
|
|
|
|
m_wmName = m_dbusHandler->getCurrentWM();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
if (m_wmName == "deepin wm")
|
2022-04-24 14:52:13 +08:00
|
|
|
|
ret = true;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::isWaylandEnv 当前环境
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
bool Dock::isWaylandEnv()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_isWayland;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::handleActiveWindowChangedK 处理活动窗口改变事件 wayland环境
|
|
|
|
|
* @param activeWin
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
WindowInfoK *Dock::handleActiveWindowChangedK(uint activeWin)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_waylandManager->handleActiveWindowChangedK(activeWin);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::handleActiveWindowChanged 处理活动窗口改变事件 X11环境
|
|
|
|
|
* @param info
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::handleActiveWindowChanged(WindowInfoBase *info)
|
|
|
|
|
{
|
|
|
|
|
qInfo() << "handleActiveWindowChanged";
|
|
|
|
|
if (!info) {
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_activeWindowOld = info;
|
|
|
|
|
m_activeWindow = nullptr;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_activeWindow = info;
|
|
|
|
|
XWindow winId = m_activeWindow->getXid();
|
|
|
|
|
m_entries->handleActiveWindowChanged(winId);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
updateHideState(true);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::saveDockedApps 保存驻留应用信息
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::saveDockedApps()
|
|
|
|
|
{
|
2022-08-08 13:20:42 +08:00
|
|
|
|
QStringList dockedApps;
|
2022-08-04 21:22:22 +08:00
|
|
|
|
for (auto entry : m_entries->filterDockedEntries()) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QString path = entry->getApp()->getFileName();
|
2022-08-08 13:20:42 +08:00
|
|
|
|
dockedApps << path;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
2022-08-08 13:20:42 +08:00
|
|
|
|
|
2022-04-24 14:52:13 +08:00
|
|
|
|
SETTING->setDockedApps(dockedApps);
|
2022-08-08 13:20:42 +08:00
|
|
|
|
|
|
|
|
|
// 在驻留任务栏的时候,同时更新最近打开应用的信息
|
|
|
|
|
updateRecentApps();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Dock::updateRecentApps()
|
|
|
|
|
{
|
|
|
|
|
QStringList unDockedApps;
|
2022-08-04 21:22:22 +08:00
|
|
|
|
QList<Entry *> recentEntrys = m_entries->unDockedEntries();
|
2022-08-08 13:20:42 +08:00
|
|
|
|
for (Entry *entry : recentEntrys) {
|
|
|
|
|
QString path = entry->getApp()->getFileName();
|
|
|
|
|
unDockedApps << path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保存未驻留的应用作为最近打开的应用
|
|
|
|
|
SETTING->setRecentApps(unDockedApps);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 21:22:22 +08:00
|
|
|
|
void Dock::onShowRecentChanged(bool visible)
|
|
|
|
|
{
|
|
|
|
|
if (m_showRecent == visible)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_showRecent = visible;
|
|
|
|
|
m_entries->updateShowRecent();
|
|
|
|
|
Q_EMIT showRecentChanged(visible);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-27 15:37:58 +08:00
|
|
|
|
void Dock::onShowMultiWindowChanged(bool visible)
|
|
|
|
|
{
|
|
|
|
|
if (m_showMultiWindow == visible)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_showMultiWindow = visible;
|
|
|
|
|
Q_EMIT showMultiWindowChanged(visible);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/** 移除应用实例
|
|
|
|
|
* @brief Dock::removeAppEntry
|
|
|
|
|
* @param entry
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::removeAppEntry(Entry *entry)
|
|
|
|
|
{
|
|
|
|
|
if (entry) {
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_entries->remove(entry);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::handleWindowGeometryChanged 智能隐藏模式下窗口矩形变化,同步更新任务栏隐藏状态
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::handleWindowGeometryChanged()
|
|
|
|
|
{
|
|
|
|
|
if (SETTING->getHideMode() == HideMode::SmartHide)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
updateHideState(false);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getEntryByWindowId 根据窗口id获取应用实例
|
|
|
|
|
* @param windowId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
Entry *Dock::getEntryByWindowId(XWindow windowId)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_entries->getByWindowId(windowId);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getDesktopFromWindowByBamf 通过bamf软件服务获取指定窗口的desktop文件
|
|
|
|
|
* @param windowId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QString Dock::getDesktopFromWindowByBamf(XWindow windowId)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_dbusHandler->getDesktopFromWindowByBamf(windowId);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::registerWindowWayland 注册wayland窗口
|
|
|
|
|
* @param objPath
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::registerWindowWayland(const QString &objPath)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_waylandManager->registerWindow(objPath);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::unRegisterWindowWayland 取消注册wayland窗口
|
|
|
|
|
* @param objPath
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::unRegisterWindowWayland(const QString &objPath)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_waylandManager->unRegisterWindow(objPath);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::isShowingDesktop
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
bool Dock::isShowingDesktop()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_dbusHandler->wlShowingDesktop();
|
2022-05-24 21:49:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::identifyWindow 识别窗口
|
|
|
|
|
* @param winInfo
|
|
|
|
|
* @param innerId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
AppInfo *Dock::identifyWindow(WindowInfoBase *winInfo, QString &innerId)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_windowIdentify->identifyWindow(winInfo, innerId);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::markAppLaunched 标识应用已启动
|
|
|
|
|
* @param appInfo
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::markAppLaunched(AppInfo *appInfo)
|
|
|
|
|
{
|
|
|
|
|
if (!appInfo || !appInfo->isValidApp())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QString desktopFile = appInfo->getFileName();
|
|
|
|
|
qInfo() << "markAppLaunched: desktopFile is " << desktopFile;
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_dbusHandler->markAppLaunched(desktopFile);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getForceQuitAppStatus 获取强制关闭应用状态
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
ForceQuitAppMode Dock::getForceQuitAppStatus()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_forceQuitAppStatus;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getWinIconPreferredApps 获取推荐的应用窗口图标
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QVector<QString> Dock::getWinIconPreferredApps()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getWinIconPreferredApps();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::handleLauncherItemDeleted 处理launcher item被删除信号
|
|
|
|
|
* @param itemPath
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::handleLauncherItemDeleted(QString itemPath)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
for (auto entry : m_entries->filterDockedEntries()) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
if (entry->getFileName() == itemPath) {
|
|
|
|
|
undockEntry(entry);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::handleLauncherItemUpdated 在收到 launcher item 更新的信号后,需要更新相关信息,包括 appInfo、innerId、名称、图标、菜单。
|
|
|
|
|
* @param itemPath
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::handleLauncherItemUpdated(QString itemPath)
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
Entry *entry = m_entries->getByDesktopFilePath(itemPath);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
if (!entry)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
AppInfo *app = new AppInfo(itemPath);
|
|
|
|
|
entry->setApp(app);
|
|
|
|
|
entry->setInnerId(app->getInnerId());
|
|
|
|
|
entry->updateName();
|
|
|
|
|
entry->updateMenu();
|
|
|
|
|
entry->forceUpdateIcon(); // 可能存在Icon图片改变,但Icon名称未改变的情况,因此强制发Icon的属性改变信号
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getOpacity 获取透明度
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
double Dock::getOpacity()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getOpacity();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getFrontendWindowRect 获取任务栏rect
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QRect Dock::getFrontendWindowRect()
|
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_frontendWindowRect;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getDisplayMode 获取显示模式
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
int Dock::getDisplayMode()
|
|
|
|
|
{
|
|
|
|
|
return int(SETTING->getDisplayMode());
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setDisplayMode 设置显示模式
|
|
|
|
|
* @param mode
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setDisplayMode(int mode)
|
|
|
|
|
{
|
2022-08-08 13:20:42 +08:00
|
|
|
|
DisplayMode displayMode = static_cast<DisplayMode>(mode);
|
|
|
|
|
SETTING->setDisplayMode(displayMode);
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_entries->setDisplayMode(displayMode);
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getDockedApps 获取驻留应用
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QStringList Dock::getDockedApps()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getDockedApps();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getEntryPaths 获取应用实例路径
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
QStringList Dock::getEntryPaths()
|
|
|
|
|
{
|
|
|
|
|
QStringList ret;
|
2022-08-04 21:22:22 +08:00
|
|
|
|
for (auto id : m_entries->getEntryIDs()) {
|
2022-04-24 14:52:13 +08:00
|
|
|
|
ret.push_back(entryDBusObjPathPrefix + id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getHideMode 获取隐藏模式
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
HideMode Dock::getHideMode()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getHideMode();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setHideMode 设置隐藏模式
|
|
|
|
|
* @param mode
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setHideMode(HideMode mode)
|
|
|
|
|
{
|
|
|
|
|
SETTING->setHideMode(mode);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getHideState 获取隐藏状态
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-24 21:49:47 +08:00
|
|
|
|
HideState Dock::getHideState()
|
2022-04-24 14:52:13 +08:00
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
return m_hideState;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setHideState 设置任务栏隐藏状态
|
|
|
|
|
* @param state
|
|
|
|
|
*/
|
2022-05-24 21:49:47 +08:00
|
|
|
|
void Dock::setHideState(HideState state)
|
2022-04-24 14:52:13 +08:00
|
|
|
|
{
|
2022-08-04 21:22:22 +08:00
|
|
|
|
m_hideState = state;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getHideTimeout 获取执行隐藏动作超时时间
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
uint Dock::getHideTimeout()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getHideTimeout();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setHideTimeout 设置执行隐藏动作超时时间
|
|
|
|
|
* @param timeout
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setHideTimeout(uint timeout)
|
|
|
|
|
{
|
|
|
|
|
SETTING->setHideTimeout(timeout);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getIconSize 获取应用图标大小
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
uint Dock::getIconSize()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getIconSize();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setIconSize 设置应用图标大小
|
|
|
|
|
* @param size
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setIconSize(uint size)
|
|
|
|
|
{
|
|
|
|
|
SETTING->setIconSize(size);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getPosition 获取当前任务栏位置
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
int Dock::getPosition()
|
|
|
|
|
{
|
|
|
|
|
return int(SETTING->getPositionMode());
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setPosition 设置任务栏位置
|
|
|
|
|
* @param position
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setPosition(int position)
|
|
|
|
|
{
|
2022-05-19 13:13:55 +08:00
|
|
|
|
SETTING->setPositionMode(PositionMode(position));
|
2022-04-24 14:52:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getShowTimeout 获取显示超时接口
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
uint Dock::getShowTimeout()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getShowTimeout();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setShowTimeout 设置显示超时
|
|
|
|
|
* @param timeout
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setShowTimeout(uint timeout)
|
|
|
|
|
{
|
|
|
|
|
return SETTING->setShowTimeout(timeout);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getWindowSizeEfficient 获取任务栏高效模式大小
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
uint Dock::getWindowSizeEfficient()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getWindowSizeEfficient();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setWindowSizeEfficient 设置任务栏高效模式大小
|
|
|
|
|
* @param size
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setWindowSizeEfficient(uint size)
|
|
|
|
|
{
|
|
|
|
|
SETTING->setWindowSizeEfficient(size);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::getWindowSizeFashion 获取任务栏时尚模式大小
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
uint Dock::getWindowSizeFashion()
|
|
|
|
|
{
|
|
|
|
|
return SETTING->getWindowSizeFashion();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:13:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Dock::setWindowSizeFashion 设置任务栏时尚模式大小
|
|
|
|
|
* @param size
|
|
|
|
|
*/
|
2022-04-24 14:52:13 +08:00
|
|
|
|
void Dock::setWindowSizeFashion(uint size)
|
|
|
|
|
{
|
|
|
|
|
SETTING->setWindowSizeFashion(size);
|
|
|
|
|
}
|
|
|
|
|
|