* don't reset the watched properties: it breks kwin

* check for the blur property only on PropertyNotify and if is on the property we actually want

svn path=/trunk/KDE/kdelibs/; revision=1214853
This commit is contained in:
Marco Martin 2011-01-16 17:25:28 +00:00
parent 543168555b
commit 091d781dc5
3 changed files with 28 additions and 11 deletions

View File

@ -30,15 +30,20 @@ namespace Plasma
{
EffectWatcher::EffectWatcher(Plasma::WindowEffects::Effect effect, QWidget *parent)
EffectWatcher::EffectWatcher(QString property, QWidget *parent)
: QWidget(parent),
m_effect(effect),
m_property(property),
m_effectActive(false)
{
#ifdef Q_WS_X11
kapp->installX11EventFilter( this );
Display *dpy = QX11Info::display();
XSelectInput(dpy, RootWindow(dpy, 0), PropertyChangeMask);
Window root = DefaultRootWindow(dpy);
XWindowAttributes attrs;
//Don't reset eventual other masks already there
XGetWindowAttributes(dpy, root, &attrs);
attrs.your_event_mask |= PropertyChangeMask;
XSelectInput(dpy, root, attrs.your_event_mask);
#endif
}
@ -46,10 +51,22 @@ EffectWatcher::EffectWatcher(Plasma::WindowEffects::Effect effect, QWidget *pare
#ifdef Q_WS_X11
bool EffectWatcher::x11Event(XEvent *event)
{
bool nowEffectActive = WindowEffects::isEffectAvailable(m_effect);
if (m_effectActive != nowEffectActive) {
m_effectActive = nowEffectActive;
emit blurBehindChanged(m_effectActive);
if (event->type == PropertyNotify) {
Display *dpy = QX11Info::display();
Atom testAtom = XInternAtom(dpy, m_property.toLatin1(), False);
if (event->xproperty.atom == testAtom) {
bool nowEffectActive = false;
int cnt;
Atom *list = XListProperties(dpy, DefaultRootWindow(dpy), &cnt);
if (list != NULL) {
nowEffectActive = (qFind(list, list + cnt, testAtom) != list + cnt);
XFree(list);
}
if (m_effectActive != nowEffectActive) {
m_effectActive = nowEffectActive;
emit blurBehindChanged(m_effectActive);
}
}
}
return QWidget::x11Event(event);
}

View File

@ -32,7 +32,7 @@ class EffectWatcher: public QWidget
Q_OBJECT
public:
EffectWatcher(Plasma::WindowEffects::Effect effect, QWidget *parent = 0);
EffectWatcher(QString property, QWidget *parent = 0);
protected:
#ifdef Q_WS_X11
@ -43,7 +43,7 @@ Q_SIGNALS:
void blurBehindChanged(bool blur);
private:
Plasma::WindowEffects::Effect m_effect;
QString m_property;
bool m_effectActive;
};

View File

@ -109,8 +109,8 @@ public:
QObject::connect(compositeWatch, SIGNAL(lostOwner()), q, SLOT(compositingChanged()));
//watch for blur effect property changes as well
effectWatcher = 0;
/* effectWatcher = new EffectWatcher(WindowEffects::BlurBehind);
QObject::connect(effectWatcher, SIGNAL(blurBehindChanged(bool)), q, SLOT(blurBehindChanged(bool)));*/
effectWatcher = new EffectWatcher("_KDE_NET_WM_BLUR_BEHIND_REGION");
QObject::connect(effectWatcher, SIGNAL(blurBehindChanged(bool)), q, SLOT(blurBehindChanged(bool)));
}
#endif