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 <https://invent.kde.org/plasma/kwin/-/merge_requests/2461> Part-of: <https://invent.kde.org/plasma/kwin/-/merge_requests/2461>
This commit is contained in:
parent
68f6734d5c
commit
7c849ee05a
1 changed files with 4 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue