diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2012-03-29 09:25:29 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-17 01:13:52 +0200 |
commit | 768e587cdcd74d9d5da0a477eede9ae37a24fb48 (patch) | |
tree | 43471d0aa7fecf29635a51321ecec7e4efc9985f /src/gui | |
parent | d4c4723583d7e2ec3b98d0b7fab98b9f7e1a87e8 (diff) |
Add QPlatformWindow::windowEvent()
This function is used to pass non-spontaneous events from QWindow to
QPlatformWindow so that QPlatformWindow subclasses can do any platform
specific event handling (such as setting/clearing modality flags on
QEvent::WindowBlock/WindowUnblock).
Change-Id: I82a89e8dadcd2f706aae25889d79cbfac9c2ee18
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 15 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow_qpa.cpp | 12 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow_qpa.h | 2 |
4 files changed, 31 insertions, 0 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 0eb53df443..2c2d833209 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1032,6 +1032,7 @@ bool QGuiApplication::notify(QObject *object, QEvent *event) } #endif + QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(qobject_cast<QWindow *>(object), event); return QCoreApplication::notify(object, event); } @@ -1053,6 +1054,20 @@ bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEvent return QCoreApplication::compressEvent(event, receiver, postedEvents); } +void QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event) +{ + if (!window) + return; + QPlatformWindow *platformWindow = window->handle(); + if (!platformWindow) + return; + // spontaneous events come from the platform integration already, we don't need to send the events back + if (event->spontaneous()) + return; + // let the platform window do any handling it needs to as well + platformWindow->windowEvent(event); +} + bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result) { return window->nativeEvent(eventType, message, result); diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index c0cee51832..35bf8570ea 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -129,6 +129,8 @@ public: static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result); + static void sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event); + static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment) { if (!(alignment & Qt::AlignHorizontal_Mask)) diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp index d5f0277ccd..b36a2771f3 100644 --- a/src/gui/kernel/qplatformwindow_qpa.cpp +++ b/src/gui/kernel/qplatformwindow_qpa.cpp @@ -311,6 +311,18 @@ bool QPlatformWindow::setMouseGrabEnabled(bool grab) } /*! + Reimplement this method to be able to do any platform specific event + handling. All events for window() are passed to this function before being + sent to QWindow::event(). + + The default implementation is empty and does nothing with \a event. +*/ +void QPlatformWindow::windowEvent(QEvent *event) +{ + Q_UNUSED(event); +} + +/*! \class QPlatformWindow \since 4.8 \internal diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h index a2b6bcb508..31b14ca97d 100644 --- a/src/gui/kernel/qplatformwindow_qpa.h +++ b/src/gui/kernel/qplatformwindow_qpa.h @@ -113,6 +113,8 @@ public: virtual bool setKeyboardGrabEnabled(bool grab); virtual bool setMouseGrabEnabled(bool grab); + virtual void windowEvent(QEvent *event); + protected: QScopedPointer<QPlatformWindowPrivate> d_ptr; private: |