Port EffectWatcher to QAbstractNativeEventFilter
This commit is contained in:
parent
d332669af8
commit
c28900a1c0
@ -122,7 +122,6 @@ set(plasma_LIB_SRCS
|
||||
private/dataenginemanager.cpp
|
||||
private/dataengineservice.cpp
|
||||
private/effects/halopainter.cpp
|
||||
private/effectwatcher.cpp
|
||||
private/getsource.cpp
|
||||
private/packages.cpp
|
||||
private/plasmoidservice.cpp
|
||||
@ -184,6 +183,10 @@ set(plasma_LIB_SRCS
|
||||
corona.cpp
|
||||
)
|
||||
|
||||
if (QT5_BUILD)
|
||||
set(plasma_LIB_SRCS ${plasma_LIB_SRCS} private/effectwatcher.cpp)
|
||||
endif()
|
||||
|
||||
kconfig_add_kcfg_files(plasma_LIB_SRCS data/kconfigxt/libplasma-theme-global.kcfgc)
|
||||
|
||||
kde4_add_ui_files(plasma_LIB_SRCS
|
||||
|
@ -19,25 +19,23 @@
|
||||
|
||||
#include "effectwatcher_p.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#if 0 // Port to Qt5 native filters
|
||||
#include <X11/Xlib.h>
|
||||
#include <QX11Info>
|
||||
#endif
|
||||
#include <xcb/xcb.h>
|
||||
#include <qx11info_x11.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
|
||||
EffectWatcher::EffectWatcher(QString property, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
EffectWatcher::EffectWatcher(const QString& property, QObject *parent)
|
||||
: QObject(parent),
|
||||
m_property(property)
|
||||
{
|
||||
m_effectActive = isEffectActive();
|
||||
#pragma message("Port to Qt5 native filter")
|
||||
#if 0
|
||||
kapp->installX11EventFilter( this );
|
||||
|
||||
QCoreApplication::instance()->installNativeEventFilter(this);
|
||||
|
||||
Display *dpy = QX11Info::display();
|
||||
Window root = DefaultRootWindow(dpy);
|
||||
XWindowAttributes attrs;
|
||||
@ -45,33 +43,33 @@ EffectWatcher::EffectWatcher(QString property, QWidget *parent)
|
||||
XGetWindowAttributes(dpy, root, &attrs);
|
||||
attrs.your_event_mask |= PropertyChangeMask;
|
||||
XSelectInput(dpy, root, attrs.your_event_mask);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#pragma message("Port to Qt5 native filter")
|
||||
#if 0
|
||||
bool EffectWatcher::x11Event(XEvent *event)
|
||||
bool EffectWatcher::nativeEventFilter(const QByteArray& eventType, void *message, long *result)
|
||||
{
|
||||
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);
|
||||
}
|
||||
Q_UNUSED(result);
|
||||
if (eventType != "xcb_generic_event_t")
|
||||
return false;
|
||||
xcb_generic_event_t* event = reinterpret_cast<xcb_generic_event_t *>(message);
|
||||
uint response_type = event->response_type & ~0x80;
|
||||
if (response_type != XCB_PROPERTY_NOTIFY)
|
||||
return false;
|
||||
|
||||
xcb_property_notify_event_t* prop_event = reinterpret_cast<xcb_property_notify_event_t *>(event);
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom testAtom = XInternAtom(dpy, m_property.toLatin1(), False);
|
||||
if (prop_event->atom == testAtom) {
|
||||
bool nowEffectActive = isEffectActive();
|
||||
if (m_effectActive != nowEffectActive) {
|
||||
m_effectActive = nowEffectActive;
|
||||
emit effectChanged(m_effectActive);
|
||||
}
|
||||
}
|
||||
return QWidget::x11Event(event);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool EffectWatcher::isEffectActive() const
|
||||
{
|
||||
#pragma message("Port to Qt5 native filter")
|
||||
#if 0
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom testAtom = XInternAtom(dpy, m_property.toLatin1(), False);
|
||||
|
||||
@ -83,11 +81,6 @@ bool EffectWatcher::isEffectActive() const
|
||||
XFree(list);
|
||||
}
|
||||
return nowEffectActive;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "moc_effectwatcher_p.cpp"
|
||||
} // namespace Plasma
|
||||
|
@ -20,24 +20,24 @@
|
||||
#ifndef BLURWATCHER_H
|
||||
#define BLURWATCHER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
|
||||
#include <QAbstractNativeEventFilter>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class EffectWatcher: public QWidget
|
||||
class EffectWatcher: public QObject, public QAbstractNativeEventFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EffectWatcher(QString property, QWidget *parent = 0);
|
||||
EffectWatcher(const QString& property, QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
bool isEffectActive() const;
|
||||
#pragma message("Port to Qt5 native filter")
|
||||
#if 0
|
||||
bool x11Event(XEvent *event);
|
||||
#endif
|
||||
|
||||
bool nativeEventFilter(const QByteArray& eventType, void *message, long *result) Q_DECL_OVERRIDE;
|
||||
|
||||
Q_SIGNALS:
|
||||
void effectChanged(bool on);
|
||||
@ -47,6 +47,6 @@ private:
|
||||
bool m_effectActive;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Plasma
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -31,8 +31,10 @@
|
||||
|
||||
#if HAVE_X11
|
||||
#include <QX11Info>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
#include "private/effectwatcher_p.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <kcolorscheme.h>
|
||||
#include <kcomponentdata.h>
|
||||
@ -113,7 +115,7 @@ public:
|
||||
|
||||
if (QPixmap::defaultDepth() > 8) {
|
||||
QObject::connect(KWindowSystem::self(), SIGNAL(compositingChanged(bool)), q, SLOT(compositingChanged(bool)));
|
||||
#if HAVE_X11
|
||||
#if HAVE_X11 && QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
//watch for blur effect property changes as well
|
||||
if (!s_blurEffectWatcher) {
|
||||
s_blurEffectWatcher = new EffectWatcher("_KDE_NET_WM_BLUR_BEHIND_REGION");
|
||||
@ -170,7 +172,7 @@ public:
|
||||
static const char *defaultTheme;
|
||||
static const char *systemColorsTheme;
|
||||
static const char *themeRcFile;
|
||||
#if HAVE_X11
|
||||
#if HAVE_X11 && QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
static EffectWatcher *s_blurEffectWatcher;
|
||||
#endif
|
||||
|
||||
@ -215,7 +217,7 @@ 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";
|
||||
#if HAVE_X11
|
||||
#if HAVE_X11 && QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
EffectWatcher *ThemePrivate::s_blurEffectWatcher = 0;
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user