Changeset View
Changeset View
Standalone View
Standalone View
effects/blur/blur.cpp
Show All 23 Lines | |||||
24 | // KConfigSkeleton | 24 | // KConfigSkeleton | ||
25 | #include "blurconfig.h" | 25 | #include "blurconfig.h" | ||
26 | 26 | | |||
27 | #include <QGuiApplication> | 27 | #include <QGuiApplication> | ||
28 | #include <QMatrix4x4> | 28 | #include <QMatrix4x4> | ||
29 | #include <QLinkedList> | 29 | #include <QLinkedList> | ||
30 | #include <QScreen> // for QGuiApplication | 30 | #include <QScreen> // for QGuiApplication | ||
31 | #include <QTime> | 31 | #include <QTime> | ||
32 | #include <QWindow> | ||||
32 | #include <cmath> // for ceil() | 33 | #include <cmath> // for ceil() | ||
33 | 34 | | |||
34 | #include <KWayland/Server/surface_interface.h> | 35 | #include <KWayland/Server/surface_interface.h> | ||
35 | #include <KWayland/Server/blur_interface.h> | 36 | #include <KWayland/Server/blur_interface.h> | ||
36 | #include <KWayland/Server/shadow_interface.h> | 37 | #include <KWayland/Server/shadow_interface.h> | ||
37 | #include <KWayland/Server/display.h> | 38 | #include <KWayland/Server/display.h> | ||
38 | #include <KSharedConfig> | 39 | #include <KSharedConfig> | ||
39 | #include <KConfigGroup> | 40 | #include <KConfigGroup> | ||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Line(s) | 252 | { | |||
267 | } | 268 | } | ||
268 | 269 | | |||
269 | KWayland::Server::SurfaceInterface *surf = w->surface(); | 270 | KWayland::Server::SurfaceInterface *surf = w->surface(); | ||
270 | 271 | | |||
271 | if (surf && surf->blur()) { | 272 | if (surf && surf->blur()) { | ||
272 | region = surf->blur()->region(); | 273 | region = surf->blur()->region(); | ||
273 | } | 274 | } | ||
274 | 275 | | |||
276 | if (auto internal = w->internalWindow()) { | ||||
277 | const auto property = internal->property("kwin_blur"); | ||||
278 | if (property.isValid()) { | ||||
279 | region = property.value<QRegion>(); | ||||
280 | } | ||||
281 | } | ||||
282 | | ||||
275 | //!value.isNull() full window in X11 case, surf->blur() | 283 | //!value.isNull() full window in X11 case, surf->blur() | ||
276 | //valid, full window in wayland case | 284 | //valid, full window in wayland case | ||
277 | if (region.isEmpty() && (!value.isNull() || (surf && surf->blur()))) { | 285 | if (region.isEmpty() && (!value.isNull() || (surf && surf->blur()))) { | ||
278 | // Set the data to a dummy value. | 286 | // Set the data to a dummy value. | ||
279 | // This is needed to be able to distinguish between the value not | 287 | // This is needed to be able to distinguish between the value not | ||
280 | // being set, and being set to an empty region. | 288 | // being set, and being set to an empty region. | ||
281 | w->setData(WindowBlurBehindRole, 1); | 289 | w->setData(WindowBlurBehindRole, 1); | ||
282 | } else | 290 | } else | ||
283 | w->setData(WindowBlurBehindRole, region); | 291 | w->setData(WindowBlurBehindRole, region); | ||
284 | } | 292 | } | ||
285 | 293 | | |||
286 | void BlurEffect::slotWindowAdded(EffectWindow *w) | 294 | void BlurEffect::slotWindowAdded(EffectWindow *w) | ||
287 | { | 295 | { | ||
288 | KWayland::Server::SurfaceInterface *surf = w->surface(); | 296 | KWayland::Server::SurfaceInterface *surf = w->surface(); | ||
289 | 297 | | |||
290 | if (surf) { | 298 | if (surf) { | ||
291 | windowBlurChangedConnections[w] = connect(surf, &KWayland::Server::SurfaceInterface::blurChanged, this, [this, w] () { | 299 | windowBlurChangedConnections[w] = connect(surf, &KWayland::Server::SurfaceInterface::blurChanged, this, [this, w] () { | ||
292 | if (w) { | 300 | if (w) { | ||
293 | updateBlurRegion(w); | 301 | updateBlurRegion(w); | ||
294 | } | 302 | } | ||
295 | }); | 303 | }); | ||
296 | } | 304 | } | ||
305 | if (auto internal = w->internalWindow()) { | ||||
306 | internal->installEventFilter(this); | ||||
307 | } | ||||
297 | 308 | | |||
298 | updateBlurRegion(w); | 309 | updateBlurRegion(w); | ||
299 | } | 310 | } | ||
300 | 311 | | |||
301 | void BlurEffect::slotWindowDeleted(EffectWindow *w) | 312 | void BlurEffect::slotWindowDeleted(EffectWindow *w) | ||
302 | { | 313 | { | ||
303 | auto it = windowBlurChangedConnections.find(w); | 314 | auto it = windowBlurChangedConnections.find(w); | ||
304 | if (it == windowBlurChangedConnections.end()) { | 315 | if (it == windowBlurChangedConnections.end()) { | ||
305 | return; | 316 | return; | ||
306 | } | 317 | } | ||
307 | disconnect(*it); | 318 | disconnect(*it); | ||
308 | windowBlurChangedConnections.erase(it); | 319 | windowBlurChangedConnections.erase(it); | ||
309 | } | 320 | } | ||
310 | 321 | | |||
311 | void BlurEffect::slotPropertyNotify(EffectWindow *w, long atom) | 322 | void BlurEffect::slotPropertyNotify(EffectWindow *w, long atom) | ||
312 | { | 323 | { | ||
313 | if (w && atom == net_wm_blur_region && net_wm_blur_region != XCB_ATOM_NONE) { | 324 | if (w && atom == net_wm_blur_region && net_wm_blur_region != XCB_ATOM_NONE) { | ||
314 | updateBlurRegion(w); | 325 | updateBlurRegion(w); | ||
315 | } | 326 | } | ||
316 | } | 327 | } | ||
317 | 328 | | |||
329 | bool BlurEffect::eventFilter(QObject *watched, QEvent *event) | ||||
330 | { | ||||
331 | auto internal = qobject_cast<QWindow*>(watched); | ||||
332 | if (internal && event->type() == QEvent::DynamicPropertyChange) { | ||||
333 | QDynamicPropertyChangeEvent *pe = static_cast<QDynamicPropertyChangeEvent*>(event); | ||||
334 | if (pe->propertyName() == "kwin_blur") { | ||||
335 | if (auto w = effects->findWindow(internal)) { | ||||
336 | updateBlurRegion(w); | ||||
zzag: Would it be feasible to add EffectWindow *findInternalWindow(QWindow *window) to EffectsHandler? | |||||
337 | } | ||||
338 | } | ||||
339 | } | ||||
340 | return false; | ||||
341 | } | ||||
342 | | ||||
318 | bool BlurEffect::enabledByDefault() | 343 | bool BlurEffect::enabledByDefault() | ||
319 | { | 344 | { | ||
320 | GLPlatform *gl = GLPlatform::instance(); | 345 | GLPlatform *gl = GLPlatform::instance(); | ||
321 | 346 | | |||
322 | if (gl->isIntel() && gl->chipClass() < SandyBridge) | 347 | if (gl->isIntel() && gl->chipClass() < SandyBridge) | ||
323 | return false; | 348 | return false; | ||
324 | if (gl->isSoftwareEmulation()) { | 349 | if (gl->isSoftwareEmulation()) { | ||
325 | return false; | 350 | return false; | ||
▲ Show 20 Lines • Show All 446 Lines • Show Last 20 Lines |
Would it be feasible to add EffectWindow *findInternalWindow(QWindow *window) to EffectsHandler?