QEventDispatcherWasm: handle EventLoopExec
Call emscripten_set_main_loop like the old GUI event dispatcher did, with one difference that requestAnimationFrame updates are now no longer handled by the event dispatcher. Change-Id: If02d90ae9c45d7b38999567d733a237af842cded Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
46039092bd
commit
088b364e4b
@ -208,6 +208,8 @@ bool QEventDispatcherWasm::processEvents(QEventLoop::ProcessEventsFlags flags)
|
|||||||
|
|
||||||
if (flags & QEventLoop::DialogExec)
|
if (flags & QEventLoop::DialogExec)
|
||||||
handleDialogExec();
|
handleDialogExec();
|
||||||
|
else if (flags & QEventLoop::EventLoopExec)
|
||||||
|
handleEventLoopExec();
|
||||||
|
|
||||||
if (!(flags & QEventLoop::ExcludeUserInputEvents))
|
if (!(flags & QEventLoop::ExcludeUserInputEvents))
|
||||||
pollForNativeEvents();
|
pollForNativeEvents();
|
||||||
@ -364,6 +366,22 @@ void QEventDispatcherWasm::wakeUp()
|
|||||||
emscripten_async_call(&QEventDispatcherWasm::callProcessEvents, this, 0);
|
emscripten_async_call(&QEventDispatcherWasm::callProcessEvents, this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QEventDispatcherWasm::handleEventLoopExec()
|
||||||
|
{
|
||||||
|
// Start the main loop, and then stop it on the first callback. This
|
||||||
|
// is done for the "simulateInfiniteLoop" functionality where
|
||||||
|
// emscripten_set_main_loop() throws a JS exception which returns
|
||||||
|
// control to the browser while preserving the C++ stack.
|
||||||
|
//
|
||||||
|
// Note that we don't use asyncify here: Emscripten supports one level of
|
||||||
|
// asyncify only and we want to reserve that for dialog exec() instead of
|
||||||
|
// using it for the one qApp exec().
|
||||||
|
const bool simulateInfiniteLoop = true;
|
||||||
|
emscripten_set_main_loop([](){
|
||||||
|
emscripten_pause_main_loop();
|
||||||
|
}, 0, simulateInfiniteLoop);
|
||||||
|
}
|
||||||
|
|
||||||
void QEventDispatcherWasm::handleDialogExec()
|
void QEventDispatcherWasm::handleDialogExec()
|
||||||
{
|
{
|
||||||
#if !QT_HAVE_EMSCRIPTEN_ASYNCIFY
|
#if !QT_HAVE_EMSCRIPTEN_ASYNCIFY
|
||||||
|
@ -90,6 +90,7 @@ private:
|
|||||||
bool isMainThreadEventDispatcher();
|
bool isMainThreadEventDispatcher();
|
||||||
bool isSecondaryThreadEventDispatcher();
|
bool isSecondaryThreadEventDispatcher();
|
||||||
|
|
||||||
|
void handleEventLoopExec();
|
||||||
void handleDialogExec();
|
void handleDialogExec();
|
||||||
void pollForNativeEvents();
|
void pollForNativeEvents();
|
||||||
bool waitForForEvents();
|
bool waitForForEvents();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user