xcb/kwindoweffects: Fix stripes when dpr is not an integer.

This commit is contained in:
Mouse Zhang 2022-11-08 10:55:59 +08:00 committed by Mouse Zhang
parent 5ec8b644c7
commit 51c54c1de4
1 changed files with 5 additions and 3 deletions

View File

@ -24,6 +24,8 @@
#include <xcb/xcb.h>
#include <cmath>
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