From cc0434d34cb0cc579c2c77714ac9f97be93016e1 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 20 Sep 2022 11:25:02 +0200 Subject: [PATCH] effects/blur: use effect-local data instead of window data for blur regions --- src/effects/blur/blur.cpp | 18 +++++++----------- src/effects/blur/blur.h | 3 ++- src/libkwineffects/kwineffects.h | 1 - 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/effects/blur/blur.cpp b/src/effects/blur/blur.cpp index 53e54950cf..a6626ef601 100644 --- a/src/effects/blur/blur.cpp +++ b/src/effects/blur/blur.cpp @@ -277,7 +277,7 @@ void BlurEffect::reconfigure(ReconfigureFlags flags) effects->addRepaintFull(); } -void BlurEffect::updateBlurRegion(EffectWindow *w) const +void BlurEffect::updateBlurRegion(EffectWindow *w) { QRegion region; bool valid = false; @@ -312,14 +312,10 @@ void BlurEffect::updateBlurRegion(EffectWindow *w) const } } - // If the specified blur region is empty, enable blur for the whole window. - if (region.isEmpty() && valid) { - // Set the data to a dummy value. - // This is needed to be able to distinguish between the value not - // being set, and being set to an empty region. - w->setData(WindowBlurBehindRole, 1); + if (valid) { + blurRegions[w] = region; } else { - w->setData(WindowBlurBehindRole, region); + blurRegions.remove(w); } } @@ -344,6 +340,7 @@ void BlurEffect::slotWindowAdded(EffectWindow *w) void BlurEffect::slotWindowDeleted(EffectWindow *w) { + blurRegions.remove(w); auto it = windowBlurChangedConnections.find(w); if (it == windowBlurChangedConnections.end()) { return; @@ -453,9 +450,8 @@ QRegion BlurEffect::blurRegion(const EffectWindow *w) const { QRegion region; - const QVariant value = w->data(WindowBlurBehindRole); - if (value.isValid()) { - const QRegion appRegion = qvariant_cast(value); + if (auto it = blurRegions.find(w); it != blurRegions.end()) { + const QRegion &appRegion = *it; if (!appRegion.isEmpty()) { if (w->decorationHasAlpha() && decorationSupportsBlurBehind(w)) { region = decorationBlurRegion(w); diff --git a/src/effects/blur/blur.h b/src/effects/blur/blur.h index 90b908d8bc..989b4fbfe2 100644 --- a/src/effects/blur/blur.h +++ b/src/effects/blur/blur.h @@ -74,7 +74,7 @@ private: 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 updateBlurRegion(EffectWindow *w); void doBlur(const QRegion &shape, const QRect &screen, const float opacity, const QMatrix4x4 &screenProjection, bool isDock, QRect windowRect); void uploadRegion(QVector2D *&map, const QRegion ®ion, const int downSampleIterations); void uploadGeometry(GLVertexBuffer *vbo, const QRegion &blurRegion, const QRegion &windowRegion); @@ -123,6 +123,7 @@ private: QVector blurStrengthValues; QMap windowBlurChangedConnections; + QMap blurRegions; static KWaylandServer::BlurManagerInterface *s_blurManager; static QTimer *s_blurManagerRemoveTimer; diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index ec93e309bc..3f7ef88f10 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -174,7 +174,6 @@ enum DataRole { WindowMinimizedGrabRole, WindowUnminimizedGrabRole, WindowForceBlurRole, ///< For fullscreen effects to enforce blurring of windows, - WindowBlurBehindRole, ///< For single windows to blur behind WindowForceBackgroundContrastRole, ///< For fullscreen effects to enforce the background contrast, WindowBackgroundContrastRole, ///< For single windows to enable Background contrast };