diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/javascript/.eslintrc.libs.js | 3 | ||||
-rw-r--r-- | platform/javascript/SCsub | 10 | ||||
-rw-r--r-- | platform/javascript/detect.py | 4 | ||||
-rw-r--r-- | platform/javascript/emscripten_helpers.py | 12 | ||||
-rw-r--r-- | platform/windows/display_server_windows.cpp | 52 | ||||
-rw-r--r-- | platform/windows/display_server_windows.h | 6 |
6 files changed, 63 insertions, 24 deletions
diff --git a/platform/javascript/.eslintrc.libs.js b/platform/javascript/.eslintrc.libs.js index e5f0c3d147..81b1b8c864 100644 --- a/platform/javascript/.eslintrc.libs.js +++ b/platform/javascript/.eslintrc.libs.js @@ -18,5 +18,8 @@ module.exports = { "GodotRuntime": true, "GodotFS": true, "IDHandler": true, + "Browser": true, + "GL": true, + "XRWebGLLayer": true, }, }; diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index 7a8005fe30..1d3f96a6b8 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -67,6 +67,16 @@ else: sys_env.Depends(build[0], sys_env["JS_LIBS"]) +if "JS_PRE" in env: + for js in env["JS_PRE"]: + env.Append(LINKFLAGS=["--pre-js", env.File(js).path]) + env.Depends(build, env["JS_PRE"]) + +if "JS_EXTERNS" in env: + for ext in env["JS_EXTERNS"]: + env["ENV"]["EMCC_CLOSURE_ARGS"] += " --externs " + ext.path + env.Depends(build, env["JS_EXTERNS"]) + engine = [ "js/engine/preloader.js", "js/engine/utils.js", diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index d53c774e77..7d501e94b2 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -1,7 +1,7 @@ import os import sys -from emscripten_helpers import run_closure_compiler, create_engine_file, add_js_libraries +from emscripten_helpers import run_closure_compiler, create_engine_file, add_js_libraries, add_js_pre, add_js_externs from methods import get_compiler_version from SCons.Util import WhereIs @@ -133,6 +133,8 @@ def configure(env): # Add helper method for adding libraries. env.AddMethod(add_js_libraries, "AddJSLibraries") + env.AddMethod(add_js_pre, "AddJSPre") + env.AddMethod(add_js_externs, "AddJSExterns") # Add method that joins/compiles our Engine files. env.AddMethod(create_engine_file, "CreateEngineFile") diff --git a/platform/javascript/emscripten_helpers.py b/platform/javascript/emscripten_helpers.py index cc874c432e..278186e4c0 100644 --- a/platform/javascript/emscripten_helpers.py +++ b/platform/javascript/emscripten_helpers.py @@ -25,3 +25,15 @@ def add_js_libraries(env, libraries): if "JS_LIBS" not in env: env["JS_LIBS"] = [] env.Append(JS_LIBS=env.File(libraries)) + + +def add_js_pre(env, js_pre): + if "JS_PRE" not in env: + env["JS_PRE"] = [] + env.Append(JS_PRE=env.File(js_pre)) + + +def add_js_externs(env, externs): + if "JS_EXTERNS" not in env: + env["JS_EXTERNS"] = [] + env.Append(JS_EXTERNS=env.File(externs)) diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index db3d697e05..98ca724655 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1876,27 +1876,12 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA break; } - case WM_ACTIVATE: // Watch For Window Activate Message - { - windows[window_id].minimized = HIWORD(wParam) != 0; - - if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) { - _send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_IN); - windows[window_id].window_focused = true; - alt_mem = false; - control_mem = false; - shift_mem = false; - } else { // WM_INACTIVE - Input::get_singleton()->release_pressed_events(); - _send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_OUT); - windows[window_id].window_focused = false; - alt_mem = false; - }; - - if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[window_id].wtctx) { - wintab_WTEnable(windows[window_id].wtctx, GET_WM_ACTIVATE_STATE(wParam, lParam)); - } + case WM_ACTIVATE: { // Watch For Window Activate Message + saved_wparam = wParam; + saved_lparam = lParam; + // Run a timer to prevent event catching warning if the window is closing. + focus_timer_id = SetTimer(windows[window_id].hWnd, 2, USER_TIMER_MINIMUM, (TIMERPROC) nullptr); return 0; // Return To The Message Loop } case WM_GETMINMAXINFO: { @@ -1937,6 +1922,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA case WM_CLOSE: // Did We Receive A Close Message? { + if (focus_timer_id != 0U) { + KillTimer(windows[window_id].hWnd, focus_timer_id); + } _send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST); return 0; // Jump Back @@ -2630,6 +2618,28 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if (!Main::is_iterating()) { Main::iteration(); } + } else if (wParam == focus_timer_id) { + windows[window_id].minimized = HIWORD(saved_wparam) != 0; + + if (LOWORD(saved_wparam) == WA_ACTIVE || LOWORD(saved_wparam) == WA_CLICKACTIVE) { + _send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_IN); + windows[window_id].window_focused = true; + alt_mem = false; + control_mem = false; + shift_mem = false; + } else { // WM_INACTIVE + Input::get_singleton()->release_pressed_events(); + _send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_OUT); + windows[window_id].window_focused = false; + alt_mem = false; + }; + + if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[window_id].wtctx) { + wintab_WTEnable(windows[window_id].wtctx, GET_WM_ACTIVATE_STATE(saved_wparam, saved_lparam)); + } + + KillTimer(windows[window_id].hWnd, focus_timer_id); + focus_timer_id = 0U; } } break; @@ -3213,8 +3223,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } #endif - move_timer_id = 1; - //set_ime_active(false); if (!OS::get_singleton()->is_in_low_processor_usage_mode()) { diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 89dd927304..722854c538 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -387,7 +387,8 @@ private: WindowID last_focused_window = INVALID_WINDOW_ID; - uint32_t move_timer_id; + uint32_t move_timer_id = 0U; + uint32_t focus_timer_id = 0U; HCURSOR hCursor; @@ -408,6 +409,9 @@ private: bool in_dispatch_input_event = false; bool console_visible = false; + WPARAM saved_wparam; + LPARAM saved_lparam; + WNDCLASSEXW wc; HCURSOR cursors[CURSOR_MAX] = { nullptr }; |