From e97eaffc6b1d5b65fbdcd25fa56c88b47fa5ad3c Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 9 Feb 2016 12:09:01 +0100 Subject: [PATCH] Scale blurbehind and contrast besides translating if the window we are blurring the background or adding contrast has a scale transform applied, scale the area to be blurred as well REVIEW:126980 --- effects/backgroundcontrast/contrast.cpp | 19 +++++++++++++++++-- effects/blur/blur.cpp | 19 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/effects/backgroundcontrast/contrast.cpp b/effects/backgroundcontrast/contrast.cpp index 168deb02b4..b6b40982c6 100644 --- a/effects/backgroundcontrast/contrast.cpp +++ b/effects/backgroundcontrast/contrast.cpp @@ -371,9 +371,24 @@ void ContrastEffect::drawWindow(EffectWindow *w, int mask, QRegion region, Windo if (shouldContrast(w, mask, data)) { QRegion shape = region & contrastRegion(w).translated(w->pos()) & screen; - const bool translated = data.xTranslation() || data.yTranslation(); // let's do the evil parts - someone wants to blur behind a transformed window - if (translated) { + const bool translated = data.xTranslation() || data.yTranslation(); + const bool scaled = data.xScale() != 1 || data.yScale() != 1; + if (scaled) { + QPoint pt = shape.boundingRect().topLeft(); + QVector shapeRects = shape.rects(); + shape = QRegion(); // clear + foreach (QRect r, shapeRects) { + r.moveTo(pt.x() + (r.x() - pt.x()) * data.xScale() + data.xTranslation(), + pt.y() + (r.y() - pt.y()) * data.yScale() + data.yTranslation()); + r.setWidth(r.width() * data.xScale()); + r.setHeight(r.height() * data.yScale()); + shape |= r; + } + shape = shape & region; + + //Only translated, not scaled + } else if (translated) { shape = shape.translated(data.xTranslation(), data.yTranslation()); shape = shape & region; } diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index 4723078af5..b044f78440 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -435,9 +435,24 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai if (shouldBlur(w, mask, data)) { QRegion shape = region & blurRegion(w).translated(w->pos()) & screen; - const bool translated = data.xTranslation() || data.yTranslation(); // let's do the evil parts - someone wants to blur behind a transformed window - if (translated) { + const bool translated = data.xTranslation() || data.yTranslation(); + const bool scaled = data.xScale() != 1 || data.yScale() != 1; + if (scaled) { + QPoint pt = shape.boundingRect().topLeft(); + QVector shapeRects = shape.rects(); + shape = QRegion(); // clear + foreach (QRect r, shapeRects) { + r.moveTo(pt.x() + (r.x() - pt.x()) * data.xScale() + data.xTranslation(), + pt.y() + (r.y() - pt.y()) * data.yScale() + data.yTranslation()); + r.setWidth(r.width() * data.xScale()); + r.setHeight(r.height() * data.yScale()); + shape |= r; + } + shape = shape & region; + + //Only translated, not scaled + } else if (translated) { shape = shape.translated(data.xTranslation(), data.yTranslation()); shape = shape & region; }