fix: 任务栏仅主屏显示关联信号改用后端的信号

wayland下改变主屏后不会发出QApplication::primaryScreenChanged信号,改用后端PrimaryChanged信号

Log: 修复wayland下任务栏设置仅主屏显示后切换主屏任务栏未跟随显示的问题
Influence: 切换主屏后,任务栏显示
Bug: https://pms.uniontech.com/bug-view-129559.html
Change-Id: I70e4d71916326fa6ff203b64e337075ad87bec8c
This commit is contained in:
chenbin 2022-01-10 09:48:41 +08:00 committed by wubw
parent 87525c9917
commit 587e3822d9
2 changed files with 9 additions and 2 deletions

View File

@ -31,9 +31,15 @@ DisplayManager::DisplayManager(QObject *parent)
: QObject(parent)
, m_gsettings(Utils::SettingsPtr("com.deepin.dde.dock.mainwindow", "/com/deepin/dde/dock/mainwindow/", this))
, m_onlyInPrimary(Utils::SettingValue("com.deepin.dde.dock.mainwindow", "/com/deepin/dde/dock/mainwindow/", "onlyShowPrimary", false).toBool())
, m_displayInter(nullptr)
{
connect(qApp, &QApplication::primaryScreenChanged, this, &DisplayManager::primaryScreenChanged);
connect(qApp, &QApplication::primaryScreenChanged, this, &DisplayManager::dockInfoChanged);
if (Utils::IS_WAYLAND_DISPLAY) {
m_displayInter = new DisplayInter("com.deepin.daemon.Display", "/com/deepin/daemon/Display",QDBusConnection::sessionBus(), this);
connect(m_displayInter, &__Display::PrimaryChanged, this, &DisplayManager::dockInfoChanged);
} else {
connect(qApp, &QApplication::primaryScreenChanged, this, &DisplayManager::dockInfoChanged);
}
connect(qApp, &QGuiApplication::screenAdded, this, &DisplayManager::screenCountChanged);
connect(qApp, &QGuiApplication::screenRemoved, this, &DisplayManager::screenCountChanged);
@ -166,7 +172,7 @@ void DisplayManager::updateScreenDockInfo()
// 仅显示在主屏时的处理
if (m_onlyInPrimary) {
for (auto s : m_screens) {
if (s != qApp->primaryScreen()) {
if (Utils::IS_WAYLAND_DISPLAY ? !s->model().contains(m_displayInter->primary()) : s != qApp->primaryScreen()) {
QMap <Position, bool> map;
map.insert(Position::Top, false);
map.insert(Position::Bottom, false);

View File

@ -68,6 +68,7 @@ private:
QMap<QScreen *, QMap<Position, bool>> m_screenPositionMap;
const QGSettings *m_gsettings; // 多屏配置控制
bool m_onlyInPrimary;
DisplayInter *m_displayInter;
};
#endif // DISPLAYMANAGER_H