Skip to content

Commit

Permalink
blur/fake-blur: wait 5 seconds before fetching desktop wallpaper to e…
Browse files Browse the repository at this point in the history
…nsure plasmashell has started
  • Loading branch information
taj-ny committed Jul 13, 2024
1 parent c9da043 commit f02e6a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand All @@ -625,14 +639,17 @@ 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)) {
desktop = w;
break;
}
}
if (!desktop) {
if (!desktop || !isDesktopWallpaperAvailable) {
return nullptr;
}

Expand Down
3 changes: 3 additions & 0 deletions src/blur.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ public Q_SLOTS:

QList<BlurValuesStruct> blurStrengthValues;

QTimer fakeBlurDesktopWallpaperTimer;
bool isDesktopWallpaperAvailable = false;

QHash<const Output*, GLTexture*> m_fakeBlurTextures;

// Windows to blur even when transformed.
Expand Down

0 comments on commit f02e6a0

Please sign in to comment.