From 4326d3f029bd904aab66a20020e4e70150011e6e Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sat, 19 Feb 2022 18:38:05 +0200 Subject: [PATCH] effects/blur: Avoid shrinking unrelated opaque regions Currently, the blur effect will shrink an opaque region even if it doesn't intersect m_currentBlur. This ensures that the blur effect won't do a stupid thing such as clipping the opaque region of the desktop window. --- src/effects/blur/blur.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/effects/blur/blur.cpp b/src/effects/blur/blur.cpp index a451c15ea3..763f0c2bdb 100644 --- a/src/effects/blur/blur.cpp +++ b/src/effects/blur/blur.cpp @@ -542,20 +542,22 @@ void BlurEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std:: return; } - // to blur an area partially we have to shrink the opaque area of a window - QRegion newClip; - const QRegion oldClip = data.clip; - for (const QRect &rect : data.clip) { - newClip |= rect.adjusted(m_expandSize, m_expandSize, -m_expandSize, -m_expandSize); - } - data.clip = newClip; + if (data.clip.intersects(m_currentBlur)) { + // to blur an area partially we have to shrink the opaque area of a window + QRegion newClip; + const QRegion oldClip = data.clip; + for (const QRect &rect : data.clip) { + newClip |= rect.adjusted(m_expandSize, m_expandSize, -m_expandSize, -m_expandSize); + } + data.clip = newClip; - // we don't have to blur a region we don't see - m_currentBlur -= newClip; - // if we have to paint a non-opaque part of this window that intersects with the - // currently blurred region we have to redraw the whole region - if ((data.paint - oldClip).intersects(m_currentBlur)) { - data.paint |= m_currentBlur; + // we don't have to blur a region we don't see + m_currentBlur -= newClip; + // if we have to paint a non-opaque part of this window that intersects with the + // currently blurred region we have to redraw the whole region + if ((data.paint - oldClip).intersects(m_currentBlur)) { + data.paint |= m_currentBlur; + } } // in case this window has regions to be blurred