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>
This commit is contained in:
parent
8aa0d71d06
commit
3f8f79ddaf
@ -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()
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -11,7 +11,7 @@ QT_BEGIN_NAMESPACE
|
||||
class QWasmEventDispatcher : public QEventDispatcherWasm
|
||||
{
|
||||
protected:
|
||||
void processWindowSystemEvents(QEventLoop::ProcessEventsFlags flags) override;
|
||||
bool processPostedEvents() override;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user