Commit b9024cf9 authored by Marco Martin's avatar Marco Martin
Browse files

try to enforce borders settings from KWin

Summary:
this makes the "no borders" option do something: however it cause many
other issues with many themes that weren't really designed for "no
borders"
it fixes the "tiny borders" for almost all themes, as the whole calculation before
was
completely wrong

Test Plan:
Some themes work way better now, some look broken with no border or no side borders
some look perfect with those options
another issue is that aurorae is going to support no borders, it has to support like
breeze resizing from the shadows

Reviewers: #plasma, #kwin, davidedmundson

Reviewed By: #plasma, #kwin, davidedmundson

Subscribers: davidedmundson, ngraham, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25146
parent 639441f1
......@@ -348,14 +348,11 @@ void Decoration::init()
trackBorders(m_borders);
trackBorders(m_maximizedBorders);
if (m_extendedBorders) {
auto updateExtendedBorders = [this] {
setResizeOnlyBorders(*m_extendedBorders);
};
updateExtendedBorders();
connect(m_extendedBorders, &KWin::Borders::leftChanged, this, updateExtendedBorders);
connect(m_extendedBorders, &KWin::Borders::rightChanged, this, updateExtendedBorders);
connect(m_extendedBorders, &KWin::Borders::topChanged, this, updateExtendedBorders);
connect(m_extendedBorders, &KWin::Borders::bottomChanged, this, updateExtendedBorders);
connect(m_extendedBorders, &KWin::Borders::leftChanged, this, &Decoration::updateExtendedBorders);
connect(m_extendedBorders, &KWin::Borders::rightChanged, this, &Decoration::updateExtendedBorders);
connect(m_extendedBorders, &KWin::Borders::topChanged, this, &Decoration::updateExtendedBorders);
connect(m_extendedBorders, &KWin::Borders::bottomChanged, this, &Decoration::updateExtendedBorders);
}
connect(client().data(), &KDecoration2::DecoratedClient::maximizedChanged, this, &Decoration::updateBorders, Qt::QueuedConnection);
connect(client().data(), &KDecoration2::DecoratedClient::shadedChanged, this, &Decoration::updateBorders);
......@@ -410,6 +407,8 @@ void Decoration::updateBorders()
return;
}
setBorders(*b);
updateExtendedBorders();
}
void Decoration::paint(QPainter *painter, const QRect &repaintRegion)
......@@ -556,6 +555,31 @@ void Decoration::installTitleItem(QQuickItem *item)
connect(item, &QQuickItem::yChanged, this, update);
}
void Decoration::updateExtendedBorders()
{
// extended sizes
const int extSize = settings()->largeSpacing();
int extLeft = m_extendedBorders->left();
int extRight = m_extendedBorders->right();
int extBottom = m_extendedBorders->bottom();
if (settings()->borderSize() == KDecoration2::BorderSize::None) {
if (!client().data()->isMaximizedHorizontally()) {
extLeft = qMax(m_extendedBorders->left(), extSize);
extRight = qMax(m_extendedBorders->right(), extSize);
}
if (!client().data()->isMaximizedVertically()) {
extBottom = qMax(m_extendedBorders->bottom(), extSize);
}
} else if (settings()->borderSize() == KDecoration2::BorderSize::NoSides && !client().data()->isMaximizedHorizontally() ) {
extLeft = qMax(m_extendedBorders->left(), extSize);
extRight = qMax(m_extendedBorders->right(), extSize);
}
setResizeOnlyBorders(QMargins(extLeft, 0, extRight, extBottom));
}
void Decoration::updateBuffer()
{
m_contentRect = QRect(QPoint(0, 0), m_view->bufferAsImage().size());
......
......@@ -74,6 +74,8 @@ private:
void setupBorders(QQuickItem *item);
void updateBorders();
void updateBuffer();
void updateExtendedBorders();
QRect m_contentRect; //the geometry of the part of the buffer that is not a shadow when buffer was created.
QQuickItem *m_item = nullptr;
QQmlContext *m_qmlContext = nullptr;
......
......@@ -208,63 +208,69 @@ void AuroraeTheme::borders(int& left, int& top, int& right, int& bottom, bool ma
break;
}
} else {
int minMargin;
int maxMargin;
switch (d->borderSize) {
case KDecoration2::BorderSize::NoSides:
case KDecoration2::BorderSize::Tiny:
// TODO: this looks wrong
if (isCompositingActive()) {
left = qMin(0, (int)left - d->themeConfig.borderLeft() - d->themeConfig.paddingLeft());
right = qMin(0, (int)right - d->themeConfig.borderRight() - d->themeConfig.paddingRight());
bottom = qMin(0, (int)bottom - d->themeConfig.borderBottom() - d->themeConfig.paddingBottom());
} else {
left = qMin(0, (int)left - d->themeConfig.borderLeft());
right = qMin(0, (int)right - d->themeConfig.borderRight());
bottom = qMin(0, (int)bottom - d->themeConfig.borderBottom());
}
minMargin = 1;
maxMargin = 4;
break;
case KDecoration2::BorderSize::Normal:
minMargin = 4;
maxMargin = 6;
break;
case KDecoration2::BorderSize::Large:
left = right = bottom = top = 4;
minMargin = 6;
maxMargin = 8;
break;
case KDecoration2::BorderSize::VeryLarge:
left = right = bottom = top = 8;
minMargin = 8;
maxMargin = 12;
break;
case KDecoration2::BorderSize::Huge:
left = right = bottom = top = 12;
minMargin = 12;
maxMargin = 20;
break;
case KDecoration2::BorderSize::VeryHuge:
left = right = bottom = top = 23;
minMargin = 23;
maxMargin = 30;
break;
case KDecoration2::BorderSize::Oversized:
left = right = bottom = top = 36;
minMargin = 36;
maxMargin = 48;
break;
case KDecoration2::BorderSize::Normal:
default:
left = right = bottom = top = 0;
minMargin = 0;
maxMargin = 0;
}
left = qBound(minMargin, d->themeConfig.borderLeft(), maxMargin);
right = qBound(minMargin, d->themeConfig.borderRight(), maxMargin);
bottom = qBound(minMargin, d->themeConfig.borderBottom(), maxMargin);
if (d->borderSize == KDecoration2::BorderSize::None) {
left = 0;
right = 0;
bottom = 0;
} else if (d->borderSize == KDecoration2::BorderSize::NoSides) {
left = 0;
right = 0;
}
const qreal title = titleHeight + d->themeConfig.titleEdgeTop() + d->themeConfig.titleEdgeBottom();
switch ((DecorationPosition)d->themeConfig.decorationPosition()) {
case DecorationTop:
left += d->themeConfig.borderLeft();
right += d->themeConfig.borderRight();
bottom += d->themeConfig.borderBottom();
top = title;
break;
case DecorationBottom:
left += d->themeConfig.borderLeft();
right += d->themeConfig.borderRight();
bottom = title;
top += d->themeConfig.borderTop();
break;
case DecorationLeft:
left = title;
right += d->themeConfig.borderRight();
bottom += d->themeConfig.borderBottom();
top += d->themeConfig.borderTop();
break;
case DecorationRight:
left += d->themeConfig.borderLeft();
right = title;
bottom += d->themeConfig.borderBottom();
top += d->themeConfig.borderTop();
break;
default:
left = right = bottom = top = 0;
......
......@@ -188,6 +188,11 @@ Decoration {
topMargin: parent.padding.top + parent.borders.top - margins.top
bottomMargin: parent.padding.bottom + parent.borders.bottom - margins.bottom
}
visible: parent.borders.left > fixedMargins.left
&& parent.borders.right > fixedMargins.right
&& parent.borders.top > fixedMargins.top
&& parent.borders.bottom > fixedMargins.bottom
imagePath: backgroundSvg.imagePath
prefix: "innerborder"
opacity: (decoration.client.active && !decoration.client.maximized && backgroundSvg.supportsInnerBorder) ? 1 : 0
......@@ -207,6 +212,12 @@ Decoration {
topMargin: parent.padding.top + parent.borders.top - margins.top
bottomMargin: parent.padding.bottom + parent.borders.bottom - margins.bottom
}
visible: parent.borders.left > fixedMargins.left
&& parent.borders.right > fixedMargins.right
&& parent.borders.top > fixedMargins.top
&& parent.borders.bottom > fixedMargins.bottom
imagePath: backgroundSvg.imagePath
prefix: "innerborder-inactive"
opacity: (!decoration.client.active && !decoration.client.maximized && backgroundSvg.supportsInnerBorderInactive) ? 1 : 0
......
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