diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-05-16 18:46:50 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-05-20 12:26:28 +0000 |
commit | da8ace713a19d2a8c9831ddf50d17607bc4856cc (patch) | |
tree | 2e48cee43e46de9ffad45f9b614529410cd35f42 /src/corelib | |
parent | f78ef9753c58587a5db292493b2c003a3e0a3144 (diff) |
QWidgetWindow: Forward incoming events with their original spontaneous state
The events may come from QPA, as spontaneous events, or from other parts
of Qt, as non-spontaneous events. We should keep the state of the original
event.
Introduces QCoreApplication::forwardEvent() as a wrapper around the
opaquely named notifyInternal2. Ideally this would be the behavior of
sendEvent, with an enum argument to override the flag, but that ship
has sailed.
Change-Id: Ib0209f2b99744bd10590c63239ee7a97b60be4fd
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 15 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 39e7c71a9c..a5bd2513b6 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1019,6 +1019,21 @@ bool QCoreApplication::notifyInternal2(QObject *receiver, QEvent *event) } /*! + \internal + \since 5.10 + + Forwards the \a event to the \a receiver, using the spontaneous + state of the \a originatingEvent if specified. +*/ +bool QCoreApplication::forwardEvent(QObject *receiver, QEvent *event, QEvent *originatingEvent) +{ + if (event && originatingEvent) + event->spont = originatingEvent->spont; + + return notifyInternal2(receiver, event); +} + +/*! Sends \a event to \a receiver: \a {receiver}->event(\a event). Returns the value that is returned from the receiver's event handler. Note that this function is called for all events sent to diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 0fee7b3de8..34133533f0 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -206,6 +206,7 @@ private: QT_DEPRECATED bool notifyInternal(QObject *receiver, QEvent *event); // ### Qt6 BIC: remove me # endif static bool notifyInternal2(QObject *receiver, QEvent *); + static bool forwardEvent(QObject *receiver, QEvent *event, QEvent *originatingEvent = nullptr); #endif static QCoreApplication *self; |