Commit 9b7ab4d1 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

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
parent 80d3f148
......@@ -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
......
......@@ -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);
}
......
......@@ -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
......@@ -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();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment