feat: 增加设置任务栏是否开启窗口多开的接口

增加接口setShowMultiWindow和showMultiWindow接口,用于设置和返回任务栏是否支持窗口多开的功能

Log: 增加设置任务栏是否开启窗口多开的功能
Influence: 控制中心-个性化-任务栏,设置开启或者关闭任务栏支持窗口多开,观察任务栏相同的应用打开多个窗口的情况下,是否在多开区域存在多开的窗口
Task: https://pms.uniontech.com/task-view-170977.html
Change-Id: I208aba19f3ab94a02f72e64d0d4eeb1e83a7a6bf
This commit is contained in:
donghualin 2022-07-27 07:37:58 +00:00
parent fd19bc4cf2
commit 2a44cac44a
12 changed files with 129 additions and 4 deletions

View File

@ -161,6 +161,16 @@
"description": "show or hide recent app in dock", "description": "show or hide recent app in dock",
"permissions": "readwrite", "permissions": "readwrite",
"visibility": "private" "visibility": "private"
},
"Show_MultiWindow": {
"value": false,
"serial": 0,
"flags": [],
"name": "Show_MultiWindow",
"name[zh_CN]": "*****",
"description": "show or hide Multi Window in dock when the Entry has subWindow",
"permissions": "readwrite",
"visibility": "private"
} }
} }
} }

View File

@ -43,6 +43,7 @@ const QString keyPluginSettings = "Plugin_Settings";
const QString keyForceQuitApp = "Force_Quit_App"; const QString keyForceQuitApp = "Force_Quit_App";
const QString keyRecentApp = "Recent_App"; const QString keyRecentApp = "Recent_App";
const QString keyShowRecent = "Show_Recent"; const QString keyShowRecent = "Show_Recent";
const QString keyShowMultiWindow = "Show_MultiWindow";
const QString scratchDir = QDir::homePath() + "/.local/dock/scratch/"; const QString scratchDir = QDir::homePath() + "/.local/dock/scratch/";

View File

