Skip to content

Commit

Permalink
Merge pull request #37519 from HaSa1002/fix-duplicate-inputs-win
Browse files Browse the repository at this point in the history
Fix input event being dispatched multiple times on Windows
  • Loading branch information
akien-mga authored May 16, 2020
2 parents e669aa3 + 434bf05 commit 1702fb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions platform/windows/display_server_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1702fb7

Please sign in to comment.