summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
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/windows
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/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp39
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp2
3 files changed, 4 insertions, 40 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 37493fe3db..b12975174f 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -240,13 +240,6 @@ QWindowsContext *QWindowsContext::m_instance = 0;
typedef QHash<HWND, QWindowsWindow *> HandleBaseWindowHash;
struct QWindowsContextPrivate {
- typedef QPlatformNativeInterface::EventFilter EventFilter;
-
- enum EventFilterType
- {
- GenericWindowsEventFilter,
- EventFilterTypeCount
- };
QWindowsContextPrivate();
@@ -262,7 +255,6 @@ struct QWindowsContextPrivate {
QSharedPointer<QWindowCreationContext> m_creationContext;
const HRESULT m_oleInitializeResult;
const QByteArray m_eventType;
- EventFilter m_eventFilters[EventFilterTypeCount];
QWindow *m_lastActiveWindow;
};
@@ -289,7 +281,6 @@ QWindowsContextPrivate::QWindowsContextPrivate() :
m_systemInfo |= QWindowsContext::SI_RTL_Extensions;
m_keyMapper.setUseRTLExtensions(true);
}
- qFill(m_eventFilters, m_eventFilters + EventFilterTypeCount, EventFilter(0));
}
QWindowsContext::QWindowsContext() :
@@ -695,27 +686,6 @@ QByteArray QWindowsContext::comErrorString(HRESULT hr)
}
/*!
- \brief Set event filter.
-
- \sa QWindowsNativeInterface
-*/
-
-QWindowsContext::EventFilter QWindowsContext::setEventFilter(const QByteArray &eventType, EventFilter filter)
-{
- int eventFilterType = -1;
- if (eventType == d->m_eventType)
- eventFilterType = QWindowsContextPrivate::GenericWindowsEventFilter;
- if (eventFilterType < 0) {
- qWarning("%s: Attempt to set unsupported event filter '%s'.",
- __FUNCTION__, eventType.constData());
- return 0;
- }
- const EventFilter previous = d->m_eventFilters[eventFilterType];
- d->m_eventFilters[eventFilterType] = filter;
- return previous;
-}
-
-/*!
\brief Main windows procedure registered for windows.
\sa QWindowsGuiEventDispatcher
@@ -736,11 +706,10 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
msg.pt.y = GET_Y_LPARAM(lParam);
long filterResult = 0;
- if (d->m_eventFilters[QWindowsContextPrivate::GenericWindowsEventFilter]) {
- if (d->m_eventFilters[QWindowsContextPrivate::GenericWindowsEventFilter](&msg, &filterResult)) {
- *result = LRESULT(filterResult);
- return true;
- }
+ QCoreApplication* coreApp = QCoreApplication::instance();
+ if (coreApp && coreApp->filterNativeEvent(d->m_eventType, &msg, &filterResult)) {
+ *result = LRESULT(filterResult);
+ return true;
}
// Events without an associated QWindow or events we are not interested in.
switch (et) {
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index 0b18196abe..e4fde55464 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -107,7 +107,6 @@ class QWindowsContext
{
Q_DISABLE_COPY(QWindowsContext)
public:
- typedef bool (*EventFilter)(void *message, long *result);
enum SystemInfoFlags
{
@@ -143,8 +142,6 @@ public:
HDC displayContext() const;
int screenDepth() const;
- EventFilter setEventFilter(const QByteArray &eventType, EventFilter filter);
-
static QWindowsContext *instance();
static QString windowsErrorMessage(unsigned long errorCode);
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 1ff142bc98..f32f8cd689 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -102,8 +102,6 @@ public:
#endif
virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window);
virtual void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *bs);
- virtual EventFilter setEventFilter(const QByteArray &eventType, EventFilter filter)
- { return QWindowsContext::instance()->setEventFilter(eventType, filter); }
Q_INVOKABLE void *createMessageWindow(const QString &classNameTemplate,
const QString &windowName,