fix frontend pos not scaled correct

Change-Id: Iea64cd0efbe67ec8f01f5526fc2433e433660a99
This commit is contained in:
石博文 2017-12-29 15:54:46 +08:00
parent 58fd2df606
commit 59ea6183d8
Notes: Deepin Code Review 2017-12-29 17:03:38 +08:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Fri, 29 Dec 2017 17:03:38 +0800
Reviewed-on: https://cr.deepin.io/29861
Project: dde/dde-dock
Branch: refs/heads/master
2 changed files with 21 additions and 2 deletions

View File

@ -410,7 +410,6 @@ void DockSettings::hideStateChanged()
void DockSettings::dockItemCountChanged()
{
// qDebug() << Q_FUNC_INFO;
if (m_displayMode == Dock::Efficient)
return;

View File

@ -50,6 +50,22 @@ const QPoint rawXPosition(const QPoint &scaledPos)
return g.topLeft() + (scaledPos - g.topLeft()) * qApp->devicePixelRatio();
}
const QPoint scaledPos(const QPoint &rawXPos)
{
QRect g = qApp->primaryScreen()->geometry();
for (auto *screen : qApp->screens())
{
const QRect &sg = screen->geometry();
if (sg.contains(rawXPos))
{
g = sg;
break;
}
}
return g.topLeft() + (rawXPos - g.topLeft()) / qApp->devicePixelRatio();
}
MainWindow::MainWindow(QWidget *parent)
: QWidget(parent),
@ -704,9 +720,13 @@ void MainWindow::positionCheck()
if (m_positionUpdateTimer->isActive())
return;
if (pos() == m_settings->frontendWindowRect().topLeft())
const QPoint scaledFrontPos = scaledPos(m_settings->frontendWindowRect().topLeft());
if (QPoint(pos() - scaledFrontPos).manhattanLength() < 2)
return;
qWarning() << "Dock position may error!!!!!";
qDebug() << pos() << m_settings->frontendWindowRect() << m_settings->windowRect(m_settings->position(), false);
internalMove();
}