summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qnx
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2012-06-23 21:48:53 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-20 18:34:08 +0200
commit1603ba23656c8c31dc05fe9b3f1e12b22e29989a (patch)
tree5e507db7a34023b9236c982257923a2242c1693a /src/plugins/platforms/qnx
parent981ea7a1aa602cebfdd43b7dc6efd3abf5a1cba3 (diff)
Provide public API for native event filtering, moved up from QPA.
The previous API was hard to use (global function, no type safety, manual chaining), and confusing (app vs dispatcher split only made sense on Windows). Installing and removing out of order would have the risk of setting back a dangling pointer (crash). Meanwhile QPA added type safety, and this new API models the QObject::installEventFilter API for ease of use. The virtual method is in a new interface, QAbstractNativeEventFilter. QPA was even calling the dispatcher event filter with QPA-private event classes, which made no sense (refactoring leftover from when the code was in the dispatcher). Now the QPA plugins trigger the qcoreapp event filters with the actual native events directly. Change-Id: Ie35e47c59c862383bcaf857b28d54f7c72547882 Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Diffstat (limited to 'src/plugins/platforms/qnx')
-rw-r--r--src/plugins/platforms/qnx/qqnxbpseventfilter.cpp22
-rw-r--r--src/plugins/platforms/qnx/qqnxbpseventfilter.h6
2 files changed, 7 insertions, 21 deletions
diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp
index 93bb2d3584..4ce38b9fdc 100644
--- a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp
+++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp
@@ -90,13 +90,7 @@ void QQnxBpsEventFilter::installOnEventDispatcher(QAbstractEventDispatcher *disp
if (navigator_request_events(0) != BPS_SUCCESS)
qWarning("QQNX: failed to register for navigator events");
- QAbstractEventDispatcher::EventFilter previousEventFilter = dispatcher->setEventFilter(dispatcherEventFilter);
-
- // the QPA plugin creates the event dispatcher so we are the first event
- // filter assert on that just in case somebody adds another event filter
- // in the QQnxIntegration constructor instead of adding a new section in here
- Q_ASSERT(previousEventFilter == 0);
- Q_UNUSED(previousEventFilter);
+ dispatcher->installNativeEventFilter(this);
}
void QQnxBpsEventFilter::registerForScreenEvents(QQnxScreen *screen)
@@ -137,19 +131,11 @@ void QQnxBpsEventFilter::unregisterForDialogEvents(QQnxFileDialogHelper *dialog)
qWarning("QQNX: attempting to unregister dialog that was not registered");
}
-bool QQnxBpsEventFilter::dispatcherEventFilter(void *message)
+bool QQnxBpsEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
- qBpsEventFilterDebug() << Q_FUNC_INFO;
-
- if (s_instance == 0)
- return false;
-
+ Q_UNUSED(eventType);
+ Q_UNUSED(result);
bps_event_t *event = static_cast<bps_event_t *>(message);
- return s_instance->bpsEventFilter(event);
-}
-
-bool QQnxBpsEventFilter::bpsEventFilter(bps_event_t *event)
-{
const int eventDomain = bps_event_get_domain(event);
qBpsEventFilterDebug() << Q_FUNC_INFO << "event=" << event << "domain=" << eventDomain;
diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.h b/src/plugins/platforms/qnx/qqnxbpseventfilter.h
index aafca0f989..164cb0291b 100644
--- a/src/plugins/platforms/qnx/qqnxbpseventfilter.h
+++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.h
@@ -44,6 +44,7 @@
#include <QObject>
#include <QHash>
+#include <QAbstractNativeEventFilter>
#include <bps/dialog.h>
@@ -58,7 +59,7 @@ class QQnxScreen;
class QQnxScreenEventHandler;
class QQnxVirtualKeyboardBps;
-class QQnxBpsEventFilter : public QObject
+class QQnxBpsEventFilter : public QObject, public QAbstractNativeEventFilter
{
Q_OBJECT
public:
@@ -76,8 +77,7 @@ public:
void unregisterForDialogEvents(QQnxFileDialogHelper *dialog);
private:
- static bool dispatcherEventFilter(void *message);
- bool bpsEventFilter(bps_event_t *event);
+ bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
bool handleNavigatorEvent(bps_event_t *event);