Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions panels/dock/dconfig/org.deepin.ds.dock.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@
"permissions": "readwrite",
"visibility": "private"
},
"Show_On_All_Screens": {
"value": false,
"serial": 0,
"flags": [],
"name": "show_on_all_screens",
"name[zh_CN]": "任务栏显示在所有屏幕",
"description": "show a mirrored dock on every connected screen",
"permissions": "readwrite",
"visibility": "private"
},
"Locked": {
"value": false,
"serial": 0,
Expand Down
14 changes: 12 additions & 2 deletions panels/dock/dockhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ DockHelper::DockHelper(DockPanel *parent)
QMetaObject::invokeMethod(this, &DockHelper::checkNeedShowOrNot, Qt::QueuedConnection);

connect(parent, &DockPanel::rootObjectChanged, this, &DockHelper::initAreas);
connect(parent, &DockPanel::dockScreenChanged, this, &DockHelper::initAreas);
connect(parent, &DockPanel::showInPrimaryChanged, this, &DockHelper::updateAllDockWakeArea);
connect(parent, &DockPanel::hideStateChanged, this, &DockHelper::updateAllDockWakeArea);
connect(parent, &DockPanel::hideModeChanged, m_hideTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
Expand Down Expand Up @@ -141,6 +142,8 @@ bool DockHelper::eventFilter(QObject *watched, QEvent *event)
bool DockHelper::wakeUpAreaNeedShowOnThisScreen(QScreen *screen)
{
auto isDockAllowedShownOnThisScreen = [this, screen]() -> bool {
if (parent()->mirroredInstance())
return screen == parent()->dockScreen();
return (parent()->showInPrimary() && screen == qApp->primaryScreen()) || !parent()->showInPrimary();
};

Expand Down Expand Up @@ -301,11 +304,18 @@ void DockHelper::initAreas()
return;

// init areas
for (auto screen : qApp->screens()) {
m_areas.insert(screen, createArea(screen));
if (parent()->mirroredInstance()) {
if (auto *screen = parent()->dockScreen())
m_areas.insert(screen, createArea(screen));
} else {
for (auto screen : qApp->screens()) {
m_areas.insert(screen, createArea(screen));
}
}

connect(qApp, &QGuiApplication::screenAdded, this, [this](QScreen *screen) {
if (parent()->mirroredInstance() && screen != parent()->dockScreen())
return;
if (m_areas.contains(screen))
return;
m_areas.insert(screen, createArea(screen));
Expand Down
109 changes: 105 additions & 4 deletions panels/dock/dockpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
// for old api compatible
#include "dockdbusproxy.h"
#include "dockfrontadaptor.h"
#include "dockdaemonadaptor.h"

Check warning on line 19 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dockdaemonadaptor.h" not found.

#include <DGuiApplicationHelper>

Check warning on line 21 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DGuiApplicationHelper> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DConfig>

Check warning on line 22 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DConfig> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QEnterEvent>

Check warning on line 23 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QEnterEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QGuiApplication>

Check warning on line 24 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGuiApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QLoggingCategory>

Check warning on line 25 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLoggingCategory> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QMouseEvent>
#include <QProcess>

Check warning on line 27 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QProcess> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QQuickItem>

Check warning on line 28 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQuickItem> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QQuickWindow>

Check warning on line 29 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQuickWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTimer>

Check warning on line 30 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <wayland/xdgactivation.h>

Expand Down Expand Up @@ -196,6 +198,47 @@
Q_EMIT dockDaemonAdaptor->LockedChanged(locked());
});

auto appearanceConfig = DConfig::create(QStringLiteral("org.deepin.dde.appearance"),
QStringLiteral("org.deepin.dde.appearance"),
QString(), this);
if (appearanceConfig && appearanceConfig->isValid()) {
auto dtkThemeConfig = DConfig::create(QStringLiteral("org.deepin.dtk.preference"),
QStringLiteral("org.deepin.dtk.preference"),
QString(), this);
auto controlCenterThemeConfig = DConfig::create(QStringLiteral("org.deepin.dde.control-center"),
QStringLiteral("org.deepin.dtk.preference"),
QString(), this);
auto fileManagerThemeConfig = DConfig::create(QStringLiteral("dde-file-manager"),
QStringLiteral("org.deepin.dtk.preference"),
QString(), this);
auto shellThemeConfig = DConfig::create(QStringLiteral("org.deepin.dde.shell"),
QStringLiteral("org.deepin.dtk.preference"),
QString(), this);
const auto applyGlobalTheme = [this, appearanceConfig, dtkThemeConfig,
controlCenterThemeConfig, fileManagerThemeConfig,
shellThemeConfig]() {
const auto globalTheme = appearanceConfig->value(QStringLiteral("Global_Theme"), QString()).toString();
const auto theme = globalTheme.contains(QStringLiteral("dark"), Qt::CaseInsensitive) ? Dark : Light;
const auto themeType = theme == Dark ? 2 : 1;
const auto applyThemeType = [themeType](DConfig *config) {
if (config && config->isValid())
config->setValue(QStringLiteral("themeType"), themeType);
};
applyThemeType(dtkThemeConfig);
applyThemeType(controlCenterThemeConfig);
applyThemeType(fileManagerThemeConfig);
applyThemeType(shellThemeConfig);
Dtk::Gui::DGuiApplicationHelper::instance()->setPaletteType(static_cast<Dtk::Gui::DGuiApplicationHelper::ColorType>(theme));
setColorTheme(theme);
};
applyGlobalTheme();
connect(appearanceConfig, &DConfig::valueChanged, this,
[applyGlobalTheme](const QString &key) {
if (key == QStringLiteral("Global_Theme"))
applyGlobalTheme();
});
}

DPanel::init();

QObject::connect(this, &DApplet::rootObjectChanged, this, [this]() {
Expand All @@ -206,22 +249,32 @@
// connect(window(), &QQuickWindow::yChanged, this, &DockPanel::onWindowGeometryChanged);
connect(window(), &QQuickWindow::widthChanged, this, &DockPanel::onWindowGeometryChanged);
connect(window(), &QQuickWindow::heightChanged, this, &DockPanel::onWindowGeometryChanged);
QMetaObject::invokeMethod(this, &DockPanel::onWindowGeometryChanged);
if (showInPrimary())
if (mirroredInstance()) {
const auto targetName = appletData().value(QStringLiteral("DockScreen")).toString();
for (auto *screen : qApp->screens()) {
if (screen->name() == targetName) {
setDockScreen(screen);
break;
}
}
if (!m_dockScreen)
m_dockScreen = window()->screen();
} else if (showInPrimary())
updateDockScreen();
else {
m_dockScreen = window()->screen();
}
QMetaObject::invokeMethod(this, &DockPanel::onWindowGeometryChanged);
// 监听屏幕几何信息变化,当主屏位置变化时重新计算 frontendWindowRect
if (auto screen = window()->screen()) {
if (auto screen = m_dockScreen) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Dock stays at old screen coordinates

When a mirrored monitor's geometry changes after the dock is placed, onWindowGeometryChanged() updates the reported frontend rectangle but does not reposition the window. After a monitor geometry or layout change, the mirrored dock stays at its old coordinates instead of the configured screen edge.

Recalculate and apply the window position when the assigned screen's geometry changes.

Also at panels/dock/dockpanel.cpp:552-553.

Prompt for AI agents
In `panels/dock/dockpanel.cpp` at line 209:

**Dock stays at old screen coordinates**

When a mirrored monitor's geometry changes after the dock is placed, `onWindowGeometryChanged()` updates the reported frontend rectangle but does not reposition the window. After a monitor geometry or layout change, the mirrored dock stays at its old coordinates instead of the configured screen edge.

Recalculate and apply the window position when the assigned screen's geometry changes.

Also at `panels/dock/dockpanel.cpp:552-553`.

connect(screen, &QScreen::geometryChanged, this, &DockPanel::onWindowGeometryChanged);
}
rootObject()->installEventFilter(this);
Q_EMIT devicePixelRatioChanged(window()->devicePixelRatio());
}
});

m_theme = static_cast<ColorTheme>(Dtk::Gui::DGuiApplicationHelper::instance()->themeType());
setColorTheme(static_cast<ColorTheme>(Dtk::Gui::DGuiApplicationHelper::instance()->themeType()));
auto platformName = QGuiApplication::platformName();
if (QStringLiteral("wayland") == platformName) {
m_helper = new WaylandDockHelper(this);
Expand Down Expand Up @@ -480,6 +533,8 @@
auto *win = window();
if (!win)
return;
if (mirroredInstance())
return;

auto *primary = qApp->primaryScreen();
setDockScreen(primary);
Expand All @@ -498,6 +553,21 @@
return SETTINGS->showInPrimary();
}

bool DockPanel::showOnAllScreens() const
{
return SETTINGS->showOnAllScreens();
}

void DockPanel::setShowOnAllScreens(bool newShowOnAllScreens)
{
SETTINGS->setShowOnAllScreens(newShowOnAllScreens);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Dock property bindings stay stale

When the setting changes while a caller observes the DockPanel property, DockSettings emits showOnAllScreensChanged, but DockPanel does not forward that signal or emit its own notifier. Bindings and observers of the exposed property therefore keep the old value.

Forward DockSettings::showOnAllScreensChanged through DockPanel::showOnAllScreensChanged.

Also at panels/dock/dockpanel.h:35.

Prompt for AI agents
In `panels/dock/dockpanel.cpp` at line 475:

**Dock property bindings stay stale**

When the setting changes while a caller observes the `DockPanel` property, `DockSettings` emits `showOnAllScreensChanged`, but `DockPanel` does not forward that signal or emit its own notifier. Bindings and observers of the exposed property therefore keep the old value.

Forward `DockSettings::showOnAllScreensChanged` through `DockPanel::showOnAllScreensChanged`.

Also at `panels/dock/dockpanel.h:35`.

}

bool DockPanel::mirroredInstance() const
{
return appletData().value(QStringLiteral("DockMirror")).toBool();
}

void DockPanel::setShowInPrimary(bool newShowInPrimary)
{
if (SETTINGS->showInPrimary() == newShowInPrimary)
Expand Down Expand Up @@ -550,6 +620,37 @@
return;
m_dockScreen = screen;
window()->setScreen(m_dockScreen);
if (mirroredInstance()) {
QMetaObject::invokeMethod(this, [this, screen] {
if (!screen || !window() || m_dockScreen != screen || !qApp->screens().contains(screen))
return;

window()->setScreen(screen);
const auto screenGeometry = screen->geometry();
const auto windowWidth = window()->width();
const auto windowHeight = window()->height();
int x = screenGeometry.x() + (screenGeometry.width() - windowWidth) / 2;
int y = screenGeometry.y() + (screenGeometry.height() - windowHeight) / 2;

switch (position()) {
case Top:
y = screenGeometry.y();
break;
case Right:
x = screenGeometry.right() + 1 - windowWidth;
break;
case Bottom:
y = screenGeometry.bottom() + 1 - windowHeight;
break;
case Left:
x = screenGeometry.x();
break;
}

window()->setPosition(x, y);
onWindowGeometryChanged();
}, Qt::QueuedConnection);
}
Q_EMIT dockScreenChanged(m_dockScreen);
Q_EMIT screenNameChanged();
}
Expand Down
6 changes: 6 additions & 0 deletions panels/dock/dockpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
Q_PROPERTY(bool fashionMode READ fashionMode NOTIFY fashionModeChanged FINAL)
Q_PROPERTY(IndicatorStyle indicatorStyle READ indicatorStyle WRITE setIndicatorStyle NOTIFY indicatorStyleChanged FINAL)
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary NOTIFY showInPrimaryChanged FINAL)
Q_PROPERTY(bool showOnAllScreens READ showOnAllScreens WRITE setShowOnAllScreens NOTIFY showOnAllScreensChanged FINAL)
Q_PROPERTY(bool mirroredInstance READ mirroredInstance CONSTANT FINAL)
Q_PROPERTY(QString screenName READ screenName NOTIFY screenNameChanged FINAL)
Q_PROPERTY(bool locked READ locked WRITE setLocked NOTIFY lockedChanged FINAL)
Q_PROPERTY(bool isResizing READ isResizing WRITE setIsResizing NOTIFY isResizingChanged FINAL)
Expand Down Expand Up @@ -108,6 +110,9 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext

bool showInPrimary() const;
void setShowInPrimary(bool newShowInPrimary);
bool showOnAllScreens() const;
void setShowOnAllScreens(bool newShowOnAllScreens);
bool mirroredInstance() const;

bool locked() const;
void setLocked(bool newLocked);
Expand Down Expand Up @@ -157,6 +162,7 @@ private Q_SLOTS:
void cardCurrentChanged(const QString &cardCurrent);
void indicatorStyleChanged(IndicatorStyle style);
void showInPrimaryChanged(bool showInPrimary);
void showOnAllScreensChanged(bool showOnAllScreens);
void dockScreenChanged(QScreen *screen);
void screenNameChanged();
void requestClosePopup();
Expand Down
22 changes: 22 additions & 0 deletions panels/dock/docksettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const static QString keyIndicatorStyle = "Indicator_Style";
const static QString keyPluginsVisible = "Plugins_Visible";
const static QString keyCardCurrent = "cardCurrent";
const static QString keyShowInPrimary = "Show_In_Primary";
const static QString keyShowOnAllScreens = "Show_On_All_Screens";
const static QString keyLocked = "Locked";
const static QString keyEnableContextMenu = "enableContextMenu";
const static QString keyEnableFashionMode = "enableFashionMode";
Expand Down Expand Up @@ -163,6 +164,7 @@ DockSettings::DockSettings(QObject* parent)
, m_dockPosition(dock::Bottom)
, m_alignment(dock::CenterAlignment)
, m_style(dock::Fashion)
, m_showOnAllScreens(false)
, m_locked(false)
, m_contextMenuEnabled(true)
{
Expand Down Expand Up @@ -190,6 +192,7 @@ void DockSettings::init()
m_pluginsVisible = m_dockConfig->value(keyPluginsVisible).toMap();
m_cardCurrent = m_dockConfig->value(keyCardCurrent).toString();
m_showInPrimary = m_dockConfig->value(keyShowInPrimary).toBool();
m_showOnAllScreens = m_dockConfig->value(keyShowOnAllScreens, false).toBool();
m_locked = m_dockConfig->value(keyLocked).toBool();
m_contextMenuEnabled = m_dockConfig->value(keyEnableContextMenu, true).toBool();
m_fashionModeEnabled = m_dockConfig->value(keyEnableFashionMode, false).toBool();
Expand Down Expand Up @@ -238,6 +241,11 @@ void DockSettings::init()
if (showInPrimary == m_showInPrimary) return;
m_showInPrimary = showInPrimary;
Q_EMIT showInPrimaryChanged(m_showInPrimary);
} else if (keyShowOnAllScreens == key) {
const auto showOnAllScreens = m_dockConfig->value(keyShowOnAllScreens).toBool();
if (showOnAllScreens == m_showOnAllScreens) return;
m_showOnAllScreens = showOnAllScreens;
Q_EMIT showOnAllScreensChanged(m_showOnAllScreens);
} else if (keyLocked == key) {
auto locked = m_dockConfig->value(keyLocked).toBool();
if (locked == m_locked) return;
Expand Down Expand Up @@ -379,6 +387,20 @@ bool DockSettings::showInPrimary() const
return m_showInPrimary;
}

bool DockSettings::showOnAllScreens() const
{
return m_showOnAllScreens;
}

void DockSettings::setShowOnAllScreens(bool newShowOnAllScreens)
{
if (m_showOnAllScreens == newShowOnAllScreens)
return;
m_showOnAllScreens = newShowOnAllScreens;
m_dockConfig->setValue(keyShowOnAllScreens, m_showOnAllScreens);
Q_EMIT showOnAllScreensChanged(m_showOnAllScreens);
}

bool DockSettings::locked() const
{
return m_locked;
Expand Down
5 changes: 5 additions & 0 deletions panels/dock/docksettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class DockSettings : public QObject
Q_PROPERTY(QVariantMap pluginsVisible READ pluginsVisible WRITE setPluginsVisible NOTIFY pluginsVisibleChanged FINAL)
Q_PROPERTY(QString cardCurrent READ cardCurrent WRITE setCardCurrent NOTIFY cardCurrentChanged FINAL)
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary NOTIFY showInPrimaryChanged FINAL)
Q_PROPERTY(bool showOnAllScreens READ showOnAllScreens WRITE setShowOnAllScreens NOTIFY showOnAllScreensChanged FINAL)
Q_PROPERTY(bool locked READ locked WRITE setLocked NOTIFY lockedChanged FINAL)
Q_PROPERTY(bool contextMenuEnabled READ contextMenuEnabled NOTIFY contextMenuEnabledChanged FINAL)
Q_PROPERTY(bool fashionModeEnabled READ fashionModeEnabled NOTIFY fashionModeEnabledChanged FINAL)
Expand All @@ -43,6 +44,7 @@ class DockSettings : public QObject
QVariantMap pluginsVisible();
QString cardCurrent() const;
bool showInPrimary() const;
bool showOnAllScreens() const;
bool locked() const;
bool contextMenuEnabled() const;
// 时尚模式是否允许开启,由 DConfig 的 enableFashionMode 控制,默认关闭
Expand All @@ -56,6 +58,7 @@ class DockSettings : public QObject
void setPluginsVisible(const QVariantMap & pluginsVisible);
void setCardCurrent(const QString &cardCurrent);
void setShowInPrimary(bool newShowInPrimary);
void setShowOnAllScreens(bool newShowOnAllScreens);
void setLocked(bool newLocked);

private:
Expand Down Expand Up @@ -84,6 +87,7 @@ class DockSettings : public QObject
void cardCurrentChanged(const QString &cardCurrent);

void showInPrimaryChanged(bool showInPrimary);
void showOnAllScreensChanged(bool showOnAllScreens);
void lockedChanged(bool locked);
void contextMenuEnabledChanged(bool enabled);
void fashionModeEnabledChanged(bool enabled);
Expand All @@ -104,6 +108,7 @@ class DockSettings : public QObject
QVariantMap m_pluginsVisible;
QString m_cardCurrent;
bool m_showInPrimary;
bool m_showOnAllScreens;
bool m_locked;
bool m_contextMenuEnabled;
bool m_fashionModeEnabled = false;
Expand Down
Loading
Loading