hiDPI for window radius

pull/10/head
reionwong 4 years ago
parent 44259cffcf
commit b77b3e2c2a

@ -73,8 +73,8 @@ void Button::paint(QPainter *painter, const QRect &repaintRegion)
painter->save();
painter->setRenderHints(QPainter::Antialiasing);
QRect btnRect(0, 0, 28 * decoration->devicePixelRatio(),
28 * decoration->devicePixelRatio());
QRect btnRect(0, 0, 29 * decoration->devicePixelRatio(),
29 * decoration->devicePixelRatio());
btnRect.moveCenter(rect.center());
if (isHovered() || isPressed()) {

@ -106,6 +106,7 @@ void Decoration::init()
auto s = settings();
m_devicePixelRatio = m_settings->value("PixelRatio", 1.0).toReal();
m_frameRadius = 12 * m_devicePixelRatio;
reconfigure();
updateTitleBar();
@ -254,13 +255,12 @@ void Decoration::updateShadow()
// assign global shadow if exists and parameters match
if (!g_sShadow) {
// assign parameters
g_shadowSize = 70;
g_shadowStrength = 30;
g_shadowSize = 90;
g_shadowStrength = 35;
g_shadowColor = Qt::black;
const int frameRadius = 12;
const int shadowOverlap = frameRadius;
const int shadowOverlap = m_frameRadius;
// const int shadowOffset = qMax(6 * g_shadowSize / 16, shadowOverlap * 2);
const int shadowOffset = shadowOverlap;
const int shadowOffset = shadowOverlap / 2;
// create image
QImage image(2 * g_shadowSize, 2 * g_shadowSize, QImage::Format_ARGB32_Premultiplied);
@ -301,13 +301,13 @@ void Decoration::updateShadow()
painter.setPen( gradientStopColor(g_shadowColor, g_shadowStrength * 0.5));
painter.setBrush(Qt::NoBrush);
painter.drawRoundedRect(innerRect, -0.5 + frameRadius, -0.5 + frameRadius);
painter.drawRoundedRect(innerRect, -0.5 + m_frameRadius, -0.5 + m_frameRadius);
// mask out inner rect
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::black);
painter.setCompositionMode(QPainter::CompositionMode_DestinationOut);
painter.drawRoundedRect(innerRect, 0.5 + frameRadius, 0.5 + frameRadius);
painter.drawRoundedRect(innerRect, 0.5 + m_frameRadius, 0.5 + m_frameRadius);
painter.end();
g_sShadow = QSharedPointer<KDecoration2::DecorationShadow>::create();

@ -27,6 +27,8 @@
#include <QRegion>
#include <QDebug>
#include <QSettings>
Q_DECLARE_METATYPE(QPainterPath)
typedef void (* SetDepth)(void *, int);
@ -187,6 +189,10 @@ RoundedWindow::RoundedWindow(QObject *, const QVariantList &)
: KWin::Effect()
, m_frameRadius(12)
{
QSettings settings(QSettings::UserScope, "cutefishos", "theme");
qreal devicePixelRatio = settings.value("PixelRatio", 1.0).toReal();
m_frameRadius = 12 * devicePixelRatio;
setDepthfunc = (SetDepth) QLibrary::resolve("kwin.so." + qApp->applicationVersion(), "_ZN4KWin8Toplevel8setDepthEi");
QString name = "_NET_WM_STATE";

Loading…
Cancel
Save