diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-09-03 11:28:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-03 11:28:03 +0200 |
commit | 6a08f8288ee53456820817fea70598fa846cea3e (patch) | |
tree | c266ce9db2eb109b6533a5abb60e6c9243aac838 /platform | |
parent | ce28452109676d55e4d1fbb7158c8bf1fa8db406 (diff) | |
parent | 8c4fb4cec8c69d882dfce64a2054a0c4bb99d708 (diff) |
Merge pull request #10914 from eska014/html5-main-notif
Prevent sending MainLoop notifications before initialized
Diffstat (limited to 'platform')
-rw-r--r-- | platform/javascript/os_javascript.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index a0e5610591..ac8d367366 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -521,21 +521,6 @@ void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, i #undef SET_EM_CALLBACK #undef EM_CHECK - /* clang-format off */ - EM_ASM_ARGS({ - const send_notification = Module.cwrap('send_notification', null, ['number']); - const notifs = arguments; - (['mouseover', 'mouseleave', 'focus', 'blur']).forEach(function(event, i) { - Module.canvas.addEventListener(event, send_notification.bind(this, notifs[i])); - }); - }, - MainLoop::NOTIFICATION_WM_MOUSE_ENTER, - MainLoop::NOTIFICATION_WM_MOUSE_EXIT, - MainLoop::NOTIFICATION_WM_FOCUS_IN, - MainLoop::NOTIFICATION_WM_FOCUS_OUT - ); -/* clang-format on */ - #ifdef JAVASCRIPT_EVAL_ENABLED javascript_eval = memnew(JavaScript); ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JavaScript", javascript_eval)); @@ -818,7 +803,23 @@ void OS_JavaScript::main_loop_begin() { if (main_loop) main_loop->init(); + + /* clang-format off */ + EM_ASM_ARGS({ + const send_notification = Module.cwrap('send_notification', null, ['number']); + const notifs = arguments; + (['mouseover', 'mouseleave', 'focus', 'blur']).forEach(function(event, i) { + Module.canvas.addEventListener(event, send_notification.bind(null, notifs[i])); + }); + }, + MainLoop::NOTIFICATION_WM_MOUSE_ENTER, + MainLoop::NOTIFICATION_WM_MOUSE_EXIT, + MainLoop::NOTIFICATION_WM_FOCUS_IN, + MainLoop::NOTIFICATION_WM_FOCUS_OUT + ); + /* clang-format on */ } + bool OS_JavaScript::main_loop_iterate() { if (!main_loop) |