From 7658c6ff6a3c0e7ed7b75118ce6b4e6347cf8c68 Mon Sep 17 00:00:00 2001 From: Zhang Qipeng Date: Fri, 15 Jan 2021 14:46:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=BB=E5=8A=A1=E6=A0=8F=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 任务栏传给xcb的高度计算错误。 Log: 修复任务栏高度异常的问题。 Bug: https://pms.uniontech.com/zentao/bug-view-60842.html Change-Id: I0b467f269304e5dabb44a1ad6bc157590790c851 --- frame/util/multiscreenworker.cpp | 24 +++++++++++++++--------- frame/util/multiscreenworker.h | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/frame/util/multiscreenworker.cpp b/frame/util/multiscreenworker.cpp index 06f3d8e59..9359e5739 100644 --- a/frame/util/multiscreenworker.cpp +++ b/frame/util/multiscreenworker.cpp @@ -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(parent()->winId()), orientation, + static_cast(strut + WINDOWMARGIN * ratio), // 设置窗口与屏幕边缘距离,需要乘缩放 + static_cast(strutStart), // 设置任务栏起点坐标(上下为x,左右为y) + static_cast(strutEnd)); // 设置任务栏终点坐标(上下为x,左右为y) } void MultiScreenWorker::onRequestUpdatePosition(const Position &fromPos, const Position &toPos) diff --git a/frame/util/multiscreenworker.h b/frame/util/multiscreenworker.h index c89ab2f99..4cdb7918f 100644 --- a/frame/util/multiscreenworker.h +++ b/frame/util/multiscreenworker.h @@ -476,7 +476,7 @@ private: //当前屏幕的方向 int m_monitorRotation; //当前屏幕的所有方向 - RotationList m_rotations; + RotationList m_rotations; // 逆时针旋转(向下,向右,向上,向左) /***************不和其他流程产生交互,尽量不要动这里的变量***************/ int m_screenRawHeight;