Skip to content

Commit

Permalink
Merge pull request #128 from taj-ny/blur/force-blur/fix-x11-csd
Browse files Browse the repository at this point in the history
force-blur: fix blur region for x11 windows with csd
  • Loading branch information
taj-ny authored Dec 20, 2024
2 parents 2167a3f + f0814da commit 2dd786d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,15 @@ void BlurEffect::updateBlurRegion(EffectWindow *w, bool geometryChanged)

// Don't override blur region for menus that already have one. The window geometry could include shadows.
if (shouldForceBlur(w) && !((isMenu(w) || w->isTooltip()) && (content.has_value() || geometryChanged))) {
content = w->expandedGeometry().translated(-w->x(), -w->y()).toRect();
if (m_settings.forceBlur.blurDecorations && w->decoration()) {
frame = w->frameGeometry().translated(-w->x(), -w->y()).toRect();
// On X11, EffectWindow::contentsRect() includes GTK's client-side shadows, while on Wayland, it doesn't.
// The content region is translated by EffectWindow::contentsRect() in BlurEffect::blurRegion, causing the
// blur region to be off on X11. The frame region is not translated, so it is used instead.
const auto isX11WithCSD = !effects->waylandDisplay() && (w->frameGeometry() != w->bufferGeometry());
if (!isX11WithCSD) {
content = w->contentsRect().translated(-w->contentsRect().topLeft()).toRect();
}
if (isX11WithCSD || (m_settings.forceBlur.blurDecorations && w->decoration())) {
frame = w->frameGeometry().translated(-w->x(), -w->y()).toRect();;
}
}

Expand Down Expand Up @@ -340,7 +346,7 @@ void BlurEffect::slotWindowAdded(EffectWindow *w)
});
}

windowExpandedGeometryChangedConnections[w] = connect(w, &EffectWindow::windowExpandedGeometryChanged, this, [this,w]() {
windowFrameGeometryChangedConnections[w] = connect(w, &EffectWindow::windowFrameGeometryChanged, this, [this,w]() {
if (!w) {
return;
}
Expand Down Expand Up @@ -375,9 +381,9 @@ void BlurEffect::slotWindowDeleted(EffectWindow *w)
disconnect(*it);
windowBlurChangedConnections.erase(it);
}
if (auto it = windowExpandedGeometryChangedConnections.find(w); it != windowExpandedGeometryChangedConnections.end()) {
if (auto it = windowFrameGeometryChangedConnections.find(w); it != windowFrameGeometryChangedConnections.end()) {
disconnect(*it);
windowExpandedGeometryChangedConnections.erase(it);
windowFrameGeometryChangedConnections.erase(it);
}
if (auto it = std::find(m_allWindows.begin(), m_allWindows.end(), w); it != m_allWindows.end()) {
m_allWindows.erase(it);
Expand Down
2 changes: 1 addition & 1 deletion src/blur.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public Q_SLOTS:
QMatrix4x4 m_colorMatrix;

QMap<EffectWindow *, QMetaObject::Connection> windowBlurChangedConnections;
QMap<EffectWindow *, QMetaObject::Connection> windowExpandedGeometryChangedConnections;
QMap<EffectWindow *, QMetaObject::Connection> windowFrameGeometryChangedConnections;
QMap<Output *, QMetaObject::Connection> screenChangedConnections;
std::unordered_map<EffectWindow *, BlurEffectData> m_windows;

Expand Down

0 comments on commit 2dd786d

Please sign in to comment.