Skip to content
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 @@ -22,6 +22,7 @@ if(BETTERBLUR_X11)
KDecoration3::KDecoration
KF6::ConfigGui
KWinX11::kwin
Qt6::DBus
${XCB_LIBRARIES}
)
target_compile_definitions(better_blur_dx PRIVATE
Expand All @@ -36,6 +37,7 @@ else()
KDecoration3::KDecoration
KF6::ConfigGui
KWin::kwin
Qt6::DBus
${XCB_LIBRARIES}
)
target_compile_definitions(better_blur_dx PRIVATE
Expand Down
23 changes: 23 additions & 0 deletions src/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <wayland_server.h>
#endif

#include <QDBusConnection>
#include <QGuiApplication>
#include <QMatrix4x4>
#include <QScreen>
Expand Down Expand Up @@ -259,6 +260,12 @@ BlurEffect::BlurEffect()
connect(effects, &EffectsHandler::viewRemoved, this, &BlurEffect::slotViewRemoved);
#endif
connect(effects, &EffectsHandler::propertyNotify, this, &BlurEffect::slotPropertyNotify);
QDBusConnection::systemBus().connect(
QStringLiteral("org.freedesktop.login1"),
QStringLiteral("/org/freedesktop/login1"),
QStringLiteral("org.freedesktop.login1.Manager"),
QStringLiteral("PrepareForSleep"),
this, SLOT(slotPrepareForSleep(bool)));
connect(effects, &EffectsHandler::xcbConnectionChanged, this, [this]() {
net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this);
});
Expand Down Expand Up @@ -546,6 +553,22 @@ void BlurEffect::slotViewRemoved(KWin::RenderView *view)
}
}

void BlurEffect::slotPrepareForSleep(bool start)
{
if (start) {
return;
}

// GPU memory is powered down across suspend/hibernate - cached blur
// textures and texture compare query results may hold garbage afterwards,
// permanently wedging the conditional render / dirty region tracking.
// Drop all render data so everything is rebuilt on the next paint.
effects->makeOpenGLContextCurrent();
for (auto &[window, data] : m_windows) {
data.render.clear();
}
}

void BlurEffect::slotPropertyNotify(EffectWindow *w, long atom)
{
if (w && atom == net_wm_blur_region && net_wm_blur_region != XCB_ATOM_NONE) {
Expand Down
1 change: 1 addition & 0 deletions src/blur.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public Q_SLOTS:
void slotWindowAdded(KWin::EffectWindow *w);
void slotWindowDeleted(KWin::EffectWindow *w);
void slotViewRemoved(KWin::RenderView *view);
void slotPrepareForSleep(bool start);
void slotPropertyNotify(KWin::EffectWindow *w, long atom);
void setupDecorationConnections(EffectWindow *w);

Expand Down