From 1fb4baf365ea9fee2907016874c95205adc76c6f Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Wed, 17 Apr 2019 00:36:37 +0200 Subject: [PATCH] [effects/screenedge] Support "hint-stretch-borders" Summary: Some old themes have the flag set and also a style which expects the borders to be stretched. Given that the documentation on techbase describes widgets/glowbar still as "a frame without a prefix", one also would assume that all the optional hints (which make sense) still apply. Even more, the Air & Oxygen themes have the hint also set, though for their rendering it makes no difference. The small code needed seems worth the unbreaking of old themes as well as giving theme creators another variable of freedom for their styles. Test Plan: Glow bar still works on all corners and edges with all themes as before, though rendering now as expected for themes which have the "hint-stretch-borders" set. Reviewers: #kwin, zzag, davidedmundson Reviewed By: #kwin, zzag, davidedmundson Subscribers: davidedmundson, zzag, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D20621 --- effects/screenedge/screenedgeeffect.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/effects/screenedge/screenedgeeffect.cpp b/effects/screenedge/screenedgeeffect.cpp index 51db00ee38..3c0810eb10 100644 --- a/effects/screenedge/screenedgeeffect.cpp +++ b/effects/screenedge/screenedgeeffect.cpp @@ -308,6 +308,8 @@ T *ScreenEdgeEffect::createEdgeGlow(ElectricBorder border, const QSize &size) { ensureGlowSvg(); + const bool stretchBorder = m_glow->hasElement(QStringLiteral("hint-stretch-borders")); + QPoint pixmapPosition(0, 0); QPixmap l, r, c; switch (border) { @@ -342,11 +344,21 @@ T *ScreenEdgeEffect::createEdgeGlow(ElectricBorder border, const QSize &size) p.begin(&image); if (border == ElectricBottom || border == ElectricTop) { p.drawPixmap(pixmapPosition, l); - p.drawTiledPixmap(QRect(l.width(), pixmapPosition.y(), size.width() - l.width() - r.width(), c.height()), c); + const QRect cRect(l.width(), pixmapPosition.y(), size.width() - l.width() - r.width(), c.height()); + if (stretchBorder) { + p.drawPixmap(cRect, c); + } else { + p.drawTiledPixmap(cRect, c); + } p.drawPixmap(QPoint(size.width() - r.width(), pixmapPosition.y()), r); } else { p.drawPixmap(pixmapPosition, l); - p.drawTiledPixmap(QRect(pixmapPosition.x(), l.height(), c.width(), size.height() - l.height() - r.height()), c); + const QRect cRect(pixmapPosition.x(), l.height(), c.width(), size.height() - l.height() - r.height()); + if (stretchBorder) { + p.drawPixmap(cRect, c); + } else { + p.drawTiledPixmap(cRect, c); + } p.drawPixmap(QPoint(pixmapPosition.x(), size.height() - r.height()), r); } p.end();