diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index d6b806a8f79..9b2be2e5115 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -916,6 +916,17 @@ void OS_JavaScript::initialize_core() { Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { + /* clang-format off */ + swap_ok_cancel = EM_ASM_INT({ + const win = (['Windows', 'Win64', 'Win32', 'WinCE']); + const plat = navigator.platform || ""; + if (win.indexOf(plat) !== -1) { + return 1; + } + return 0; + }) == 1; + /* clang-format on */ + EmscriptenWebGLContextAttributes attributes; emscripten_webgl_init_context_attributes(&attributes); attributes.alpha = GLOBAL_GET("display/window/per_pixel_transparency/allowed"); @@ -1084,6 +1095,10 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, return OK; } +bool OS_JavaScript::get_swap_ok_cancel() { + return swap_ok_cancel; +} + void OS_JavaScript::swap_buffers() { emscripten_webgl_commit_frame(); } @@ -1428,6 +1443,7 @@ OS_JavaScript::OS_JavaScript(int p_argc, char *p_argv[]) { visual_server = NULL; audio_driver_javascript = NULL; + swap_ok_cancel = false; idb_available = false; sync_wait_time = -1; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index d27d9958e3d..1f277014068 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -69,6 +69,7 @@ class OS_JavaScript : public OS_Unix { AudioDriverJavaScript *audio_driver_javascript; VisualServer *visual_server; + bool swap_ok_cancel; bool idb_available; int64_t sync_wait_time; int64_t last_sync_check_time; @@ -115,6 +116,7 @@ public: // Override return type to make writing static callbacks less tedious. static OS_JavaScript *get_singleton(); + virtual bool get_swap_ok_cancel(); virtual void swap_buffers(); virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0); virtual VideoMode get_video_mode(int p_screen = 0) const;