@ -35,6 +35,7 @@ DBusAdaptorDock::DBusAdaptorDock(QObject *parent)
connect(dock, &Dock::hideStateChanged, this, &DBusAdaptorDock::HideStateChanged); connect(dock, &Dock::hideStateChanged, this, &DBusAdaptorDock::HideStateChanged);
connect(dock, &Dock::frontendWindowRectChanged, this, &DBusAdaptorDock::FrontendWindowRectChanged); connect(dock, &Dock::frontendWindowRectChanged, this, &DBusAdaptorDock::FrontendWindowRectChanged);
connect(dock, &Dock::showRecentChanged, this, &DBusAdaptorDock::showRecentChanged); connect(dock, &Dock::showRecentChanged, this, &DBusAdaptorDock::showRecentChanged);
connect(dock, &Dock::showMultiWindowChanged, this, &DBusAdaptorDock::ShowMultiWindowChanged);
} }
} }
@ -180,6 +181,11 @@ bool DBusAdaptorDock::showRecent() const
return parent()->showRecent(); return parent()->showRecent();
} }
bool DBusAdaptorDock::showMultiWindow() const
{
return parent()->showMultiWindow();
}
Dock *DBusAdaptorDock::parent() const Dock *DBusAdaptorDock::parent() const
{ {
return static_cast<Dock *>(QObject::parent()); return static_cast<Dock *>(QObject::parent());
@ -256,6 +262,11 @@ void DBusAdaptorDock::SetShowRecent(bool visible)
parent()->setShowRecent(visible); parent()->setShowRecent(visible);
} }
void DBusAdaptorDock::SetShowMultiWindow(bool showMultiWindow)
{
parent()->setShowMultiWindow(showMultiWindow);
}
void DBusAdaptorDock::SetFrontendWindowRect(int x, int y, uint width, uint height) void DBusAdaptorDock::SetFrontendWindowRect(int x, int y, uint width, uint height)
{ {
parent()->setFrontendWindowRect(x, y, width, height); parent()->setFrontendWindowRect(x, y, width, height);

View File

@ -96,6 +96,9 @@ class DBusAdaptorDock: public QDBusAbstractAdaptor
" <method name=\"SetShowRecent\">\n" " <method name=\"SetShowRecent\">\n"
" <arg direction=\"in\" type=\"b\" name=\"visible\"/>\n" " <arg direction=\"in\" type=\"b\" name=\"visible\"/>\n"
" </method>\n" " </method>\n"
" <method name=\"SetShowMultiWindow\">\n"
" <arg direction=\"in\" type=\"b\" name=\"visible\"/>\n"
" </method>\n"
" <method name=\"SetFrontendWindowRect\">\n" " <method name=\"SetFrontendWindowRect\">\n"
" <arg direction=\"in\" type=\"i\" name=\"x\"/>\n" " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
" <arg direction=\"in\" type=\"i\" name=\"y\"/>\n" " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
@ -124,6 +127,7 @@ class DBusAdaptorDock: public QDBusAbstractAdaptor
" <property access=\"readwrite\" type=\"u\" name=\"IconSize\"/>\n" " <property access=\"readwrite\" type=\"u\" name=\"IconSize\"/>\n"
" <property access=\"read\" type=\"as\" name=\"DockedApps\"/>\n" " <property access=\"read\" type=\"as\" name=\"DockedApps\"/>\n"
" <property access=\"read\" type=\"b\" name=\"ShowRecent\"/>\n" " <property access=\"read\" type=\"b\" name=\"ShowRecent\"/>\n"
" <property access=\"read\" type=\"b\" name=\"ShowMultiWindow\"/>\n"
" </interface>\n" " </interface>\n"
"") "")
public: public:
@ -181,6 +185,9 @@ public: // PROPERTIES
Q_PROPERTY(bool ShowRecent READ showRecent NOTIFY showRecentChanged) Q_PROPERTY(bool ShowRecent READ showRecent NOTIFY showRecentChanged)
bool showRecent() const; bool showRecent() const;
Q_PROPERTY(bool ShowMultiWindow READ showMultiWindow NOTIFY ShowMultiWindowChanged)
bool showMultiWindow() const;
Dock *parent() const; Dock *parent() const;
public Q_SLOTS: // METHODS public Q_SLOTS: // METHODS
@ -198,6 +205,7 @@ public Q_SLOTS: // METHODS
bool RequestDock(const QString &desktopFile, int index); bool RequestDock(const QString &desktopFile, int index);
bool RequestUndock(const QString &desktopFile); bool RequestUndock(const QString &desktopFile);
void SetShowRecent(bool visible); void SetShowRecent(bool visible);
void SetShowMultiWindow(bool showMultiWindow);
void SetFrontendWindowRect(int x, int y, uint width, uint height); void SetFrontendWindowRect(int x, int y, uint width, uint height);
Q_SIGNALS: // SIGNALS Q_SIGNALS: // SIGNALS
@ -219,6 +227,7 @@ Q_SIGNALS: // SIGNALS
void WindowSizeEfficientChanged(uint value) const; void WindowSizeEfficientChanged(uint value) const;
void WindowSizeFashionChanged(uint value) const; void WindowSizeFashionChanged(uint value) const;
void showRecentChanged(bool) const; void showRecentChanged(bool) const;
void ShowMultiWindowChanged(bool) const;
}; };
#endif #endif

View File

