fix: 任务栏高度异常

任务栏传给xcb的高度计算错误。

Log: 修复任务栏高度异常的问题。
Bug: https://pms.uniontech.com/zentao/bug-view-60842.html
Change-Id: I0b467f269304e5dabb44a1ad6bc157590790c851
This commit is contained in:
Zhang Qipeng 2021-01-15 14:46:13 +08:00
parent c18ad621d3
commit 7658c6ff6a
2 changed files with 16 additions and 10 deletions

View File

@ -735,6 +735,10 @@ void MultiScreenWorker::onRequestUpdateFrontendGeometry()
emit requestUpdateDockEntry();
}
/**
* @brief xcb去设置任务栏的高度_NET_WM_STRUT_PARTIAL属性
*
*/
void MultiScreenWorker::onRequestNotifyWindowManager()
{
static QRect lastRect = QRect();
@ -772,12 +776,10 @@ void MultiScreenWorker::onRequestNotifyWindowManager()
const QPoint &p = rawXPosition(rect.topLeft());
qDebug() << "dock topLeft position:" << p;
QScreen const *currentScreen = Utils::screenAtByScaled(rect.topLeft());
XcbMisc::Orientation orientation = XcbMisc::OrientationTop;
uint strut = 0;
uint strutStart = 0;
uint strutEnd = 0;
double strut = 0;
double strutStart = 0;
double strutEnd = 0;
switch (m_position) {
case Position::Top:
@ -788,7 +790,7 @@ void MultiScreenWorker::onRequestNotifyWindowManager()
break;
case Position::Bottom:
orientation = XcbMisc::OrientationBottom;
strut = currentScreen->geometry().height() * ratio - p.y();
strut = m_screenRawHeight - p.y();
strutStart = p.x();
strutEnd = qMin(qRound(p.x() + rect.width() * ratio), rect.right());
break;
@ -800,13 +802,17 @@ void MultiScreenWorker::onRequestNotifyWindowManager()
break;
case Position::Right:
orientation = XcbMisc::OrientationRight;
strut = currentScreen->geometry().width() * ratio - p.x();
strut = m_screenRawWidth - p.x();
strutStart = p.y();
strutEnd = qMin(qRound(p.y() + rect.height() * ratio), rect.bottom());
break;
}
qDebug() << "set dock geometry to xcb:" << strut << strutStart << strutEnd;
XcbMisc::instance()->set_strut_partial(parent()->winId(), orientation, strut + WINDOWMARGIN * ratio, strutStart, strutEnd);
qDebug() << "set reserved area to xcb:" << strut << strutStart << strutEnd;
XcbMisc::instance()->set_strut_partial(static_cast<xcb_window_t>(parent()->winId()), orientation,
static_cast<uint>(strut + WINDOWMARGIN * ratio), // 设置窗口与屏幕边缘距离,需要乘缩放
static_cast<uint>(strutStart), // 设置任务栏起点坐标上下为x左右为y
static_cast<uint>(strutEnd)); // 设置任务栏终点坐标上下为x左右为y
}
void MultiScreenWorker::onRequestUpdatePosition(const Position &fromPos, const Position &toPos)

View File

@ -476,7 +476,7 @@ private:
//当前屏幕的方向
int m_monitorRotation;
//当前屏幕的所有方向
RotationList m_rotations;
RotationList m_rotations; // 逆时针旋转(向下,向右,向上,向左)
/***************不和其他流程产生交互,尽量不要动这里的变量***************/
int m_screenRawHeight;