Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if(BETTERBLUR_WAYLAND)
KDecoration3::KDecoration
KF6::ConfigGui
KWin::kwin
Qt6::DBus
)
install(TARGETS forceblur DESTINATION ${KDE_INSTALL_PLUGINDIR}/kwin/effects/plugins)
endif()
Expand All @@ -38,6 +39,7 @@ if(BETTERBLUR_X11)
KDecoration3::KDecoration
KF6::ConfigGui
KWinX11::kwin
Qt6::DBus
)
target_compile_definitions(forceblur_x11 PRIVATE BETTERBLUR_X11)
install(TARGETS forceblur_x11 DESTINATION ${KDE_INSTALL_PLUGINDIR}/kwin-x11/effects/plugins)
Expand Down
54 changes: 54 additions & 0 deletions src/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
#include "wayland/display.h"
#include "wayland/surface.h"

#include <QDBusConnection>
#include <QGuiApplication>
#include <QImage>
#include <QMatrix4x4>
#include <QScreen>
#include <QStringLiteral>
#include <QTime>
#include <QTimer>
#include <QWindow>
Expand Down Expand Up @@ -160,6 +162,8 @@ BlurEffect::BlurEffect()
slotScreenAdded(screen);
}

updateWallpaperChangedConnection();

m_valid = true;
}

Expand All @@ -169,6 +173,17 @@ BlurEffect::~BlurEffect()
if (s_blurManager) {
s_blurManagerRemoveTimer->start(1000);
}

// Disconnect from DBus if connected
if (m_wallpaperChangedConnectionActive)
{
QDBusConnection::sessionBus().disconnect(QStringLiteral("org.kde.plasmashell"),
QStringLiteral("/PlasmaShell"),
QStringLiteral("org.kde.PlasmaShell"),
QStringLiteral("wallpaperChanged"),
this,
SLOT(slotWallpaperChanged(uint)));
}
}

void BlurEffect::initBlurStrengthValues()
Expand Down Expand Up @@ -232,6 +247,7 @@ void BlurEffect::initBlurStrengthValues()
void BlurEffect::reconfigure(ReconfigureFlags flags)
{
m_settings.read();
updateWallpaperChangedConnection();

m_iterationCount = blurStrengthValues[m_settings.general.blurStrength].iteration;
m_offset = blurStrengthValues[m_settings.general.blurStrength].offset;
Expand Down Expand Up @@ -329,6 +345,32 @@ bool BlurEffect::hasStaticBlur(EffectWindow *w)
return true;
}

void BlurEffect::updateWallpaperChangedConnection()
{
const bool shouldBeConnected = m_settings.staticBlur.enable
&& m_settings.staticBlur.imageSource == StaticBlurImageSource::DesktopWallpaper;

if (shouldBeConnected && !m_wallpaperChangedConnectionActive) {
m_wallpaperChangedConnectionActive = QDBusConnection::sessionBus().connect(QStringLiteral("org.kde.plasmashell"),
QStringLiteral("/PlasmaShell"),
QStringLiteral("org.kde.PlasmaShell"),
QStringLiteral("wallpaperChanged"),
this,
SLOT(slotWallpaperChanged(uint)));
if (!m_wallpaperChangedConnectionActive) {
qCWarning(KWIN_BLUR) <<"Failed to connect to wallpaperChanged DBus signal.";
}
} else if (!shouldBeConnected && m_wallpaperChangedConnectionActive) {
QDBusConnection::sessionBus().disconnect(QStringLiteral("org.kde.plasmashell"),
QStringLiteral("/PlasmaShell"),
QStringLiteral("org.kde.PlasmaShell"),
QStringLiteral("wallpaperChanged"),
this,
SLOT(slotWallpaperChanged(uint)));
m_wallpaperChangedConnectionActive = false;
}
}

void BlurEffect::slotWindowAdded(EffectWindow *w)
{
SurfaceInterface *surf = w->surface();
Expand Down Expand Up @@ -434,6 +476,18 @@ void BlurEffect::setupDecorationConnections(EffectWindow *w)
});
}

void BlurEffect::slotWallpaperChanged(uint screenNum) {
const auto screens = effects->screens();

if (screenNum >= screens.size()) {
return;
}

Output *screen = screens.at(screenNum);

m_staticBlurTextures.erase(screen);
}

bool BlurEffect::eventFilter(QObject *watched, QEvent *event)
{
auto internal = qobject_cast<QWindow *>(watched);
Expand Down
5 changes: 5 additions & 0 deletions src/blur.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public Q_SLOTS:
void slotPropertyNotify(KWin::EffectWindow *w, long atom);
void setupDecorationConnections(EffectWindow *w);

private Q_SLOTS:
void slotWallpaperChanged(uint screenNum);

private:
void initBlurStrengthValues();
QRegion blurRegion(EffectWindow *w) const;
Expand All @@ -93,6 +96,7 @@ public Q_SLOTS:
bool shouldForceBlur(const EffectWindow *w) const;
void updateBlurRegion(EffectWindow *w, bool geometryChanged = false);
bool hasStaticBlur(EffectWindow *w);
void updateWallpaperChangedConnection();
QMatrix4x4 colorMatrix(const float &brightness, const float &saturation, const float &contrast) const;

/*
Expand Down Expand Up @@ -213,6 +217,7 @@ public Q_SLOTS:
QList<BlurValuesStruct> blurStrengthValues;

std::unordered_map<const Output*, std::unique_ptr<GLTexture>> m_staticBlurTextures;
bool m_wallpaperChangedConnectionActive = false;

// Windows to blur even when transformed.
QList<const EffectWindow*> m_blurWhenTransformed;
Expand Down