@ -122,6 +122,11 @@ void DBusAdaptorEntry::ForceQuit()
parent()->forceQuit(); parent()->forceQuit();
} }
void DBusAdaptorEntry::ActiveWindow(quint32 winId)
{
parent()->activeWindow(winId);
}
QList<QVariant> DBusAdaptorEntry::GetAllowedCloseWindows() QList<QVariant> DBusAdaptorEntry::GetAllowedCloseWindows()
{ {
auto ids = parent()->getAllowedClosedWindowIds(); auto ids = parent()->getAllowedClosedWindowIds();

View File

@ -52,6 +52,9 @@ class DBusAdaptorEntry: public QDBusAbstractAdaptor
" </method>\n" " </method>\n"
" <method name=\"Check\"/>\n" " <method name=\"Check\"/>\n"
" <method name=\"ForceQuit\"/>\n" " <method name=\"ForceQuit\"/>\n"
" <method name=\"ActiveWindow\">\n"
" <arg direction=\"in\" type=\"u\" name=\"winId\"/>\n"
" </method>\n"
" <method name=\"GetAllowedCloseWindows\">\n" " <method name=\"GetAllowedCloseWindows\">\n"
" <arg direction=\"out\" type=\"au\" name=\"windows\"/>\n" " <arg direction=\"out\" type=\"au\" name=\"windows\"/>\n"
" </method>\n" " </method>\n"
@ -124,6 +127,7 @@ public Q_SLOTS: // METHODS
void Activate(uint timestamp); void Activate(uint timestamp);
void Check(); void Check();
void ForceQuit(); void ForceQuit();
void ActiveWindow(quint32 winId);
QList<QVariant> GetAllowedCloseWindows(); QList<QVariant> GetAllowedCloseWindows();
void HandleDragDrop(uint timestamp, const QStringList &files); void HandleDragDrop(uint timestamp, const QStringList &files);
void HandleMenuItem(uint timestamp, const QString &id); void HandleMenuItem(uint timestamp, const QString &id);

View File

@ -50,6 +50,8 @@ Dock::Dock(QObject *parent)
, m_activeWindowOld(nullptr) , m_activeWindowOld(nullptr)
, m_dbusHandler(new DBusHandler(this)) , m_dbusHandler(new DBusHandler(this))
, m_windowOperateMutex(QMutex(QMutex::NonRecursive)) , m_windowOperateMutex(QMutex(QMutex::NonRecursive))
, m_showRecent(false)
, m_showMultiWindow(false)
{ {
registeModule("dock"); registeModule("dock");
@ -199,8 +201,8 @@ void Dock::undockEntry(Entry *entry, bool moveToEnd)
{ {
if (!entry->getIsDocked()) { if (!entry->getIsDocked()) {
qInfo() << "undockEntry: " << entry->getId() << " is not docked"; qInfo() << "undockEntry: " << entry->getId() << " is not docked";
// 在当前未驻留的情况下执行取消驻留操作,则让其直接从当前列表中移除 // 当应用图标在最近打开区域的时候,此时该应用是未驻留的应用,如果该最近打开应用没有打开窗口,将这个图标
// 这种情况一般是在从最近打开应用中拖动应用到回收站的时候执行的操作 // 拖动到回收站了此时调用的是undock方法根据需求需要将该图标删除
if (!entry->hasWindow()) { if (!entry->hasWindow()) {
// 没有子窗口的情况下,从列表中移除 // 没有子窗口的情况下,从列表中移除
removeAppEntry(entry); removeAppEntry(entry);
@ -574,6 +576,20 @@ bool Dock::showRecent() const
return m_showRecent; return m_showRecent;
} }
void Dock::setShowMultiWindow(bool visible)
{
if (m_showMultiWindow == visible)
return;
SETTING->setShowMultiWindow(visible);
onShowMultiWindowChanged(visible);
}
bool Dock::showMultiWindow() const
{
return m_showMultiWindow;
}
/** /**
* @brief Dock::moveEntry * @brief Dock::moveEntry
* @param oldIndex * @param oldIndex
@ -688,6 +704,7 @@ void Dock::initSettings()
m_entries->updateEntriesMenu(); m_entries->updateEntriesMenu();
}); });
connect(SETTING, &DockSettings::showRecentChanged, this, &Dock::onShowRecentChanged); connect(SETTING, &DockSettings::showRecentChanged, this, &Dock::onShowRecentChanged);
connect(SETTING, &DockSettings::showMultiWindowChanged, this, &Dock::onShowMultiWindowChanged);
} }
/** /**
@ -706,6 +723,8 @@ void Dock::loadAppInfos()
{ {
// 读取是否显示最近打开应用 // 读取是否显示最近打开应用
m_showRecent = SETTING->showRecent(); m_showRecent = SETTING->showRecent();
// 读取是否显示多开窗口拆分
m_showMultiWindow = SETTING->showMultiWindow();
// 初始化驻留应用信息和最近使用的应用的信息 // 初始化驻留应用信息和最近使用的应用的信息
auto loadApps = [ this ](const QStringList &apps, bool isDocked) { auto loadApps = [ this ](const QStringList &apps, bool isDocked) {
for (const QString &app : apps) { for (const QString &app : apps) {
@ -717,6 +736,7 @@ void Dock::loadAppInfos()
AppInfo *appInfo = new AppInfo(info); AppInfo *appInfo = new AppInfo(info);
Entry *entryObj = new Entry(this, appInfo, appInfo->getInnerId()); Entry *entryObj = new Entry(this, appInfo, appInfo->getInnerId());
entryObj->setIsDocked(isDocked); entryObj->setIsDocked(isDocked);
entryObj->updateMode();
entryObj->updateMenu(); entryObj->updateMenu();
entryObj->startExport(); entryObj->startExport();
m_entries->append(entryObj); m_entries->append(entryObj);
@ -927,9 +947,9 @@ bool Dock::shouldHideOnSmartHideMode()
} }
} }
return false; return false;
} else {
return isWindowDockOverlapK(m_activeWindow);
} }
return isWindowDockOverlapK(m_activeWindow);
} }
/** /**
@ -1260,6 +1280,15 @@ void Dock::onShowRecentChanged(bool visible)
Q_EMIT showRecentChanged(visible); Q_EMIT showRecentChanged(visible);
} }
void Dock::onShowMultiWindowChanged(bool visible)
{
if (m_showMultiWindow == visible)
return;
m_showMultiWindow = visible;
Q_EMIT showMultiWindowChanged(visible);
}
/** 移除应用实例 /** 移除应用实例
* @brief Dock::removeAppEntry * @brief Dock::removeAppEntry
* @param entry * @param entry

View File

@ -135,6 +135,8 @@ public:
bool requestUndock(QString desktopFile); bool requestUndock(QString desktopFile);
void setShowRecent(bool visible); void setShowRecent(bool visible);
bool showRecent() const; bool showRecent() const;
void setShowMultiWindow(bool visible);
bool showMultiWindow() const;
void moveEntry(int oldIndex, int newIndex); void moveEntry(int oldIndex, int newIndex);
bool isOnDock(QString desktopFile); bool isOnDock(QString desktopFile);
QString queryWindowIdentifyMethod(XWindow windowId); QString queryWindowIdentifyMethod(XWindow windowId);
@ -151,6 +153,7 @@ Q_SIGNALS:
void hideStateChanged(int); void hideStateChanged(int);
void frontendWindowRectChanged(); void frontendWindowRectChanged();
void showRecentChanged(bool); void showRecentChanged(bool);
void showMultiWindowChanged(bool);
public Q_SLOTS: public Q_SLOTS:
void updateHideState(bool delay); void updateHideState(bool delay);
@ -176,6 +179,7 @@ private:
private: private:
void onShowRecentChanged(bool visible); void onShowRecentChanged(bool visible);
void onShowMultiWindowChanged(bool visible);
private: private:
WindowIdentify *m_windowIdentify; // 窗口识别 WindowIdentify *m_windowIdentify; // 窗口识别
@ -196,6 +200,7 @@ private:
DBusHandler *m_dbusHandler; // 处理dbus交互 DBusHandler *m_dbusHandler; // 处理dbus交互
QMutex m_windowOperateMutex; // 窗口合并或拆分锁 QMutex m_windowOperateMutex; // 窗口合并或拆分锁
bool m_showRecent; bool m_showRecent;
bool m_showMultiWindow;
}; };
#endif // DOCK_H #endif // DOCK_H

View File

@ -54,6 +54,8 @@ void DockSettings::init()
Q_EMIT forceQuitAppChanged(ForceQuitAppModeHandler(mode).toEnum()); Q_EMIT forceQuitAppChanged(ForceQuitAppModeHandler(mode).toEnum());
} else if (key == keyShowRecent) { } else if (key == keyShowRecent) {
Q_EMIT showRecentChanged(m_dockSettings->value(key).toBool()); Q_EMIT showRecentChanged(m_dockSettings->value(key).toBool());
} else if (key == keyShowMultiWindow) {
Q_EMIT showMultiWindowChanged(m_dockSettings->value(key).toBool());
} }
}); });
} }
@ -291,6 +293,22 @@ bool DockSettings::showRecent() const
return m_dockSettings->value(keyShowRecent).toBool(); return m_dockSettings->value(keyShowRecent).toBool();
} }
void DockSettings::setShowMultiWindow(bool showMultiWindow)
{
if (!m_dockSettings)
return;
m_dockSettings->setValue(keyShowMultiWindow, showMultiWindow);
}
bool DockSettings::showMultiWindow() const
{
if (!m_dockSettings)
return false;
return m_dockSettings->value(keyShowMultiWindow).toBool();
}
QString DockSettings::getPluginSettings() QString DockSettings::getPluginSettings()
{ {
QString ret; QString ret;

View File

@ -238,6 +238,9 @@ public:
void setShowRecent(bool visible); void setShowRecent(bool visible);
bool showRecent() const; bool showRecent() const;
void setShowMultiWindow(bool showMultiWindow);
bool showMultiWindow() const;
// plugin settings // plugin settings
QString getPluginSettings(); QString getPluginSettings();
void setPluginSettings(QString jsonStr); void setPluginSettings(QString jsonStr);
@ -256,6 +259,8 @@ Q_SIGNALS:
void forceQuitAppChanged(ForceQuitAppMode mode); void forceQuitAppChanged(ForceQuitAppMode mode);
// 是否显示最近打开应用改变 // 是否显示最近打开应用改变
void showRecentChanged(bool); void showRecentChanged(bool);
// 是否显示多开应用改变
void showMultiWindowChanged(bool);
private: private:
DockSettings(QObject *paret = nullptr); DockSettings(QObject *paret = nullptr);

View File

@ -715,6 +715,33 @@ void Entry::active(uint32_t timestamp)
} }
} }
void Entry::activeWindow(quint32 winId)
{
if (dock->isWaylandEnv()) {
if (!m_windowInfoMap.contains(winId))
return;
WindowInfoBase *winInfo = m_windowInfoMap[winId];
if (dock->isActiveWindow(winInfo)) {
bool showing = dock->isShowingDesktop();
if (showing || winInfo->isMinimized()) {
winInfo->activate();
} else if (m_windowInfoMap.size() == 1) {
winInfo->minimize();
} else {
WindowInfoBase *nextWin = findNextLeader();
if (nextWin) {
nextWin->activate();
}
}
} else {
winInfo->activate();
}
} else {
dock->doActiveWindow(winId);
}
}
int Entry::mode() int Entry::mode()
{ {
return m_mode; return m_mode;

View File

@ -92,6 +92,7 @@ public:
void forceQuit(); void forceQuit();
void presentWindows(); void presentWindows();
void active(uint32_t timestamp); void active(uint32_t timestamp);
void activeWindow(quint32 winId);
int mode(); int mode();
XWindow getCurrentWindow(); XWindow getCurrentWindow();