summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/kernel.pri2
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp126
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h11
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher_p.h4
-rw-r--r--src/corelib/kernel/qabstractnativeeventfilter.cpp105
-rw-r--r--src/corelib/kernel/qabstractnativeeventfilter.h70
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp125
-rw-r--r--src/corelib/kernel/qcoreapplication.h7
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h2
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp6
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp2
11 files changed, 328 insertions, 132 deletions
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 31dceba886..d2de873cef 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -2,6 +2,7 @@
HEADERS += \
kernel/qabstracteventdispatcher.h \
+ kernel/qabstractnativeeventfilter.h \
kernel/qbasictimer.h \
kernel/qeventloop.h\
kernel/qpointer.h \
@@ -42,6 +43,7 @@ HEADERS += \
SOURCES += \
kernel/qabstracteventdispatcher.cpp \
+ kernel/qabstractnativeeventfilter.cpp \
kernel/qbasictimer.cpp \
kernel/qeventloop.cpp \
kernel/qcoreapplication.cpp \
diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp
index 2ef98dba0f..d17d1c6335 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.cpp
+++ b/src/corelib/kernel/qabstracteventdispatcher.cpp
@@ -41,6 +41,7 @@
#include "qabstracteventdispatcher.h"
#include "qabstracteventdispatcher_p.h"
+#include "qabstractnativeeventfilter.h"
#include "qthread.h"
#include <private/qthread_p.h>
@@ -370,87 +371,96 @@ void QAbstractEventDispatcher::closingDown()
*/
/*!
- \typedef QAbstractEventDispatcher::EventFilter
-
- Typedef for a function with the signature
-
- \snippet code/src_corelib_kernel_qabstracteventdispatcher.cpp 0
-
- Note that the type of the \a message is platform dependent. The
- following table shows the \a {message}'s type on Windows, Mac, and
- X11. You can do a static cast to these types.
-
- \table
- \header
- \li Platform
- \li type
- \row
- \li Windows
- \li MSG
- \row
- \li X11
- \li XEvent
- \row
- \li Mac
- \li NSEvent
- \endtable
-
-
-
- \sa setEventFilter(), filterEvent()
+ Installs an event filter \a filterObj for all native event filters
+ received by the application.
+
+ The event filter \a filterObj receives events via its nativeEventFilter()
+ function, which is called for all events received by all threads.
+
+ The nativeEventFilter() function should return true if the event should
+ be filtered, (i.e. stopped). It should return false to allow
+ normal Qt processing to continue: the native event can then be translated
+ into a QEvent and handled by the standard Qt \l{QEvent} {event} filtering,
+ e.g. QObject::installEventFilter().
+
+ If multiple event filters are installed, the filter that was installed last
+ is activated first.
+
+ \note The filter function set here receives native messages,
+ i.e. MSG or XEvent structs.
+
+ For maximum portability, you should always try to use QEvents
+ and QObject::installEventFilter() whenever possible.
+
+ \sa QObject::installEventFilter()
+
+ \since 5.0
*/
+void QAbstractEventDispatcher::installNativeEventFilter(QAbstractNativeEventFilter *filterObj)
+{
+ Q_D(QAbstractEventDispatcher);
+
+ // clean up unused items in the list
+ d->eventFilters.removeAll(0);
+ d->eventFilters.removeAll(filterObj);
+ d->eventFilters.prepend(filterObj);
+}
/*!
- Replaces the event filter function for this
- QAbstractEventDispatcher with \a filter and returns the replaced
- event filter function. Only the current event filter function is
- called. If you want to use both filter functions, save the
- replaced EventFilter in a place where yours can call it.
-
- The event filter function set here is called for all messages
- taken from the system event loop before the event is dispatched to
- the respective target, including the messages not meant for Qt
- objects.
-
- The event filter function should return true if the message should
- be filtered, (i.e. stopped). It should return false to allow
- processing the message to continue.
+ Removes an event filter object \a obj from this object. The
+ request is ignored if such an event filter has not been installed.
+
+ All event filters for this object are automatically removed when
+ this object is destroyed.
- By default, no event filter function is set (i.e., this function
- returns a null EventFilter the first time it is called).
+ It is always safe to remove an event filter, even during event
+ filter activation (i.e. from the nativeEventFilter() function).
+
+ \sa installNativeEventFilter(), QAbstractNativeEventFilter
+ \since 5.0
*/
-QAbstractEventDispatcher::EventFilter QAbstractEventDispatcher::setEventFilter(EventFilter filter)
+void QAbstractEventDispatcher::removeNativeEventFilter(QAbstractNativeEventFilter *filterObj)
{
Q_D(QAbstractEventDispatcher);
- EventFilter oldFilter = d->event_filter;
- d->event_filter = filter;
- return oldFilter;
+ for (int i = 0; i < d->eventFilters.count(); ++i) {
+ if (d->eventFilters.at(i) == filterObj) {
+ d->eventFilters[i] = 0;
+ break;
+ }
+ }
}
/*!
- Sends \a message through the event filter that was set by
- setEventFilter(). If no event filter has been set, this function
- returns false; otherwise, this function returns the result of the
- event filter function.
+ Sends \a message through the event filters that were set by
+ installNativeEventFilter(). This function returns true as soon as an
+ event filter returns true, and false otherwise to indicate that
+ the processing of the event should continue.
Subclasses of QAbstractEventDispatcher \e must call this function
for \e all messages received from the system to ensure
compatibility with any extensions that may be used in the
application.
- Note that the type of \a message is platform dependent. See
- QAbstractEventDispatcher::EventFilter for details.
+ Note that the type of \a message is platform dependent. See
+ QAbstractNativeEventFilter for details.
- \sa setEventFilter()
+ \sa installNativeEventFilter()
+ \since 5.0
*/
-bool QAbstractEventDispatcher::filterEvent(void *message)
+bool QAbstractEventDispatcher::filterNativeEvent(const QByteArray &eventType, void *message, long *result)
{
Q_D(QAbstractEventDispatcher);
- if (d->event_filter) {
+ if (!d->eventFilters.isEmpty()) {
// Raise the loopLevel so that deleteLater() calls in or triggered
// by event_filter() will be processed from the main event loop.
QScopedLoopLevelCounter loopLevelCounter(d->threadData);
- return d->event_filter(message);
+ for (int i = 0; i < d->eventFilters.size(); ++i) {
+ QAbstractNativeEventFilter *filter = d->eventFilters.at(i);
+ if (!filter)
+ continue;
+ if (filter->nativeEventFilter(eventType, message, result))
+ return true;
+ }
}
return false;
}
diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h
index e70530b283..73c1ad7afd 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.h
+++ b/src/corelib/kernel/qabstracteventdispatcher.h
@@ -49,7 +49,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-
+class QAbstractNativeEventFilter;
class QAbstractEventDispatcherPrivate;
class QSocketNotifier;
@@ -111,9 +111,12 @@ public:
virtual void startingUp();
virtual void closingDown();
- typedef bool(*EventFilter)(void *message);
- EventFilter setEventFilter(EventFilter filter);
- bool filterEvent(void *message);
+ void installNativeEventFilter(QAbstractNativeEventFilter *filterObj);
+ void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj);
+ bool filterNativeEvent(const QByteArray &eventType, void *message, long *result);
+#if QT_DEPRECATED_SINCE(5, 0)
+ QT_DEPRECATED bool filterEvent(void *message) { return filterNativeEvent("", message, 0); }
+#endif
Q_SIGNALS:
void aboutToBlock();
diff --git a/src/corelib/kernel/qabstracteventdispatcher_p.h b/src/corelib/kernel/qabstracteventdispatcher_p.h
index b6f0160342..e34e30e7d1 100644
--- a/src/corelib/kernel/qabstracteventdispatcher_p.h
+++ b/src/corelib/kernel/qabstracteventdispatcher_p.h
@@ -65,9 +65,9 @@ class Q_CORE_EXPORT QAbstractEventDispatcherPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QAbstractEventDispatcher)
public:
inline QAbstractEventDispatcherPrivate()
- : event_filter(0)
{ }
- QAbstractEventDispatcher::EventFilter event_filter;
+
+ QList<QAbstractNativeEventFilter *> eventFilters;
static int allocateTimerId();
static void releaseTimerId(int id);
diff --git a/src/corelib/kernel/qabstractnativeeventfilter.cpp b/src/corelib/kernel/qabstractnativeeventfilter.cpp
new file mode 100644
index 0000000000..69ce560f5d
--- /dev/null
+++ b/src/corelib/kernel/qabstractnativeeventfilter.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qabstractnativeeventfilter.h"
+#include "qabstracteventdispatcher.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QAbstractNativeEventFilter
+ \since 5.0
+
+ \brief The QAbstractNativeEventFilter class provides an interface for receiving native
+ events, such as MSG or XCB event structs.
+*/
+
+/*!
+ Creates a native event filter.
+
+ By default this doesn't do anything. Remember to install it on the application
+ object.
+*/
+QAbstractNativeEventFilter::QAbstractNativeEventFilter()
+{
+}
+
+/*!
+ Destroys the native event filter.
+
+ This automatically removes it from the application.
+*/
+QAbstractNativeEventFilter::~QAbstractNativeEventFilter()
+{
+ QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
+ if (eventDispatcher)
+ eventDispatcher->removeNativeEventFilter(this);
+}
+
+/*!
+ \fn bool QAbstractNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
+
+ This method is called for every native event.
+
+ \note The filter function here receives native messages,
+ for example, MSG or XCB event structs.
+
+ It is called by the QPA platform plugin. On Windows, it is called by
+ the event dispatcher.
+
+ The type of event \a eventType is specific to the platform plugin chosen at run-time,
+ and can be used to cast \a message to the right type.
+
+ On X11, \a eventType is set to "xcb_generic_event_t", and the \a message can be casted
+ to a xcb_generic_event_t pointer.
+
+ On Windows, \a eventType is set to "windows_generic_MSG" for messages sent to toplevel windows,
+ and "windows_dispatcher_MSG" for system-wide messages such as messages from a registered hot key.
+ In both cases, the \a message can be casted to a MSG pointer.
+ The \a result pointer is only used on Windows, and corresponds to the LRESULT pointer.
+
+ On Mac, \a eventType is set to "mac_generic_NSEvent", and the \a message can be casted to an EventRef.
+
+ Example:
+ \snippet code/src_corelib_kernel_qabstractnativeeventfilter.cpp 0
+*/
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qabstractnativeeventfilter.h b/src/corelib/kernel/qabstractnativeeventfilter.h
new file mode 100644
index 0000000000..87ec88b9e4
--- /dev/null
+++ b/src/corelib/kernel/qabstractnativeeventfilter.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTNATIVEEVENTFILTER_H
+#define QABSTRACTNATIVEEVENTFILTER_H
+
+#include <QtCore/qnamespace.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QAbstractNativeEventFilterPrivate;
+
+class Q_CORE_EXPORT QAbstractNativeEventFilter
+{
+public:
+ QAbstractNativeEventFilter();
+ virtual ~QAbstractNativeEventFilter();
+
+ virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) = 0;
+
+private:
+ Q_DISABLE_COPY(QAbstractNativeEventFilter)
+ QAbstractNativeEventFilterPrivate *d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif /* QABSTRACTNATIVEEVENTFILTER_H */
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index d24cbc7d58..5ffd94b068 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -286,7 +286,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint
, origArgv(new char *[aargc])
#endif
, application_type(0)
- , eventFilter(0)
, in_exec(false)
, aboutToQuitEmitted(false)
, threadData_clean(false)
@@ -765,7 +764,7 @@ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event)
do not change the focus widget.
\endlist
- \sa QObject::event(), installEventFilter()
+ \sa QObject::event(), installNativeEventFilter()
*/
bool QCoreApplication::notify(QObject *receiver, QEvent *event)
@@ -2140,80 +2139,94 @@ void QCoreApplication::removeLibraryPath(const QString &path)
#endif //QT_NO_LIBRARY
/*!
- \typedef QCoreApplication::EventFilter
+ Sends \a message through the event filters that were set by
+ installNativeEventFilter(). This function returns true as soon as an
+ event filter returns true, and false otherwise to indicate that
+ the processing of the event should continue.
- A function with the following signature that can be used as an
- event filter:
+ Subclasses of QAbstractEventDispatcher \e must call this function
+ for \e all messages received from the system to ensure
+ compatibility with any extensions that may be used in the
+ application.
- \snippet code/src_corelib_kernel_qcoreapplication.cpp 3
+ Note that the type of \a message is platform dependent. See
+ QAbstractNativeEventFilter for details.
- \sa setEventFilter()
+ \sa installNativeEventFilter()
+ \since 5.0
+
+ \internal
+ This method only exists for the Windows event dispatcher to call the winEventFilter virtual.
+ Every other platform can just use QAbstractNativeEventFilter::filterNativeEvent directly.
*/
+bool QCoreApplication::filterNativeEvent(const QByteArray &eventType, void *message, long *result)
+{
+ if (result)
+ *result = 0;
+#ifdef Q_OS_WIN
+ if (winEventFilter(reinterpret_cast<MSG *>(message), result))
+ return true;
+#endif
+ QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance();
+ if (dispatcher)
+ return dispatcher->filterNativeEvent(eventType, message, result);
+ return false;
+}
-/*!
- \fn EventFilter QCoreApplication::setEventFilter(EventFilter filter)
- Replaces the event filter function for the QCoreApplication with
- \a filter and returns the pointer to the replaced event filter
- function. Only the current event filter function is called. If you
- want to use both filter functions, save the replaced EventFilter
- in a place where yours can call it.
+/*!
+ Installs an event filter \a filterObj for all native events
+ received by the application in the main thread.
- The event filter function set here is called for all messages
- received by all threads meant for all Qt objects. It is \e not
- called for messages that are not meant for Qt objects.
+ The event filter \a filterObj receives events via its nativeEventFilter()
+ function, which is called for all native events received in the main thread.
- The event filter function should return true if the message should
+ The nativeEventFilter() function should return true if the event should
be filtered, (i.e. stopped). It should return false to allow
- processing the message to continue.
+ normal Qt processing to continue: the native event can then be translated
+ into a QEvent and handled by the standard Qt \l{QEvent} {event} filtering,
+ e.g. QObject::installEventFilter().
- By default, no event filter function is set (i.e., this function
- returns a null EventFilter the first time it is called).
+ If multiple event filters are installed, the filter that was
+ installed last is activated first.
\note The filter function set here receives native messages,
- i.e. MSG or XEvent structs, that are going to Qt objects. It is
- called by QCoreApplication::filterEvent(). If the filter function
- returns false to indicate the message should be processed further,
- the native message can then be translated into a QEvent and
- handled by the standard Qt \l{QEvent} {event} filering, e.g.
- QObject::installEventFilter().
-
- \note The filter function set here is different form the filter
- function set via QAbstractEventDispatcher::setEventFilter(), which
- gets all messages received by its thread, even messages meant for
- objects that are not handled by Qt.
-
- \sa QObject::installEventFilter(), QAbstractEventDispatcher::setEventFilter()
+ i.e. MSG or XCB event structs.
+
+ For maximum portability, you should always try to use QEvents
+ and QObject::installEventFilter() whenever possible.
+
+ \sa QObject::installEventFilter()
+
+ \since 5.0
*/
-QCoreApplication::EventFilter
-QCoreApplication::setEventFilter(QCoreApplication::EventFilter filter)
+void QCoreApplication::installNativeEventFilter(QAbstractNativeEventFilter *filterObj)
{
- Q_D(QCoreApplication);
- EventFilter old = d->eventFilter;
- d->eventFilter = filter;
- return old;
+ QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(QCoreApplicationPrivate::theMainThread);
+ if (!filterObj || !eventDispatcher)
+ return;
+ eventDispatcher->installNativeEventFilter(filterObj);
}
/*!
- Sends \a message through the event filter that was set by
- setEventFilter(). If no event filter has been set, this function
- returns false; otherwise, this function returns the result of the
- event filter function in the \a result parameter.
+ Removes an event filter object \a obj from this object. The
+ request is ignored if such an event filter has not been installed.
+
+ All event filters for this object are automatically removed when
+ this object is destroyed.
- \sa setEventFilter()
+ It is always safe to remove an event filter, even during event
+ filter activation (i.e. from the nativeEventFilter() function).
+
+ \sa installNativeEventFilter(), QAbstractNativeEventFilter
+ \since 5.0
*/
-bool QCoreApplication::filterEvent(void *message, long *result)
+void QCoreApplication::removeNativeEventFilter(QAbstractNativeEventFilter *filterObj)
{
- Q_D(QCoreApplication);
- if (result)
- *result = 0;
- if (d->eventFilter)
- return d->eventFilter(message, result);
-#ifdef Q_OS_WIN
- return winEventFilter(reinterpret_cast<MSG *>(message), result);
-#else
- return false;
-#endif
+ QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
+ if (!filterObj || !eventDispatcher)
+ return;
+ eventDispatcher->removeNativeEventFilter(filterObj);
}
/*!
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 555686f9ab..549b6f135d 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -61,6 +61,7 @@ class QTranslator;
class QPostEventList;
class QStringList;
class QAbstractEventDispatcher;
+class QAbstractNativeEventFilter;
#define qApp QCoreApplication::instance()
@@ -159,9 +160,9 @@ public:
static void watchUnixSignal(int signal, bool watch);
#endif
- typedef bool (*EventFilter)(void *message, long *result);
- EventFilter setEventFilter(EventFilter filter);
- bool filterEvent(void *message, long *result);
+ void installNativeEventFilter(QAbstractNativeEventFilter *filterObj);
+ void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj);
+ bool filterNativeEvent(const QByteArray &eventType, void *message, long *result);
static bool isQuitLockEnabled();
static void setQuitLockEnabled(bool enabled);
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 1f1d58c009..0fe64621f3 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -121,8 +121,6 @@ public:
#endif
uint application_type;
- QCoreApplication::EventFilter eventFilter;
-
bool in_exec;
bool aboutToQuitEmitted;
bool threadData_clean;
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 5649a8dd76..9d92f83b04 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -207,12 +207,6 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
the event to be processed by Qt, then return true and set \a result
to the value that the window procedure should return. Otherwise
return false.
-
- It is only directly addressed messages that are filtered. To
- handle system wide messages, such as messages from a registered
- hot key, you need to install an event filter on the event
- dispatcher, which is returned from
- QAbstractEventDispatcher::instance().
*/
bool QCoreApplication::winEventFilter(MSG *msg, long *result) // Windows event filter
{
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 8d357b5085..e5cc627edb 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -359,7 +359,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
if (message == WM_TIMER)
KillTimer(hwnd, wp);
return 0;
- } else if (app->filterEvent(&msg, &result)) {
+ } else if (app->filterNativeEvent(QByteArrayLiteral("windows_dispatcher_MSG"), &msg, &result)) {
return result;
}