mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
feat: 任务栏适配支持多屏
任务栏显逻辑:两个屏幕的贴合处不可停靠 任务栏应按照以上逻辑运行,否则应视为问题 Log: 支持多屏显示 Task: https://pms.uniontech.com/zentao/task-view-89213.html Influence: 在多个显示器(>=2)的情况下,任务栏可正常显示,正常唤醒到其他显示器的可停靠边缘 Change-Id: I4f385fe7e5358a10902c10ba64e257bf35fcec03
This commit is contained in:
parent
0e30d5a2a5
commit
5faf079c22
@ -182,132 +182,79 @@ void DisplayManager::updateScreenDockInfo()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 最多支持双屏,这里只计算双屏,单屏默认四边均可停靠任务栏
|
// 适配多个屏幕的情况
|
||||||
if (m_screens.size() == 2) {
|
for(auto s : m_screens) {
|
||||||
QRect s0 = m_screens.at(0)->geometry();
|
QList<QScreen *> otherScreens = m_screens;
|
||||||
s0.setSize(s0.size() * m_screens.at(0)->devicePixelRatio());
|
otherScreens.removeAll(s);
|
||||||
QRect s1 = m_screens.at(1)->geometry();
|
for (auto other : otherScreens) {
|
||||||
s1.setSize(s1.size() * m_screens.at(1)->devicePixelRatio());
|
QRect ourRect = QRect(s->geometry().topLeft(), s->geometry().size() * s->devicePixelRatio());
|
||||||
|
int ourBottom = ourRect.top() + ourRect.height();
|
||||||
|
int ourTop = ourRect.top();
|
||||||
|
int ourLeft = ourRect.left();
|
||||||
|
int ourRight = ourRect.left() + ourRect.width();
|
||||||
|
QPoint ourLeftBottom = QPoint(ourLeft, ourBottom);
|
||||||
|
QPoint ourRightBottom = QPoint(ourRight, ourBottom);
|
||||||
|
QPoint ourRightTop = QPoint(ourRight, ourTop);
|
||||||
|
|
||||||
qInfo() << "monitor info changed" << m_screens.at(0)->name() << s0 << m_screens.at(1)->name() << s1;
|
QRect otherRect = QRect(other->geometry().topLeft(), other->geometry().size() * other->devicePixelRatio());
|
||||||
|
int otherBottom = otherRect.top() + otherRect.height();
|
||||||
|
int otherTop = otherRect.top();
|
||||||
|
int otherLeft = otherRect.left();
|
||||||
|
int otherRight = otherRect.left() + otherRect.width();
|
||||||
|
QPoint otherLeftBottom = QPoint(otherLeft, otherBottom);
|
||||||
|
QPoint otherLeftTop = QPoint(otherLeft, otherTop);
|
||||||
|
QPoint otherRightTop = QPoint(otherRight, otherTop);
|
||||||
|
|
||||||
int s0top = s0.y();
|
/*
|
||||||
int s0bottom = s0.y() + s0.height();
|
* 上下拼接,our屏幕左右移动。
|
||||||
int s0left = s0.x();
|
* our屏幕从other屏幕对角的左上侧向右移动,至other屏幕对角的右上侧位置
|
||||||
int s0Right = s0.x() + s0.width();
|
--------- ---------
|
||||||
|
| | | |
|
||||||
|
| our | ======>>>>> | our |
|
||||||
|
| | | |
|
||||||
|
--------------- ---------------
|
||||||
|
| | | |
|
||||||
|
| other | | other |
|
||||||
|
| | | |
|
||||||
|
--------- ---------
|
||||||
|
*/
|
||||||
|
// 上下拼接
|
||||||
|
if (ourBottom == otherTop
|
||||||
|
&& (ourRight >= otherLeft)
|
||||||
|
&& (ourLeft <= otherRight)) {
|
||||||
|
// 排除对角排列
|
||||||
|
if (ourLeftBottom == otherRightTop
|
||||||
|
|| ourRightBottom == otherLeftTop)
|
||||||
|
continue;
|
||||||
|
m_screenPositionMap[s][Position::Bottom] = false;
|
||||||
|
m_screenPositionMap[other][Position::Top] = false;
|
||||||
|
}
|
||||||
|
|
||||||
int s1top = s1.y();
|
/*
|
||||||
int s1bottom = s1.y() + s1.height();
|
* 左右拼接,our屏幕上下移动。
|
||||||
int s1left = s1.x();
|
* our屏幕从other屏幕对角的左上侧向下移动,至other屏幕对角的最左下侧位置
|
||||||
int s1Right = s1.x() + s1.width();
|
--------- ---------
|
||||||
|
| | | |
|
||||||
QPoint s0topLeft = QPoint(s0.x(), s0.y());
|
| our | ======>>>>> ---------| other |
|
||||||
QPoint s0topRight = QPoint(s0.x()+ s0.width(), s0.y());
|
| |-------- | | |
|
||||||
QPoint s0bottomRight = QPoint(s0.x()+ s0.width(), s0.y() + s0.height());
|
--------| | | our |--------
|
||||||
QPoint s0bottomLeft = QPoint(s0.x(), s0.y() + s0.height());
|
| other | | |
|
||||||
|
| | ----------
|
||||||
QPoint s1topLeft = QPoint(s1.x(), s1.y());
|
---------
|
||||||
QPoint s1topRight = QPoint(s1.x() + s1.width(), s1.y());
|
*/
|
||||||
QPoint s1bottomRight = QPoint(s1.x() + s1.width(), s1.y() + s1.height());
|
// 左右拼接
|
||||||
QPoint s1bottomLeft = QPoint(s1.x(), s1.y() + s1.height());
|
if (otherLeft == ourRight
|
||||||
|
&& (ourTop <= otherBottom)
|
||||||
/*
|
&& (ourBottom >= otherTop)) {
|
||||||
* 对角拼接,重置,默认均可停靠
|
// 排除对角排列
|
||||||
--------- ---------
|
if (ourRightTop == otherLeftBottom
|
||||||
| | | |
|
|| ourRightBottom == otherLeftTop)
|
||||||
| s0 | | s1 |
|
continue;
|
||||||
| | | |
|
m_screenPositionMap[s][Position::Right] = false;
|
||||||
----------------- -----------------
|
m_screenPositionMap[other][Position::Left] = false;
|
||||||
| | | |
|
}
|
||||||
| s1 | s0 |
|
|
||||||
| | | |
|
|
||||||
--------- ---------
|
|
||||||
*/
|
|
||||||
if (s0bottomRight == s1topLeft
|
|
||||||
|| s0topLeft == s1bottomRight) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* 左右拼接,s0左,s1右
|
|
||||||
--------------------- -------------
|
|
||||||
| | | | |
|
|
||||||
| | s1 | | |--------
|
|
||||||
| s0 | | | s0 | |
|
|
||||||
| |-------- | | s1 |
|
|
||||||
| | | | |
|
|
||||||
------------- ---------------------
|
|
||||||
*/
|
|
||||||
if (s0Right == s1left
|
|
||||||
&& (s0topRight == s1topLeft || s0bottomRight == s1bottomLeft)) {
|
|
||||||
m_screenPositionMap[m_screens.at(0)].insert(Position::Right, false);
|
|
||||||
m_screenPositionMap[m_screens.at(1)].insert(Position::Left, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 左右拼接,s1左,s0右
|
|
||||||
--------------------- -------------
|
|
||||||
| | | | |
|
|
||||||
| | s0 | | |--------
|
|
||||||
| s1 | | | s1 | |
|
|
||||||
| |-------- | | s0 |
|
|
||||||
| | | | |
|
|
||||||
------------- ---------------------
|
|
||||||
*/
|
|
||||||
if (s0left== s1Right
|
|
||||||
&& (s0topLeft == s1topRight || s0bottomLeft == s1bottomRight)) {
|
|
||||||
m_screenPositionMap[m_screens.at(0)].insert(Position::Left, false);
|
|
||||||
m_screenPositionMap[m_screens.at(1)].insert(Position::Right, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 上下拼接,s0上,s1下
|
|
||||||
--------- ---------
|
|
||||||
| | | |
|
|
||||||
| s0 | | s0 |
|
|
||||||
| | | |
|
|
||||||
------------- -------------
|
|
||||||
| | | |
|
|
||||||
| | | |
|
|
||||||
| s1 | | s1 |
|
|
||||||
| | | |
|
|
||||||
| | | |
|
|
||||||
------------- -------------
|
|
||||||
*/
|
|
||||||
if (s0bottom == s1top
|
|
||||||
&& (s0bottomLeft == s1topLeft || s0bottomRight == s1topRight)) {
|
|
||||||
m_screenPositionMap[m_screens.at(0)].insert(Position::Bottom, false);
|
|
||||||
m_screenPositionMap[m_screens.at(1)].insert(Position::Top, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 上下拼接,s1上,s0下
|
|
||||||
--------- ---------
|
|
||||||
| | | |
|
|
||||||
| s1 | | s1 |
|
|
||||||
| | | |
|
|
||||||
------------- -------------
|
|
||||||
| | | |
|
|
||||||
| | | |
|
|
||||||
| s0 | | s0 |
|
|
||||||
| | | |
|
|
||||||
| | | |
|
|
||||||
------------- -------------
|
|
||||||
*/
|
|
||||||
if (s0top == s1bottom
|
|
||||||
&& (s0topLeft == s1bottomLeft || s0topRight == s1bottomRight)) {
|
|
||||||
m_screenPositionMap[m_screens.at(0)].insert(Position::Top, false);
|
|
||||||
m_screenPositionMap[m_screens.at(1)].insert(Position::Bottom, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 目前不支持链接超过两个以上的显示器
|
|
||||||
Q_UNREACHABLE();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,8 +64,8 @@ Q_SIGNALS:
|
|||||||
void screenInfoChanged(); // 屏幕信息发生变化,需要调整任务栏显示,只需要这一个信号,其他的都不要,简化流程
|
void screenInfoChanged(); // 屏幕信息发生变化,需要调整任务栏显示,只需要这一个信号,其他的都不要,简化流程
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList <QScreen *> m_screens;
|
QList<QScreen *> m_screens;
|
||||||
QMap <QScreen *, QMap <Position, bool>> m_screenPositionMap;
|
QMap<QScreen *, QMap<Position, bool>> m_screenPositionMap;
|
||||||
const QGSettings *m_gsettings; // 多屏配置控制
|
const QGSettings *m_gsettings; // 多屏配置控制
|
||||||
bool m_onlyInPrimary;
|
bool m_onlyInPrimary;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user