Changeset View
Changeset View
Standalone View
Standalone View
effects/blur/blur.cpp
Show All 25 Lines | |||||
26 | 26 | | |||
27 | #include <QGuiApplication> | 27 | #include <QGuiApplication> | ||
28 | #include <QMatrix4x4> | 28 | #include <QMatrix4x4> | ||
29 | #include <QScreen> // for QGuiApplication | 29 | #include <QScreen> // for QGuiApplication | ||
30 | #include <QTime> | 30 | #include <QTime> | ||
31 | #include <QWindow> | 31 | #include <QWindow> | ||
32 | #include <cmath> // for ceil() | 32 | #include <cmath> // for ceil() | ||
33 | 33 | | |||
34 | #include <KWayland/Server/surface_interface.h> | 34 | #include <KWaylandServer/surface_interface.h> | ||
35 | #include <KWayland/Server/blur_interface.h> | 35 | #include <KWaylandServer/blur_interface.h> | ||
36 | #include <KWayland/Server/shadow_interface.h> | 36 | #include <KWaylandServer/shadow_interface.h> | ||
37 | #include <KWayland/Server/display.h> | 37 | #include <KWaylandServer/display.h> | ||
38 | #include <KSharedConfig> | 38 | #include <KSharedConfig> | ||
39 | #include <KConfigGroup> | 39 | #include <KConfigGroup> | ||
40 | 40 | | |||
41 | namespace KWin | 41 | namespace KWin | ||
42 | { | 42 | { | ||
43 | 43 | | |||
44 | static const QByteArray s_blurAtomName = QByteArrayLiteral("_KDE_NET_WM_BLUR_BEHIND_REGION"); | 44 | static const QByteArray s_blurAtomName = QByteArrayLiteral("_KDE_NET_WM_BLUR_BEHIND_REGION"); | ||
45 | 45 | | |||
46 | BlurEffect::BlurEffect() | 46 | BlurEffect::BlurEffect() | ||
47 | { | 47 | { | ||
48 | initConfig<BlurConfig>(); | 48 | initConfig<BlurConfig>(); | ||
49 | m_shader = new BlurShader(this); | 49 | m_shader = new BlurShader(this); | ||
50 | 50 | | |||
51 | initBlurStrengthValues(); | 51 | initBlurStrengthValues(); | ||
52 | reconfigure(ReconfigureAll); | 52 | reconfigure(ReconfigureAll); | ||
53 | 53 | | |||
54 | // ### Hackish way to announce support. | 54 | // ### Hackish way to announce support. | ||
55 | // Should be included in _NET_SUPPORTED instead. | 55 | // Should be included in _NET_SUPPORTED instead. | ||
56 | if (m_shader && m_shader->isValid() && m_renderTargetsValid) { | 56 | if (m_shader && m_shader->isValid() && m_renderTargetsValid) { | ||
57 | net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this); | 57 | net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this); | ||
58 | KWayland::Server::Display *display = effects->waylandDisplay(); | 58 | KWaylandServer::Display *display = effects->waylandDisplay(); | ||
59 | if (display) { | 59 | if (display) { | ||
60 | m_blurManager = display->createBlurManager(this); | 60 | m_blurManager = display->createBlurManager(this); | ||
61 | m_blurManager->create(); | 61 | m_blurManager->create(); | ||
62 | } | 62 | } | ||
63 | } else { | 63 | } else { | ||
64 | net_wm_blur_region = 0; | 64 | net_wm_blur_region = 0; | ||
65 | } | 65 | } | ||
66 | 66 | | |||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 284 | for (unsigned int i = 0; i < value.size() / sizeof(uint32_t);) { | |||
286 | int y = cardinals[i++]; | 286 | int y = cardinals[i++]; | ||
287 | int w = cardinals[i++]; | 287 | int w = cardinals[i++]; | ||
288 | int h = cardinals[i++]; | 288 | int h = cardinals[i++]; | ||
289 | region += QRect(x, y, w, h); | 289 | region += QRect(x, y, w, h); | ||
290 | } | 290 | } | ||
291 | } | 291 | } | ||
292 | } | 292 | } | ||
293 | 293 | | |||
294 | KWayland::Server::SurfaceInterface *surf = w->surface(); | 294 | KWaylandServer::SurfaceInterface *surf = w->surface(); | ||
295 | 295 | | |||
296 | if (surf && surf->blur()) { | 296 | if (surf && surf->blur()) { | ||
297 | region = surf->blur()->region(); | 297 | region = surf->blur()->region(); | ||
298 | } | 298 | } | ||
299 | 299 | | |||
300 | if (auto internal = w->internalWindow()) { | 300 | if (auto internal = w->internalWindow()) { | ||
301 | const auto property = internal->property("kwin_blur"); | 301 | const auto property = internal->property("kwin_blur"); | ||
302 | if (property.isValid()) { | 302 | if (property.isValid()) { | ||
Show All 9 Lines | 309 | if (region.isEmpty() && (!value.isNull() || (surf && surf->blur()))) { | |||
312 | // being set, and being set to an empty region. | 312 | // being set, and being set to an empty region. | ||
313 | w->setData(WindowBlurBehindRole, 1); | 313 | w->setData(WindowBlurBehindRole, 1); | ||
314 | } else | 314 | } else | ||
315 | w->setData(WindowBlurBehindRole, region); | 315 | w->setData(WindowBlurBehindRole, region); | ||
316 | } | 316 | } | ||
317 | 317 | | |||
318 | void BlurEffect::slotWindowAdded(EffectWindow *w) | 318 | void BlurEffect::slotWindowAdded(EffectWindow *w) | ||
319 | { | 319 | { | ||
320 | KWayland::Server::SurfaceInterface *surf = w->surface(); | 320 | KWaylandServer::SurfaceInterface *surf = w->surface(); | ||
321 | 321 | | |||
322 | if (surf) { | 322 | if (surf) { | ||
323 | windowBlurChangedConnections[w] = connect(surf, &KWayland::Server::SurfaceInterface::blurChanged, this, [this, w] () { | 323 | windowBlurChangedConnections[w] = connect(surf, &KWaylandServer::SurfaceInterface::blurChanged, this, [this, w] () { | ||
324 | if (w) { | 324 | if (w) { | ||
325 | updateBlurRegion(w); | 325 | updateBlurRegion(w); | ||
326 | } | 326 | } | ||
327 | }); | 327 | }); | ||
328 | } | 328 | } | ||
329 | if (auto internal = w->internalWindow()) { | 329 | if (auto internal = w->internalWindow()) { | ||
330 | internal->installEventFilter(this); | 330 | internal->installEventFilter(this); | ||
331 | } | 331 | } | ||
▲ Show 20 Lines • Show All 504 Lines • Show Last 20 Lines |