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>
This commit is contained in:
Bradley T. Hughes 2012-03-29 09:25:29 +02:00 committed by Qt by Nokia
parent d4c4723583
commit 768e587cdc
5 changed files with 33 additions and 0 deletions

View File

@ -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);

View File

@ -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))

View File

@ -310,6 +310,18 @@ bool QPlatformWindow::setMouseGrabEnabled(bool grab)
return false;
}
/*!
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

View File

@ -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:

View File

@ -2992,6 +2992,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
d->checkReceiverThread(receiver);
#endif
QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(qobject_cast<QWindow *>(receiver), e);
// capture the current mouse/keyboard state
if(e->spontaneous()) {
if (e->type() == QEvent::MouseButtonPress