diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-05-16 18:51:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-16 18:51:37 +0200 |
commit | 1702fb7ad2b2e072ff74f579f9d243db96e7b480 (patch) | |
tree | 21c10d16d14c051982b2b54848b353200474b61a /platform | |
parent | e669aa302bccfb79a4d267ee06bb2c7096f3ffb2 (diff) | |
parent | 434bf0572ce6e982a41be0d83f0869ec10a91eb2 (diff) |
Merge pull request #37519 from HaSa1002/fix-duplicate-inputs-win
Fix input event being dispatched multiple times on Windows
Diffstat (limited to 'platform')
-rw-r--r-- | platform/windows/display_server_windows.cpp | 9 | ||||
-rw-r--r-- | platform/windows/display_server_windows.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 114b64855e..14116d6f23 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1695,6 +1695,12 @@ void DisplayServerWindows::_dispatch_input_events(const Ref<InputEvent> &p_event } void DisplayServerWindows::_dispatch_input_event(const Ref<InputEvent> &p_event) { + _THREAD_SAFE_METHOD_ + if (in_dispatch_input_event) { + return; + } + + in_dispatch_input_event = true; Variant ev = p_event; Variant *evp = &ev; Variant ret; @@ -1706,6 +1712,7 @@ void DisplayServerWindows::_dispatch_input_event(const Ref<InputEvent> &p_event) ERR_FAIL_COND(!windows.has(event_from_window->get_window_id())); Callable callable = windows[event_from_window->get_window_id()].input_event_callback; if (callable.is_null()) { + in_dispatch_input_event = false; return; } callable.call((const Variant **)&evp, 1, ret, ce); @@ -1719,6 +1726,8 @@ void DisplayServerWindows::_dispatch_input_event(const Ref<InputEvent> &p_event) callable.call((const Variant **)&evp, 1, ret, ce); } } + + in_dispatch_input_event = false; } LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index ea08b1899f..f8606bb492 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -388,6 +388,7 @@ class DisplayServerWindows : public DisplayServer { uint32_t last_button_state = 0; bool use_raw_input = false; bool drop_events = false; + bool in_dispatch_input_event = false; bool console_visible = false; WNDCLASSEXW wc; |