From 51c54c1de4e5a2ba559ccfa34a9b1379ba91df09 Mon Sep 17 00:00:00 2001 From: Mouse Zhang Date: Tue, 8 Nov 2022 10:55:59 +0800 Subject: [PATCH] xcb/kwindoweffects: Fix stripes when dpr is not an integer. --- src/platforms/xcb/kwindoweffects.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/platforms/xcb/kwindoweffects.cpp b/src/platforms/xcb/kwindoweffects.cpp index d01c121..a9c925e 100644 --- a/src/platforms/xcb/kwindoweffects.cpp +++ b/src/platforms/xcb/kwindoweffects.cpp @@ -24,6 +24,8 @@ #include +#include + using namespace KWindowEffects; KWindowEffectsPrivateX11::KWindowEffectsPrivateX11() @@ -261,7 +263,7 @@ void KWindowEffectsPrivateX11::enableBlurBehind(WId window, bool enable, const Q for (const QRect &r : region) { // kwin on X uses device pixels, convert from logical auto dpr = qApp->devicePixelRatio(); - data << r.x() * dpr << r.y() * dpr << r.width() * dpr << r.height() * dpr; + data << std::floor(r.x() * dpr) << std::floor(r.y() * dpr) << std::ceil(r.width() * dpr) << std::ceil(r.height() * dpr); } xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, atom->atom, XCB_ATOM_CARDINAL, 32, data.size(), data.constData()); @@ -324,7 +326,7 @@ void KWindowEffectsPrivateX11::setBackgroundFrost(QWindow *window, QColor color, data.reserve(region.rectCount() * 4 + 4); for (const QRect &r : region) { auto dpr = qApp->devicePixelRatio(); - data << r.x() * dpr << r.y() * dpr << r.width() * dpr << r.height() * dpr; + data << std::floor(r.x() * dpr) << std::floor(r.y() * dpr) << std::ceil(r.width() * dpr) << std::ceil(r.height() * dpr); } data << color.red(); @@ -364,7 +366,7 @@ void KWindowEffectsPrivateX11::enableBackgroundContrast(WId window, bool enable, data.reserve(region.rectCount() * 4 + 16); for (const QRect &r : region) { auto dpr = qApp->devicePixelRatio(); - data << r.x() * dpr << r.y() * dpr << r.width() * dpr << r.height() * dpr; + data << std::floor(r.x() * dpr) << std::floor(r.y() * dpr) << std::ceil(r.width() * dpr) << std::ceil(r.height() * dpr); } QMatrix4x4 satMatrix; // saturation