diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-07-23 14:47:24 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-23 15:26:32 +0200 |
commit | b9ea43645ac752f31a152583d7959f438c61cfa4 (patch) | |
tree | e484441049a48c71d8697c18a465ecdeb9ae21c4 /src | |
parent | ce7a3b0237678de1b1082fea3e594bc4d6723a2f (diff) | |
download | qtactiveqt-b9ea43645ac752f31a152583d7959f438c61cfa4.tar.gz |
Port QtActiveQt to new native event filter system.
The old system has been removed.
Change-Id: Ief1bd54644f4a09da080bbb966db58a17faec203
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/activeqt/container/qaxwidget.cpp | 31 | ||||
-rw-r--r-- | src/activeqt/container/qaxwidget.h | 4 | ||||
-rw-r--r-- | src/activeqt/control/qaxserverbase.cpp | 12 |
3 files changed, 24 insertions, 23 deletions
diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index 1e0d3e8..9f720ef 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -60,6 +60,7 @@ #include <qregexp.h> #include <quuid.h> #include <qwhatsthis.h> +#include <qabstractnativeeventfilter.h> #include <windowsx.h> #include <ocidl.h> @@ -462,19 +463,6 @@ static Qt::KeyboardModifiers translateModifierState(int s) return bst; } -static QAbstractEventDispatcher::EventFilter previous_filter = 0; -#if QT_VERSION >= 0x050000 -/* FIXME Implement QAbstractEventDispatcher's event filtering mechanism properly as done in QObject::install/removeEventFilter - * to enable a reliable chain of event filters living in different DLLs, from which filters can be removed at arbitrary times. - * Not possible with the current API which requires a newly installed event filter to call the - * previous event filter - if the previous event filter is unloaded, then the later event filter trying to call it will crash the - * process. */ -# ifdef Q_CC_MSVC -# pragma message ("Fix QAbstractEventDispatcher::setEventFilter") -# else -# warning "Fix QAbstractEventDispatcher::setEventFilter" -# endif -#endif #if defined(Q_WS_WINCE) static int filter_ref = 0; #else @@ -482,7 +470,14 @@ static const wchar_t *qaxatom = L"QAxContainer4_Atom"; #endif // The filter procedure listening to user interaction on the control -bool axc_FilterProc(void *m) +class QAxNativeEventFilter : public QAbstractNativeEventFilter +{ +public: + virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE; +}; +Q_GLOBAL_STATIC(QAxNativeEventFilter, s_nativeEventFilter) + +bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, long *) { MSG *msg = (MSG*)m; const uint message = msg->message; @@ -536,9 +531,6 @@ bool axc_FilterProc(void *m) } } - if (previous_filter) - return previous_filter(m); - return false; } @@ -2030,7 +2022,7 @@ bool QAxWidget::createHostWindow(bool initialized, const QByteArray &data) ATOM filter_ref = FindAtom(qaxatom); #endif if (!filter_ref) - previous_filter = QAbstractEventDispatcher::instance()->setEventFilter(axc_FilterProc); + QAbstractEventDispatcher::instance()->installNativeEventFilter(s_nativeEventFilter()); #if !defined(Q_OS_WINCE) AddAtom(qaxatom); #else @@ -2075,8 +2067,7 @@ void QAxWidget::clear() #else if (!filter_ref && !--filter_ref) { #endif - QAbstractEventDispatcher::instance()->setEventFilter(previous_filter); - previous_filter = 0; + QAbstractEventDispatcher::instance()->removeNativeEventFilter(s_nativeEventFilter()); } } diff --git a/src/activeqt/container/qaxwidget.h b/src/activeqt/container/qaxwidget.h index 1e7f927..ae3cf12 100644 --- a/src/activeqt/container/qaxwidget.h +++ b/src/activeqt/container/qaxwidget.h @@ -56,6 +56,7 @@ class QAxHostWindow; class QAxAggregated; class QAxClientSite; +class QAxWidgetPrivate; class QAxWidget : public QWidget, public QAxBase { @@ -92,7 +93,8 @@ protected: private: friend class QAxClientSite; QAxClientSite *container; - + + QAxWidgetPrivate *d; const QMetaObject *parentMetaObject() const; }; diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index a272104..03bbc0c 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -65,6 +65,7 @@ #include <private/qcoreapplication_p.h> #include <qwindow.h> #include <qpa/qplatformnativeinterface.h> +#include <qabstractnativeeventfilter.h> #include "qaxfactory.h" #include "qaxbindable.h" @@ -752,7 +753,13 @@ LRESULT QT_WIN_CALLBACK axs_FilterProc(int nCode, WPARAM wParam, LPARAM lParam) // filter for executable case to hook into Qt eventloop // for DLLs the client calls TranslateAccelerator -bool qax_winEventFilter(void *message) +class QAxWinEventFilter : public QAbstractNativeEventFilter +{ +public: + virtual bool nativeEventFilter(const QByteArray &, void *message, long *) Q_DECL_OVERRIDE; +}; + +bool QAxWinEventFilter::nativeEventFilter(const QByteArray &, void *message, long *) { MSG *pMsg = (MSG*)message; if (pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) @@ -782,6 +789,7 @@ bool qax_winEventFilter(void *message) return hres == S_OK; } +Q_GLOBAL_STATIC(QAxWinEventFilter, qax_winEventFilter); // COM Factory class, mapping COM requests to ActiveQt requests. // One instance of this class for each ActiveX the server can provide. @@ -862,7 +870,7 @@ public: qApp->setQuitOnLastWindowClosed(false); if (qAxOutProcServer) - QAbstractEventDispatcher::instance()->setEventFilter(qax_winEventFilter); + QAbstractEventDispatcher::instance()->installNativeEventFilter(qax_winEventFilter()); else QApplication::instance()->d_func()->in_exec = true; |