Commit 7c849ee0 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii Committed by Merge Service
Browse files

Use font metrics to compute corner offset

The problem with the current approach is that it doesn't work reliably
on wayland. Outputs can have different pixel density, etc.

Tested-by: Merge Service <!2461>
Part-of: <!2461>
parent 68f6734d
Pipeline #180656 passed with stage
in 22 minutes and 19 seconds
......@@ -41,6 +41,8 @@
#include <QAction>
#include <QDBusInterface>
#include <QDBusPendingCall>
#include <QFontDatabase>
#include <QFontMetrics>
#include <QMouseEvent>
#include <QSharedPointer>
#include <QTextStream>
......@@ -775,17 +777,8 @@ ScreenEdges::ScreenEdges(QObject *parent)
, m_actionLeft(ElectricActionNone)
, m_gestureRecognizer(new GestureRecognizer(this))
{
// TODO: Maybe calculate the corner offset based on font metrics instead?
const auto outputs = kwinApp()->platform()->enabledOutputs();
if (!outputs.isEmpty()) {
const QSize size = outputs[0]->geometry().size();
const QSizeF physicalSize = outputs[0]->physicalSize();
const int physicalDpiX = size.width() / physicalSize.width() * qreal(25.4);
const int physicalDpiY = size.height() / physicalSize.height() * qreal(25.4);
m_cornerOffset = (physicalDpiX + physicalDpiY + 5) / 6;
}
const int gridUnit = QFontMetrics(QFontDatabase::systemFont(QFontDatabase::GeneralFont)).boundingRect(QLatin1Char('M')).height();
m_cornerOffset = 4 * gridUnit;
connect(workspace(), &Workspace::windowRemoved, this, &ScreenEdges::deleteEdgeForClient);
}
......
Supports Markdown
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