From 8f40b5b5541b2600af0f43a22753646f877cdddb Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 30 Aug 2024 00:16:37 +0300 Subject: [PATCH] plugins/blur: Fix a crash in BlurEffect::updateBlurRegion() The updateBlurRegion() creates ItemEffect() objects to block direct scanout. However, it doesn't take into account that the surface item can be null when a window is added. It can happen with Xwayland windows. The blur effect creates ItemEffect objects for the SurfaceItem and the DecorationItem, which is reasonable. But on the other hand, the blur effect still operates per window. So this change simply makes the blur effect register an ItemEffect with the WindowItem. When proper per item effects are supported, this can be changed (the blur effect would need to monitor the wl_surface getting added and removed). --- src/plugins/blur/blur.cpp | 7 +------ src/plugins/blur/blur.h | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/plugins/blur/blur.cpp b/src/plugins/blur/blur.cpp index 53b2b1fa7e..9cde73b9ba 100644 --- a/src/plugins/blur/blur.cpp +++ b/src/plugins/blur/blur.cpp @@ -266,12 +266,7 @@ void BlurEffect::updateBlurRegion(EffectWindow *w) BlurEffectData &data = m_windows[w]; data.content = content; data.frame = frame; - if (content) { - data.surfaceEffect = ItemEffect(w->windowItem()->surfaceItem()); - } - if (frame) { - data.surfaceEffect = ItemEffect(w->windowItem()->decorationItem()); - } + data.windowEffect = ItemEffect(w->windowItem()); } else { if (auto it = m_windows.find(w); it != m_windows.end()) { effects->makeOpenGLContextCurrent(); diff --git a/src/plugins/blur/blur.h b/src/plugins/blur/blur.h index 94b6c50eef..091cb1c524 100644 --- a/src/plugins/blur/blur.h +++ b/src/plugins/blur/blur.h @@ -32,14 +32,14 @@ struct BlurEffectData { /// The region that should be blurred behind the window std::optional content; - ItemEffect surfaceEffect; /// The region that should be blurred behind the frame std::optional frame; - ItemEffect decorationEffect; /// The render data per screen. Screens can have different color spaces. std::unordered_map render; + + ItemEffect windowEffect; }; class BlurEffect : public KWin::Effect