diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-01-27 14:09:36 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-30 16:40:02 +0100 |
commit | 870f19f44b1eb2b93c7151dd48b8d9cd471acae8 (patch) | |
tree | 111a6ae7cf59b83ca6f872bd537b4c8a635d8800 /src/widgets/kernel | |
parent | b3a978d661b7d85b637e8e8a134bd1df925947f8 (diff) |
Add native event filters to Windows, forward to Widgets.
Use prototypically for qwizard_win.cpp.
Change-Id: I075e81ae1bc3d62d9f27e51c73c800ffd71cbcd6
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 105 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.h | 14 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow_qpa.cpp | 5 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow_qpa_p.h | 1 |
4 files changed, 22 insertions, 103 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index af3941c231..4402b497ad 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -8963,111 +8963,36 @@ void QWidget::hideEvent(QHideEvent *) { } -/* - \fn QWidget::x11Event(MSG *) - - This special event handler can be reimplemented in a subclass to receive - native X11 events. - - In your reimplementation of this function, if you want to stop Qt from - handling the event, return true. If you return false, this native event - is passed back to Qt, which translates it into a Qt event and sends it to - the widget. - - \note Events are only delivered to this event handler if the widget is - native. - - \warning This function is not portable. - - \sa QApplication::x11EventFilter(), QWidget::winId() -*/ - - -#if defined(Q_WS_MAC) - /*! - \fn bool QWidget::macEvent(EventHandlerCallRef caller, EventRef event) - This special event handler can be reimplemented in a subclass to - receive native Macintosh events. - - The parameters are a bit different depending if Qt is build against Carbon - or Cocoa. In Carbon, \a caller and \a event are the corresponding - EventHandlerCallRef and EventRef that correspond to the Carbon event - handlers that are installed. In Cocoa, \a caller is always 0 and the - EventRef is the EventRef generated from the NSEvent. + receive native platform events identified by \a eventType + which are passed in the \a message parameter. In your reimplementation of this function, if you want to stop the - event being handled by Qt, return true. If you return false, this - native event is passed back to Qt, which translates the event into - a Qt event and sends it to the widget. + event being handled by Qt, return true and set \a result. + If you return false, this native event is passed back to Qt, + which translates the event into a Qt event and sends it to the widget. - \warning This function is not portable. + \note Events are only delivered to this event handler if the widget is + has a native Window handle. - \warning This function was not called inside of Qt until Qt 4.4. - If you need compatibility with earlier versions of Qt, consider QApplication::macEventFilter() instead. + \note This function superseedes the event filter functions + x11Event(), winEvent() and macEvent() of Qt 4. - \sa QApplication::macEventFilter() + \table + \header \i Platform \i Event Type Identifier \i Message Type \i Result Type + \row \i Windows \i "windows_generic_MSG" \i MSG * \i LRESULT + \endtable */ -bool QWidget::macEvent(EventHandlerCallRef, EventRef) -{ - return false; -} - -#endif -#if defined(Q_WS_WIN) - -/*! - This special event handler can be reimplemented in a subclass to - receive native Windows events which are passed in the \a message - parameter. - - In your reimplementation of this function, if you want to stop the - event being handled by Qt, return true and set \a result to the value - that the window procedure should return. If you return false, this - native event is passed back to Qt, which translates the event into - a Qt event and sends it to the widget. - - \warning This function is not portable. - - \sa QApplication::winEventFilter() -*/ -bool QWidget::winEvent(MSG *message, long *result) +bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) { + Q_UNUSED(eventType); Q_UNUSED(message); Q_UNUSED(result); return false; } -#endif -#if defined(Q_WS_X11) - -/*! - \fn bool QWidget::x11Event(XEvent *event) - - This special event handler can be reimplemented in a subclass to receive - native X11 events passed in the \a event parameter. - - In your reimplementation of this function, if you want to stop Qt from - handling the event, return true. If you return false, this native event - is passed back to Qt, which translates it into a Qt event and sends it to - the widget. - - \note Events are only delivered to this event handler if the widget is - native. - - \warning This function is not portable. - - \sa QApplication::x11EventFilter(), QWidget::winId() -*/ -bool QWidget::x11Event(XEvent *) -{ - return false; -} - -#endif - /*! Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index f21b2118a4..f24941d856 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -660,19 +660,7 @@ protected: virtual void showEvent(QShowEvent *); virtual void hideEvent(QHideEvent *); - -#if defined(Q_WS_MAC) - virtual bool macEvent(EventHandlerCallRef, EventRef); -#endif -#if defined(Q_WS_WIN) - virtual bool winEvent(MSG *message, long *result); -#endif -#if defined(Q_WS_X11) - virtual bool x11Event(XEvent *); -#endif -#if defined(Q_WS_QWS) - virtual bool qwsEvent(QWSEvent *); -#endif + virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result); // Misc. protected functions virtual void changeEvent(QEvent *); diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index e546df755d..e7ba4853a0 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -431,4 +431,9 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent); } +bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) +{ + return m_widget->nativeEvent(eventType, message, result); +} + QT_END_NAMESPACE diff --git a/src/widgets/kernel/qwidgetwindow_qpa_p.h b/src/widgets/kernel/qwidgetwindow_qpa_p.h index d7fdb5d4de..1e8813fddc 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa_p.h +++ b/src/widgets/kernel/qwidgetwindow_qpa_p.h @@ -79,6 +79,7 @@ protected: void handleDragEvent(QEvent *); void handleExposeEvent(QExposeEvent *); void handleWindowStateChangedEvent(QWindowStateChangeEvent *event); + bool nativeEvent(const QByteArray &eventType, void *message, long *result); private: void updateGeometry(); |