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. Change-Id: I3ea9c55c1d9c03195c1937c4dcc0e5b689e15448 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 3f8f79ddafc68e2a3e1bdf59355e9a4958f46d12) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
f4cc885f8c
commit
f9b5440292
@ -223,8 +223,7 @@ bool QEventDispatcherWasm::processEvents(QEventLoop::ProcessEventsFlags flags)
|
||||
handleApplicationExec();
|
||||
}
|
||||
|
||||
QCoreApplication::sendPostedEvents();
|
||||
processWindowSystemEvents(flags);
|
||||
processPostedEvents();
|
||||
|
||||
if (m_interrupted) {
|
||||
m_interrupted = false;
|
||||
@ -242,11 +241,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);
|
||||
@ -370,7 +364,7 @@ void QEventDispatcherWasm::wakeUp()
|
||||
m_pendingProcessEvents = true;
|
||||
}
|
||||
runOnMainThreadAsync([this](){
|
||||
QEventDispatcherWasm::callProcessEvents(this);
|
||||
QEventDispatcherWasm::callProcessPostedEvents(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -462,7 +456,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());
|
||||
|
||||
@ -470,7 +464,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)
|
||||
@ -480,7 +474,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()
|
||||
|
@ -55,7 +55,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();
|
||||
@ -66,7 +66,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