Add a method for setting the blur region for a window.

svn path=/trunk/KDE/kdelibs/; revision=1100073
This commit is contained in:
Fredrik Höglund 2010-03-06 18:15:55 +00:00
parent 222504cc9a
commit caf251058b
2 changed files with 45 additions and 1 deletions

View File

@ -25,6 +25,7 @@
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <QX11Info>
#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 &region)
{
#ifdef Q_WS_X11
Display *dpy = QX11Info::display();
Atom atom = XInternAtom(dpy, "_KDE_NET_WM_BLUR_REGION", False);
if (enable) {
QVector<QRect> rects = region.rects();
QVector<quint32> 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<const unsigned char *>(data.constData()), data.size());
} else {
XDeleteProperty(dpy, window, atom);
}
#endif
}
}
}

View File

@ -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 &region = QRegion());
}
} // namespace Plasma