summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Fernengel <harald.fernengel@nokia.com>2010-09-09 14:03:45 (GMT)
committerHarald Fernengel <harald.fernengel@nokia.com>2010-09-10 09:01:59 (GMT)
commit839e2ed4746d748df67570934a0be9e0a9cd0c3d (patch)
tree46ad5f758051bb83f6690f1dc3443da881c7afa4
parent759c3c2a2a62648b0fc4b2970a1fdb3a52c488a7 (diff)
downloadQt-839e2ed4746d748df67570934a0be9e0a9cd0c3d.zip
Qt-839e2ed4746d748df67570934a0be9e0a9cd0c3d.tar.gz
Qt-839e2ed4746d748df67570934a0be9e0a9cd0c3d.tar.bz2
Added private API to install an x11EventFilter
Some libs need to intercept X11 events without actually being able to subclass QApplication, so add a private API to allow setting event filter functions. Reviewed By: Robert Griebl
-rw-r--r--src/gui/kernel/qapplication_x11.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 7495f6d..e7b7ed8 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -400,11 +400,39 @@ QTabletDeviceDataList *qt_tablet_devices()
extern bool qt_tabletChokeMouse;
#endif
+typedef bool(*QX11FilterFunction)(XEvent *event);
+
+Q_GLOBAL_STATIC(QList<QX11FilterFunction>, x11Filters)
+
+Q_GUI_EXPORT void qt_installX11EventFilter(QX11FilterFunction func)
+{
+ Q_ASSERT(func);
+
+ if (QList<QX11FilterFunction> *list = x11Filters())
+ list->append(func);
+}
+
+Q_GUI_EXPORT void qt_removeX11EventFilter(QX11FilterFunction func)
+{
+ Q_ASSERT(func);
+
+ if (QList<QX11FilterFunction> *list = x11Filters())
+ list->removeOne(func);
+}
+
+
static bool qt_x11EventFilter(XEvent* ev)
{
long unused;
if (qApp->filterEvent(ev, &unused))
return true;
+ if (const QList<QX11FilterFunction> *list = x11Filters()) {
+ for (QList<QX11FilterFunction>::const_iterator it = list->constBegin(); it != list->constEnd(); ++it) {
+ if ((*it)(ev))
+ return true;
+ }
+ }
+
return qApp->x11EventFilter(ev);
}