From f02e6a0aa348ee2ddb2cb464786994c032e62151 Mon Sep 17 00:00:00 2001 From: taj-ny <79316397+taj-ny@users.noreply.github.com> Date: Sat, 13 Jul 2024 17:00:43 +0200 Subject: [PATCH] blur/fake-blur: wait 5 seconds before fetching desktop wallpaper to ensure plasmashell has started --- src/blur.cpp | 19 ++++++++++++++++++- src/blur.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/blur.cpp b/src/blur.cpp index 88276fe67..d39246ecc 100644 --- a/src/blur.cpp +++ b/src/blur.cpp @@ -145,6 +145,14 @@ BlurEffect::BlurEffect() slotWindowAdded(window); } + fakeBlurDesktopWallpaperTimer.setSingleShot(true); + fakeBlurDesktopWallpaperTimer.callOnTimeout([this]() { + isDesktopWallpaperAvailable = true; + if (m_settings.fakeBlur.enable && m_settings.fakeBlur.imageSource == FakeBlurImageSource::DesktopWallpaper) { + effects->addRepaintFull(); + } + }); + m_valid = true; } @@ -615,6 +623,12 @@ void BlurEffect::drawWindow(const RenderTarget &renderTarget, const RenderViewpo // Draw the window over the blurred area effects->drawWindow(renderTarget, viewport, w, mask, region, data); + + // Couldn't find a better way to check if PlasmaShell has started. The desktop will still be black at this point, + // so we have to wait. + if (w->isDesktop() && !isDesktopWallpaperAvailable && !fakeBlurDesktopWallpaperTimer.isActive()) { + fakeBlurDesktopWallpaperTimer.start(5000); + } } GLTexture *BlurEffect::ensureFakeBlurTexture(const Output *output) @@ -625,6 +639,9 @@ GLTexture *BlurEffect::ensureFakeBlurTexture(const Output *output) QImage image; if (m_settings.fakeBlur.imageSource == FakeBlurImageSource::DesktopWallpaper) { + // It's much easier to just take a screenshot of the desktop than to read the wallpaper package path from + // a configuration file, find the image with the right resolution and scale, center or tile it. + EffectWindow *desktop; for (EffectWindow *w : effects->stackingOrder()) { if (w && w->isDesktop() && (!output || w->window()->output() == output)) { @@ -632,7 +649,7 @@ GLTexture *BlurEffect::ensureFakeBlurTexture(const Output *output) break; } } - if (!desktop) { + if (!desktop || !isDesktopWallpaperAvailable) { return nullptr; } diff --git a/src/blur.h b/src/blur.h index 89756edc8..84adb043c 100644 --- a/src/blur.h +++ b/src/blur.h @@ -174,6 +174,9 @@ public Q_SLOTS: QList blurStrengthValues; + QTimer fakeBlurDesktopWallpaperTimer; + bool isDesktopWallpaperAvailable = false; + QHash m_fakeBlurTextures; // Windows to blur even when transformed.