diff options
author | Morten Sørvig <morten.sorvig@qt.io> | 2023-06-28 14:16:45 +0200 |
---|---|---|
committer | Morten Sørvig <morten.sorvig@qt.io> | 2023-07-04 15:42:01 +0200 |
commit | 3f8f79ddafc68e2a3e1bdf59355e9a4958f46d12 (patch) | |
tree | dfec5c39bb07cba62ab4d5f9d2f1cf4c1235d842 | |
parent | 8aa0d71d06fc1673d90bddecc15c8c7917a39c32 (diff) |
wasm: introduce virtual processPostedEvents()
Don't re-use processEvents() for the case where we
get a callback from the native event loop and want
to send events. This makes it clearer that these are
two different cases.
Align with the Core Foundation event dispatcher where
processPostedEvents() is virtual and is overridden
by the Gui event dispatcher to send window system events.
Pick-to: 6.6
Change-Id: I3ea9c55c1d9c03195c1937c4dcc0e5b689e15448
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_wasm.cpp | 23 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_wasm_p.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmeventdispatcher.cpp | 7 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmeventdispatcher.h | 2 |
4 files changed, 19 insertions, 17 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_wasm.cpp b/src/corelib/kernel/qeventdispatcher_wasm.cpp index e4e6dbfdce..c101f348f1 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm.cpp +++ b/src/corelib/kernel/qeventdispatcher_wasm.cpp @@ -266,8 +266,7 @@ bool QEventDispatcherWasm::processEvents(QEventLoop::ProcessEventsFlags flags) handleApplicationExec(); } - QCoreApplication::sendPostedEvents(); - processWindowSystemEvents(flags); + processPostedEvents(); if (m_interrupted) { m_interrupted = false; @@ -285,11 +284,6 @@ bool QEventDispatcherWasm::processEvents(QEventLoop::ProcessEventsFlags flags) return false; } -void QEventDispatcherWasm::processWindowSystemEvents(QEventLoop::ProcessEventsFlags flags) -{ - Q_UNUSED(flags); -} - void QEventDispatcherWasm::registerSocketNotifier(QSocketNotifier *notifier) { LOCK_GUARD(g_staticDataMutex); @@ -413,7 +407,7 @@ void QEventDispatcherWasm::wakeUp() m_pendingProcessEvents = true; } runOnMainThreadAsync([this](){ - QEventDispatcherWasm::callProcessEvents(this); + QEventDispatcherWasm::callProcessPostedEvents(this); }); } } @@ -519,7 +513,7 @@ bool QEventDispatcherWasm::wakeEventDispatcherThread() // Process event activation callbacks for the main thread event dispatcher. // Must be called on the main thread. -void QEventDispatcherWasm::callProcessEvents(void *context) +void QEventDispatcherWasm::callProcessPostedEvents(void *context) { Q_ASSERT(emscripten_is_main_runtime_thread()); @@ -527,7 +521,7 @@ void QEventDispatcherWasm::callProcessEvents(void *context) if (!g_mainThreadEventDispatcher) return; - // In the unlikely event that we get a callProcessEvents() call for + // In the unlikely event that we get a callProcessPostedEvents() call for // a previous main thread event dispatcher (i.e. the QApplication // object was deleted and created again): just ignore it and return. if (context != g_mainThreadEventDispatcher) @@ -537,7 +531,14 @@ void QEventDispatcherWasm::callProcessEvents(void *context) LOCK_GUARD(g_mainThreadEventDispatcher->m_mutex); g_mainThreadEventDispatcher->m_pendingProcessEvents = false; } - g_mainThreadEventDispatcher->processEvents(QEventLoop::AllEvents); + + g_mainThreadEventDispatcher->processPostedEvents(); +} + +bool QEventDispatcherWasm::processPostedEvents() +{ + QCoreApplication::sendPostedEvents(); + return false; } void QEventDispatcherWasm::processTimers() diff --git a/src/corelib/kernel/qeventdispatcher_wasm_p.h b/src/corelib/kernel/qeventdispatcher_wasm_p.h index d42bc6281c..8a9782a96f 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm_p.h +++ b/src/corelib/kernel/qeventdispatcher_wasm_p.h @@ -56,7 +56,7 @@ public: static void socketSelect(int timeout, int socket, bool waitForRead, bool waitForWrite, bool *selectForRead, bool *selectForWrite, bool *socketDisconnect); protected: - virtual void processWindowSystemEvents(QEventLoop::ProcessEventsFlags flags); + virtual bool processPostedEvents(); private: bool isMainThreadEventDispatcher(); @@ -67,7 +67,7 @@ private: void handleDialogExec(); bool wait(int timeout = -1); bool wakeEventDispatcherThread(); - static void callProcessEvents(void *eventDispatcher); + static void callProcessPostedEvents(void *eventDispatcher); void processTimers(); void updateNativeTimer(); diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp index 2fd1a30401..cd2cefc14d 100644 --- a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp @@ -8,10 +8,11 @@ QT_BEGIN_NAMESPACE // Note: All event dispatcher functionality is implemented in QEventDispatcherWasm -// in QtCore, except for processWindowSystemEvents() below which uses API from QtGui. -void QWasmEventDispatcher::processWindowSystemEvents(QEventLoop::ProcessEventsFlags flags) +// in QtCore, except for processPostedEvents() below which uses API from QtGui. +bool QWasmEventDispatcher::processPostedEvents() { - QWindowSystemInterface::sendWindowSystemEvents(flags); + QEventDispatcherWasm::processPostedEvents(); + return QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.h b/src/plugins/platforms/wasm/qwasmeventdispatcher.h index a28fa7263b..33d672a57f 100644 --- a/src/plugins/platforms/wasm/qwasmeventdispatcher.h +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.h @@ -11,7 +11,7 @@ QT_BEGIN_NAMESPACE class QWasmEventDispatcher : public QEventDispatcherWasm { protected: - void processWindowSystemEvents(QEventLoop::ProcessEventsFlags flags) override; + bool processPostedEvents() override; }; QT_END_NAMESPACE |