Changeset View
Changeset View
Standalone View
Standalone View
src/platforms/xcb/kwindoweffects.cpp
Show All 13 Lines | |||||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public | 15 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "kwindoweffects_x11.h" | 19 | #include "kwindoweffects_x11.h" | ||
20 | 20 | | |||
21 | #include <QVarLengthArray> | 21 | #include <QVarLengthArray> | ||
22 | #include <QGuiApplication> | ||||
22 | 23 | | |||
23 | #include "kwindowsystem.h" | 24 | #include "kwindowsystem.h" | ||
24 | #include <config-kwindowsystem.h> | 25 | #include <config-kwindowsystem.h> | ||
25 | 26 | | |||
26 | #include <xcb/xcb.h> | 27 | #include <xcb/xcb.h> | ||
27 | #include <QX11Info> | 28 | #include <QX11Info> | ||
28 | #include <QMatrix4x4> | 29 | #include <QMatrix4x4> | ||
29 | #include <QWidget> | 30 | #include <QWidget> | ||
▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Line(s) | 255 | if (!atom) { | |||
255 | return; | 256 | return; | ||
256 | } | 257 | } | ||
257 | 258 | | |||
258 | if (enable) { | 259 | if (enable) { | ||
259 | QVector<QRect> rects = region.rects(); | 260 | QVector<QRect> rects = region.rects(); | ||
260 | QVector<uint32_t> data; | 261 | QVector<uint32_t> data; | ||
261 | data.reserve(rects.count() * 4); | 262 | data.reserve(rects.count() * 4); | ||
262 | Q_FOREACH (const QRect &r, rects) { | 263 | Q_FOREACH (const QRect &r, rects) { | ||
263 | data << r.x() << r.y() << r.width() << r.height(); | 264 | // kwin on X uses device pixels, convert from logical | ||
265 | auto dpr = qApp->devicePixelRatio(); | ||||
266 | data << r.x() * dpr << r.y() * dpr << r.width() * dpr << r.height() * dpr; | ||||
zzag: should we floor or round? | |||||
Our best option is to match QHighDpi::toNativePixels(QRect) davidedmundson: Our best option is to match QHighDpi::toNativePixels(QRect)
Which seems to floor | |||||
264 | } | 267 | } | ||
265 | 268 | | |||
266 | xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, atom->atom, XCB_ATOM_CARDINAL, | 269 | xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, atom->atom, XCB_ATOM_CARDINAL, | ||
267 | 32, data.size(), data.constData()); | 270 | 32, data.size(), data.constData()); | ||
268 | } else { | 271 | } else { | ||
269 | xcb_delete_property(c, window, atom->atom); | 272 | xcb_delete_property(c, window, atom->atom); | ||
270 | } | 273 | } | ||
271 | } | 274 | } | ||
272 | 275 | | |||
273 | void KWindowEffectsPrivateX11::enableBackgroundContrast(WId window, bool enable, qreal contrast, qreal intensity, qreal saturation, const QRegion ®ion) | 276 | void KWindowEffectsPrivateX11::enableBackgroundContrast(WId window, bool enable, qreal contrast, qreal intensity, qreal saturation, const QRegion ®ion) | ||
274 | { | 277 | { | ||
275 | xcb_connection_t *c = QX11Info::connection(); | 278 | xcb_connection_t *c = QX11Info::connection(); | ||
276 | const QByteArray effectName = QByteArrayLiteral("_KDE_NET_WM_BACKGROUND_CONTRAST_REGION"); | 279 | const QByteArray effectName = QByteArrayLiteral("_KDE_NET_WM_BACKGROUND_CONTRAST_REGION"); | ||
277 | xcb_intern_atom_cookie_t atomCookie = xcb_intern_atom_unchecked(c, false, effectName.length(), effectName.constData()); | 280 | xcb_intern_atom_cookie_t atomCookie = xcb_intern_atom_unchecked(c, false, effectName.length(), effectName.constData()); | ||
278 | QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atom(xcb_intern_atom_reply(c, atomCookie, nullptr)); | 281 | QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atom(xcb_intern_atom_reply(c, atomCookie, nullptr)); | ||
279 | if (!atom) { | 282 | if (!atom) { | ||
280 | return; | 283 | return; | ||
281 | } | 284 | } | ||
282 | 285 | | |||
283 | if (enable) { | 286 | if (enable) { | ||
284 | QVector<QRect> rects = region.rects(); | 287 | QVector<QRect> rects = region.rects(); | ||
285 | QVector<uint32_t> data; | 288 | QVector<uint32_t> data; | ||
286 | data.reserve(rects.count() * 4 + 16); | 289 | data.reserve(rects.count() * 4 + 16); | ||
287 | Q_FOREACH (const QRect &r, rects) { | 290 | Q_FOREACH (const QRect &r, rects) { | ||
288 | data << r.x() << r.y() << r.width() << r.height(); | 291 | auto dpr = qApp->devicePixelRatio(); | ||
292 | data << r.x() * dpr << r.y() * dpr << r.width() * dpr << r.height() * dpr; | ||||
289 | } | 293 | } | ||
290 | 294 | | |||
291 | QMatrix4x4 satMatrix; //saturation | 295 | QMatrix4x4 satMatrix; //saturation | ||
292 | QMatrix4x4 intMatrix; //intensity | 296 | QMatrix4x4 intMatrix; //intensity | ||
293 | QMatrix4x4 contMatrix; //contrast | 297 | QMatrix4x4 contMatrix; //contrast | ||
294 | 298 | | |||
295 | //Saturation matrix | 299 | //Saturation matrix | ||
296 | if (!qFuzzyCompare(saturation, 1.0)) { | 300 | if (!qFuzzyCompare(saturation, 1.0)) { | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |
should we floor or round?