Fix strut area outof primary screen bounds

Change-Id: I86c26d1e8431d1604dcf0154b1ecf37c117cdb25
This commit is contained in:
石博文 2017-11-28 14:27:16 +08:00
parent 7c536e8243
commit bceddf78c4
Notes: Deepin Code Review 2017-11-28 16:16:05 +08:00
Verified+1: Anonymous Coward #1000004
Verified+1: <yefei@linuxdeepin.com>
Code-Review+2: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Tue, 28 Nov 2017 16:16:05 +0800
Reviewed-on: https://cr.deepin.io/28952
Project: dde/dde-dock
Branch: refs/heads/master
3 changed files with 15 additions and 10 deletions

View File

@ -116,8 +116,8 @@ public:
const qreal scale = qApp->devicePixelRatio();
DisplayRect dr = primaryRawRect();
dr.width = qreal(dr.width) / scale;
dr.height = qreal(dr.height) / scale;
dr.width = std::round(qreal(dr.width) / scale);
dr.height = std::round(qreal(dr.height) / scale);
return dr;
}

View File

@ -436,8 +436,8 @@ void DockSettings::calculateWindowConfig()
{
// qDebug() << Q_FUNC_INFO;
const auto ratio = qApp->devicePixelRatio();
const int defaultHeight = AppItem::itemBaseHeight() / ratio;
const int defaultWidth = AppItem::itemBaseWidth() / ratio;
const int defaultHeight = std::round(AppItem::itemBaseHeight() / ratio);
const int defaultWidth = std::round(AppItem::itemBaseWidth() / ratio);
if (m_displayMode == Dock::Efficient)
{

View File

@ -427,8 +427,9 @@ void MainWindow::setStrutPartial()
const int maxScreenHeight = m_settings->screenRawHeight();
const int maxScreenWidth = m_settings->screenRawWidth();
const Position side = m_settings->position();
const QPoint p = rawXPosition(m_posChangeAni->endValue().toPoint());
const QSize s = m_settings->windowSize();
const QPoint &p = rawXPosition(m_posChangeAni->endValue().toPoint());
const QSize &s = m_settings->windowSize();
const QRect &primaryRawRect = m_settings->primaryRawRect();
XcbMisc::Orientation orientation = XcbMisc::OrientationTop;
uint strut = 0;
@ -442,7 +443,7 @@ void MainWindow::setStrutPartial()
orientation = XcbMisc::OrientationTop;
strut = p.y() + s.height() * ratio;
strutStart = p.x();
strutEnd = p.x() + s.width() * ratio;
strutEnd = qMin(qRound(p.x() + s.width() * ratio), primaryRawRect.right());
strutArea.setLeft(strutStart);
strutArea.setRight(strutEnd);
strutArea.setBottom(strut);
@ -451,7 +452,7 @@ void MainWindow::setStrutPartial()
orientation = XcbMisc::OrientationBottom;
strut = maxScreenHeight - p.y();
strutStart = p.x();
strutEnd = p.x() + s.width() * ratio;
strutEnd = qMin(qRound(p.x() + s.width() * ratio), primaryRawRect.right());
strutArea.setLeft(strutStart);
strutArea.setRight(strutEnd);
strutArea.setTop(p.y());
@ -460,7 +461,7 @@ void MainWindow::setStrutPartial()
orientation = XcbMisc::OrientationLeft;
strut = p.x() + s.width() * ratio;
strutStart = p.y();
strutEnd = p.y() + s.height() * ratio;
strutEnd = qMin(qRound(p.y() + s.height() * ratio), primaryRawRect.bottom());
strutArea.setTop(strutStart);
strutArea.setBottom(strutEnd);
strutArea.setRight(strut);
@ -469,7 +470,7 @@ void MainWindow::setStrutPartial()
orientation = XcbMisc::OrientationRight;
strut = maxScreenWidth - p.x();
strutStart = p.y();
strutEnd = p.y() + s.height() * ratio;
strutEnd = qMin(qRound(p.y() + s.height() * ratio), primaryRawRect.bottom());
strutArea.setTop(strutStart);
strutArea.setBottom(strutEnd);
strutArea.setLeft(p.x());
@ -493,7 +494,11 @@ void MainWindow::setStrutPartial()
++count;
}
if (count > 0)
{
qWarning() << "strutArea is intersects with another screen.";
qWarning() << maxScreenHeight << maxScreenWidth << side << p << s;
return;
}
m_xcbMisc->set_strut_partial(winId(), orientation, strut, strutStart, strutEnd);
}