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).
This commit is contained in:
Vlad Zahorodnii 2024-08-30 00:16:37 +03:00
parent e4f9df54e6
commit 8f40b5b554
2 changed files with 3 additions and 8 deletions

View file

@ -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();

View file

@ -32,14 +32,14 @@ struct BlurEffectData
{
/// The region that should be blurred behind the window
std::optional<QRegion> content;
ItemEffect surfaceEffect;
/// The region that should be blurred behind the frame
std::optional<QRegion> frame;
ItemEffect decorationEffect;
/// The render data per screen. Screens can have different color spaces.
std::unordered_map<Output *, BlurRenderData> render;
ItemEffect windowEffect;
};
class BlurEffect : public KWin::Effect