From 091d781dc540f774b78cbfeb8028f12c74475537 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sun, 16 Jan 2011 17:25:28 +0000 Subject: [PATCH] * 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 --- private/effectwatcher.cpp | 31 ++++++++++++++++++++++++------- private/effectwatcher_p.h | 4 ++-- theme.cpp | 4 ++-- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/private/effectwatcher.cpp b/private/effectwatcher.cpp index 9533fd8eb..93aa2db5e 100644 --- a/private/effectwatcher.cpp +++ b/private/effectwatcher.cpp @@ -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); } diff --git a/private/effectwatcher_p.h b/private/effectwatcher_p.h index c706074f2..56b20f7a3 100644 --- a/private/effectwatcher_p.h +++ b/private/effectwatcher_p.h @@ -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; }; diff --git a/theme.cpp b/theme.cpp index f92feae1d..dcb17f042 100644 --- a/theme.cpp +++ b/theme.cpp @@ -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