diff --git a/windoweffects.cpp b/windoweffects.cpp index 7529c826b..3af08d271 100644 --- a/windoweffects.cpp +++ b/windoweffects.cpp @@ -25,6 +25,7 @@ #ifdef Q_WS_X11 #include +#include #include #endif @@ -61,6 +62,10 @@ bool isEffectAvailable(Effect effect) break; case OverrideShadow: effectName = "_KDE_SHADOW_OVERRIDE"; + break; + case BlurBehind: + effectName = "_KDE_NET_WM_BLUR_REGION"; + break; default: return false; } @@ -296,6 +301,28 @@ void overrideShadow(WId window, bool override) #endif } +void enableBlurBehind(WId window, bool enable, const QRegion ®ion) +{ +#ifdef Q_WS_X11 + Display *dpy = QX11Info::display(); + Atom atom = XInternAtom(dpy, "_KDE_NET_WM_BLUR_REGION", False); + + if (enable) { + QVector rects = region.rects(); + QVector data; + for (int i = 0; i < rects.count(); i++) { + const QRect r = rects[i]; + data << r.x() << r.y() << r.width() << r.height(); + } + + XChangeProperty(dpy, window, atom, XA_CARDINAL, 32, PropModeReplace, + reinterpret_cast(data.constData()), data.size()); + } else { + XDeleteProperty(dpy, window, atom); + } +#endif +} + } } diff --git a/windoweffects.h b/windoweffects.h index 8db92c5aa..a0b22abcd 100644 --- a/windoweffects.h +++ b/windoweffects.h @@ -41,7 +41,8 @@ namespace WindowEffects PresentWindows = 3, PresentWindowsGroup = 4, HighlightWindows = 5, - OverrideShadow = 6 + OverrideShadow = 6, + BlurBehind = 7 }; /** @@ -133,6 +134,22 @@ namespace WindowEffects * @since 4.4 */ PLASMA_EXPORT void overrideShadow(WId window, bool override); + + /** + * Instructs the window manager to blur the background in the specified region + * behind the given window. Passing a null region will enable the blur effect + * for the whole window. The region is relative to the top-left corner of the + * client area. + * + * Note that you will usually want to set the region to the shape of the window, + * excluding any shadow or halo. + * + * @param window The window for which to enable the blur effect + * @param enable Enable the effect if @a true, disable it if @false + * @param region The region within the window where the background will be blurred + * @since 4.5 + */ + PLASMA_EXPORT void enableBlurBehind(WId window, bool enable = true, const QRegion ®ion = QRegion()); } } // namespace Plasma