generic: get rid of the effects watcher specific to Plasma

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2016-08-29 19:39:11 +00:00
parent cfff1dd53a
commit 718725941c
6 changed files with 3 additions and 177 deletions

View file

@ -627,9 +627,9 @@ Q_SIGNALS:
* Note that this signal may be emitted before any compositing plugins
* have been initialized in the window manager.
*
* If you need to check if a specific compositing plugin such as the
* blur effect is enabled, you should track that separately rather
* than test for it in a slot connected to this signal.
* Since most KWin effect require compositor you can safely assume that
* when the compositor is not active effects like blur-behind are not
* possible too.
*
* @since 4.7.1
*/

View file

@ -108,7 +108,6 @@ set(plasma_LIB_SRCS
private/dataengineconsumer.cpp
private/dataengineservice.cpp
private/dialogshadows.cpp
private/effectwatcher.cpp
private/extenderapplet.cpp
private/extenderitemmimedata.cpp
private/focusindicator.cpp

View file

@ -1,90 +0,0 @@
/*
* Copyright 2011 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "effectwatcher_p.h"
#include <kapplication.h>
#include <kdebug.h>
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#endif
namespace Plasma
{
EffectWatcher::EffectWatcher(QString property, QWidget *parent)
: QWidget(parent),
m_property(property)
{
m_effectActive = isEffectActive();
#ifdef Q_WS_X11
kapp->installX11EventFilter( this );
Display *dpy = QX11Info::display();
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
}
#ifdef Q_WS_X11
bool EffectWatcher::x11Event(XEvent *event)
{
if (event->type == PropertyNotify) {
Display *dpy = QX11Info::display();
Atom testAtom = XInternAtom(dpy, m_property.toLatin1(), False);
if (event->xproperty.atom == testAtom) {
bool nowEffectActive = isEffectActive();
if (m_effectActive != nowEffectActive) {
m_effectActive = nowEffectActive;
emit effectChanged(m_effectActive);
}
}
}
return QWidget::x11Event(event);
}
#endif
bool EffectWatcher::isEffectActive() const
{
#ifdef Q_WS_X11
Display *dpy = QX11Info::display();
Atom testAtom = XInternAtom(dpy, m_property.toLatin1(), False);
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);
}
return nowEffectActive;
#else
return false;
#endif
}
}
#include "moc_effectwatcher_p.cpp"

View file

@ -1,53 +0,0 @@
/*
* Copyright 2011 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef BLURWATCHER_H
#define BLURWATCHER_H
#include <QWidget>
#include <plasma/windoweffects.h>
namespace Plasma
{
class EffectWatcher: public QWidget
{
Q_OBJECT
public:
EffectWatcher(QString property, QWidget *parent = 0);
protected:
bool isEffectActive() const;
#ifdef Q_WS_X11
bool x11Event(XEvent *event);
#endif
Q_SIGNALS:
void effectChanged(bool on);
private:
QString m_property;
bool m_effectActive;
};
}
#endif

View file

@ -28,10 +28,6 @@
#include <QTimer>
#include <QCache>
#include <QBuffer>
#ifdef Q_WS_X11
#include <QtGui/qx11info_x11.h>
#include "private/effectwatcher_p.h"
#endif
#include <kcolorscheme.h>
#include <kcomponentdata.h>
@ -88,7 +84,6 @@ public:
cachesToDiscard(NoCache),
locolor(false),
compositingActive(KWindowSystem::self()->compositingActive()),
blurActive(false),
isDefault(false),
useGlobal(true),
hasWallpapers(false),
@ -113,14 +108,6 @@ public:
if (QPixmap::defaultDepth() > 8) {
QObject::connect(KWindowSystem::self(), SIGNAL(compositingChanged(bool)), q, SLOT(compositingChanged(bool)));
#ifdef Q_WS_X11
//watch for blur effect property changes as well
if (!s_blurEffectWatcher) {
s_blurEffectWatcher = new EffectWatcher("_KDE_NET_WM_BLUR_BEHIND_REGION");
}
QObject::connect(s_blurEffectWatcher, SIGNAL(effectChanged(bool)), q, SLOT(blurBehindChanged(bool)));
#endif
}
}
@ -156,7 +143,6 @@ public:
void scheduleThemeChangeNotification(CacheTypes caches);
void notifyOfChanged();
void colorsChanged();
void blurBehindChanged(bool blur);
bool useCache();
void settingsFileChanged(const QString &);
void setThemeName(const QString &themeName, bool writeSettings);
@ -170,9 +156,6 @@ public:
static const char *systemColorsTheme;
static const char *themeRcFile;
static PackageStructure::Ptr packageStructure;
#ifdef Q_WS_X11
static EffectWatcher *s_blurEffectWatcher;
#endif
Theme *q;
QString themeName;
@ -205,7 +188,6 @@ public:
bool locolor : 1;
bool compositingActive : 1;
bool blurActive : 1;
bool isDefault : 1;
bool useGlobal : 1;
bool hasWallpapers : 1;
@ -220,9 +202,6 @@ const char *ThemePrivate::themeRcFile = "plasmarc";
// the system colors theme is used to cache unthemed svgs with colorization needs
// these svgs do not follow the theme's colors, but rather the system colors
const char *ThemePrivate::systemColorsTheme = "internal-system-colors";
#ifdef Q_WS_X11
EffectWatcher *ThemePrivate::s_blurEffectWatcher = 0;
#endif
bool ThemePrivate::useCache()
{
@ -366,14 +345,6 @@ void ThemePrivate::colorsChanged()
scheduleThemeChangeNotification(PixmapCache);
}
void ThemePrivate::blurBehindChanged(bool blur)
{
if (blurActive != blur) {
blurActive = blur;
scheduleThemeChangeNotification(PixmapCache | SvgElementsCache);
}
}
void ThemePrivate::scheduleThemeChangeNotification(CacheTypes caches)
{
cachesToDiscard |= caches;

View file

@ -396,7 +396,6 @@ class PLASMA_EXPORT Theme : public QObject
Q_PRIVATE_SLOT(d, void compositingChanged(bool))
Q_PRIVATE_SLOT(d, void colorsChanged())
Q_PRIVATE_SLOT(d, void blurBehindChanged(bool blur))
Q_PRIVATE_SLOT(d, void settingsFileChanged(const QString &))
Q_PRIVATE_SLOT(d, void scheduledCacheUpdate())
Q_PRIVATE_SLOT(d, void onAppExitCleanup())