emscripten: Check whether window has focus at engine start

This commit is contained in:
Sebastian Krzyszkowiak 2020-05-10 18:52:28 +02:00
parent 8b9c9e5541
commit 55692916e3
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF

View file

@ -514,6 +514,10 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game* game) {
}
#ifdef __EMSCRIPTEN__
emscripten_set_blur_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, game, false, libsuperderpy_emscripten_focus_change);
if (game->config.autopause && !EM_ASM_INT({document.hasFocus()})) {
PrintConsole(game, "Window not focused, autopausing...");
PauseExecution(game);
}
emscripten_set_main_loop_arg(libsuperderpy_emscripten_mainloop, game, 0, true);
return 0;
#else