[blur] use blurRegion to identify if a decoration supports blur
Having blurRegion to identify if a decoration supports blur or not instead of the metadata-json way has the following benefits: - decorations can now provide both blur or not based on user preference - theme engines such as Aurorae do not have to enforce blur or not to their themes and they can support blur enabled and disabled themes at the same time if they want to - blurRegion is empty by default so the Korners bug will be fixed for all solid aurorae themes. Breeze and Oxygen have set **blur:false** so nothing changes for them. - all aurorae themes that do not require blur will free up system resources by default
This commit is contained in:
parent
bd920fb28c
commit
a1fec92ef2
7 changed files with 12 additions and 41 deletions
|
@ -50,7 +50,6 @@ KWIN_SINGLETON_FACTORY(DecorationBridge)
|
|||
DecorationBridge::DecorationBridge(QObject *parent)
|
||||
: KDecoration2::DecorationBridge(parent)
|
||||
, m_factory(nullptr)
|
||||
, m_blur(false)
|
||||
, m_showToolTips(false)
|
||||
, m_settings()
|
||||
, m_noPlugin(false)
|
||||
|
@ -193,7 +192,6 @@ void DecorationBridge::reconfigure()
|
|||
void DecorationBridge::loadMetaData(const QJsonObject &object)
|
||||
{
|
||||
// reset all settings
|
||||
m_blur = false;
|
||||
m_recommendedBorderSize = QString();
|
||||
m_theme = QString();
|
||||
m_defaultTheme = QString();
|
||||
|
@ -205,10 +203,6 @@ void DecorationBridge::loadMetaData(const QJsonObject &object)
|
|||
return;
|
||||
}
|
||||
const QVariantMap decoSettingsMap = decoSettings.toObject().toVariantMap();
|
||||
auto blurIt = decoSettingsMap.find(QStringLiteral("blur"));
|
||||
if (blurIt != decoSettingsMap.end()) {
|
||||
m_blur = blurIt.value().toBool();
|
||||
}
|
||||
auto recBorderSizeIt = decoSettingsMap.find(QStringLiteral("recommendedBorderSize"));
|
||||
if (recBorderSizeIt != decoSettingsMap.end()) {
|
||||
m_recommendedBorderSize = recBorderSizeIt.value().toString();
|
||||
|
@ -289,7 +283,6 @@ QString DecorationBridge::supportInformation() const
|
|||
b.append(QStringLiteral("Plugin: %1\n").arg(m_plugin));
|
||||
b.append(QStringLiteral("Theme: %1\n").arg(m_theme));
|
||||
b.append(QStringLiteral("Plugin recommends border size: %1\n").arg(m_recommendedBorderSize.isNull() ? "No" : m_recommendedBorderSize));
|
||||
b.append(QStringLiteral("Blur: %1\n").arg(m_blur));
|
||||
const QMetaObject *metaOptions = m_settings->metaObject();
|
||||
for (int i=0; i<metaOptions->propertyCount(); ++i) {
|
||||
const QMetaProperty property = metaOptions->property(i);
|
||||
|
|
|
@ -45,9 +45,6 @@ public:
|
|||
std::unique_ptr<KDecoration2::DecoratedClientPrivate> createClient(KDecoration2::DecoratedClient *client, KDecoration2::Decoration *decoration) override;
|
||||
std::unique_ptr<KDecoration2::DecorationSettingsPrivate> settings(KDecoration2::DecorationSettings *parent) override;
|
||||
|
||||
bool needsBlur() const {
|
||||
return m_blur;
|
||||
}
|
||||
QString recommendedBorderSize() const {
|
||||
return m_recommendedBorderSize;
|
||||
}
|
||||
|
@ -75,7 +72,6 @@ private:
|
|||
QString readTheme() const;
|
||||
void readDecorationOptions();
|
||||
KPluginFactory *m_factory;
|
||||
bool m_blur;
|
||||
bool m_showToolTips;
|
||||
QString m_recommendedBorderSize;
|
||||
QString m_plugin;
|
||||
|
|
|
@ -499,11 +499,6 @@ bool EffectsHandlerImpl::decorationsHaveAlpha() const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EffectsHandlerImpl::decorationSupportsBlurBehind() const
|
||||
{
|
||||
return Decoration::DecorationBridge::self()->needsBlur();
|
||||
}
|
||||
|
||||
// start another painting pass
|
||||
void EffectsHandlerImpl::startPaint()
|
||||
{
|
||||
|
|
|
@ -172,8 +172,6 @@ public:
|
|||
|
||||
bool decorationsHaveAlpha() const override;
|
||||
|
||||
bool decorationSupportsBlurBehind() const override;
|
||||
|
||||
EffectFrame* effectFrame(EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment) const override;
|
||||
|
||||
QVariant kwinOption(KWinOption kwopt) override;
|
||||
|
|
|
@ -415,21 +415,20 @@ bool BlurEffect::supported()
|
|||
return supported;
|
||||
}
|
||||
|
||||
bool BlurEffect::decorationSupportsBlurBehind(const EffectWindow *w) const
|
||||
{
|
||||
return w->decoration() && !w->decoration()->blurRegion().isNull();
|
||||
}
|
||||
|
||||
QRegion BlurEffect::decorationBlurRegion(const EffectWindow *w) const
|
||||
{
|
||||
if (!w || !effects->decorationSupportsBlurBehind() || !w->decoration()) {
|
||||
if (!decorationSupportsBlurBehind(w)) {
|
||||
return QRegion();
|
||||
}
|
||||
|
||||
QRegion decorationRegion = QRegion(w->decoration()->rect()) - w->decorationInnerRect();
|
||||
|
||||
if (!w->decoration()->blurRegion().isNull()) {
|
||||
//! we return only blurred regions that belong to decoration region
|
||||
return decorationRegion.intersected(w->decoration()->blurRegion());
|
||||
}
|
||||
|
||||
//! when decoration requests blur but does not provide any blur region we can assume it prefers entire decoration region
|
||||
return decorationRegion;
|
||||
//! we return only blurred regions that belong to decoration region
|
||||
return decorationRegion.intersected(w->decoration()->blurRegion());
|
||||
}
|
||||
|
||||
QRect BlurEffect::expand(const QRect &rect) const
|
||||
|
@ -456,7 +455,7 @@ QRegion BlurEffect::blurRegion(const EffectWindow *w) const
|
|||
if (value.isValid()) {
|
||||
const QRegion appRegion = qvariant_cast<QRegion>(value);
|
||||
if (!appRegion.isEmpty()) {
|
||||
if (w->decorationHasAlpha() && effects->decorationSupportsBlurBehind()) {
|
||||
if (w->decorationHasAlpha() && decorationSupportsBlurBehind(w)) {
|
||||
region = decorationBlurRegion(w);
|
||||
}
|
||||
region |= appRegion.translated(w->contentsRect().topLeft()) &
|
||||
|
@ -466,7 +465,7 @@ QRegion BlurEffect::blurRegion(const EffectWindow *w) const
|
|||
// for the whole window.
|
||||
region = w->rect();
|
||||
}
|
||||
} else if (w->decorationHasAlpha() && effects->decorationSupportsBlurBehind()) {
|
||||
} else if (w->decorationHasAlpha() && decorationSupportsBlurBehind(w)) {
|
||||
// If the client hasn't specified a blur region, we'll only enable
|
||||
// the effect behind the decoration.
|
||||
region = decorationBlurRegion(w);
|
||||
|
@ -599,8 +598,7 @@ bool BlurEffect::shouldBlur(const EffectWindow *w, int mask, const WindowPaintDa
|
|||
if ((scaled || (translated || (mask & PAINT_WINDOW_TRANSFORMED))) && !w->data(WindowForceBlurRole).toBool())
|
||||
return false;
|
||||
|
||||
bool blurBehindDecos = effects->decorationsHaveAlpha() &&
|
||||
effects->decorationSupportsBlurBehind();
|
||||
bool blurBehindDecos = effects->decorationsHaveAlpha() && decorationSupportsBlurBehind(w);
|
||||
|
||||
if (!w->hasAlpha() && w->opacity() >= 1.0 && !(blurBehindDecos && w->hasDecoration()))
|
||||
return false;
|
||||
|
|
|
@ -69,6 +69,7 @@ private:
|
|||
void updateTexture();
|
||||
QRegion blurRegion(const EffectWindow *w) const;
|
||||
QRegion decorationBlurRegion(const EffectWindow *w) const;
|
||||
bool decorationSupportsBlurBehind(const EffectWindow *w) const;
|
||||
bool shouldBlur(const EffectWindow *w, int mask, const WindowPaintData &data) const;
|
||||
void updateBlurRegion(EffectWindow *w) const;
|
||||
void doBlur(const QRegion &shape, const QRect &screen, const float opacity, const QMatrix4x4 &screenProjection, bool isDock, QRect windowRect);
|
||||
|
|
|
@ -855,10 +855,6 @@ class KWINEFFECTS_EXPORT EffectsHandler : public QObject
|
|||
* Whether window decorations use the alpha channel.
|
||||
*/
|
||||
Q_PROPERTY(bool decorationsHaveAlpha READ decorationsHaveAlpha)
|
||||
/**
|
||||
* Whether the window decorations support blurring behind the decoration.
|
||||
*/
|
||||
Q_PROPERTY(bool decorationSupportsBlurBehind READ decorationSupportsBlurBehind)
|
||||
Q_PROPERTY(CompositingType compositingType READ compositingType CONSTANT)
|
||||
Q_PROPERTY(QPoint cursorPos READ cursorPos)
|
||||
Q_PROPERTY(QSize virtualScreenSize READ virtualScreenSize NOTIFY virtualScreenSizeChanged)
|
||||
|
@ -1229,12 +1225,6 @@ public:
|
|||
*/
|
||||
virtual bool decorationsHaveAlpha() const = 0;
|
||||
|
||||
/**
|
||||
* Returns @a true if the window decorations support blurring behind the decoration, and @a false otherwise
|
||||
* @since 4.6
|
||||
*/
|
||||
virtual bool decorationSupportsBlurBehind() const = 0;
|
||||
|
||||
/**
|
||||
* Creates a new frame object. If the frame does not have a static size
|
||||
* then it will be located at @a position with @a alignment. A
|
||||
|
|
Loading…
Reference in a new issue