Improve tests behaviour on set ups with high dpi

Summary:
We are testing on a 100x100 mock display. We'd ask QWidget for our
display's dpi, it would not use the mock display but the actual
system's. On my system it made the corners overlap with each other and
all sorts of weird things happened.

Test Plan: The tests actually pass here.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28224
icc-effect-master
Aleix Pol 2020-03-23 20:26:21 +01:00
parent 80d3f148e0
commit 9b7ab4d16a
4 changed files with 17 additions and 2 deletions

View File

@ -46,6 +46,9 @@ void SwipeGesture::setStartGeometry(const QRect &geometry)
setMinimumY(geometry.y());
setMaximumX(geometry.x() + geometry.width());
setMaximumY(geometry.y() + geometry.height());
Q_ASSERT(m_maximumX >= m_minimumX);
Q_ASSERT(m_maximumY >= m_minimumY);
}
qreal SwipeGesture::minimumDeltaReachedProgress(const QSizeF &delta) const

View File

@ -727,8 +727,7 @@ ScreenEdges::ScreenEdges(QObject *parent)
, m_actionLeft(ElectricActionNone)
, m_gestureRecognizer(new GestureRecognizer(this))
{
QWidget w;
m_cornerOffset = (w.physicalDpiX() + w.physicalDpiY() + 5) / 6;
m_cornerOffset = (Screens::self()->physicalDpiX(0) + Screens::self()->physicalDpiX(0) + 5) / 6;
connect(workspace(), &Workspace::clientRemoved, this, &ScreenEdges::deleteEdgeForClient);
}

View File

@ -229,4 +229,14 @@ void Screens::setConfig(KSharedConfig::Ptr config)
m_config = config;
}
int Screens::physicalDpiX(int screen) const
{
return size(screen).width() / physicalSize(screen).width() * qreal(25.4);
}
int Screens::physicalDpiY(int screen) const
{
return size(screen).height() / physicalSize(screen).height() * qreal(25.4);
}
} // namespace

View File

@ -146,6 +146,9 @@ public:
virtual Qt::ScreenOrientation orientation(int screen) const;
int physicalDpiX(int screen) const;
int physicalDpiY(int screen) const;
public Q_SLOTS:
void reconfigure();