mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-07 21:56:44 +01:00
emscripten: install a callback for visibility changes
Fixes an issue where focus blur event was being dispatched only after the game has been focused again.
This commit is contained in:
parent
2ad77b071f
commit
f07b075052
2 changed files with 8 additions and 0 deletions
|
@ -384,6 +384,12 @@ SYMBOL_INTERNAL void libsuperderpy_emscripten_mainloop(void* game) {
|
||||||
emscripten_cancel_main_loop();
|
emscripten_cancel_main_loop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SYMBOL_INTERNAL EM_BOOL libsuperderpy_emscripten_visibility_change(int eventType, const EmscriptenVisibilityChangeEvent* visibilityChangeEvent, void* game) {
|
||||||
|
libsuperderpy_emscripten_mainloop(game);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SYMBOL_EXPORT int libsuperderpy_run(struct Game* game) {
|
SYMBOL_EXPORT int libsuperderpy_run(struct Game* game) {
|
||||||
|
@ -392,6 +398,7 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game* game) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
|
emscripten_set_visibilitychange_callback(game, false, libsuperderpy_emscripten_visibility_change);
|
||||||
emscripten_set_main_loop_arg(libsuperderpy_emscripten_mainloop, game, 0, true);
|
emscripten_set_main_loop_arg(libsuperderpy_emscripten_mainloop, game, 0, true);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -63,6 +63,7 @@ struct GamestateResources;
|
||||||
#include <allegro5/allegro_iphone.h>
|
#include <allegro5/allegro_iphone.h>
|
||||||
#elif defined(__EMSCRIPTEN__)
|
#elif defined(__EMSCRIPTEN__)
|
||||||
#include <emscripten/emscripten.h>
|
#include <emscripten/emscripten.h>
|
||||||
|
#include <emscripten/html5.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "character.h"
|
#include "character.h"
|
||||||
|
|
Loading…
Reference in a new issue