Merge pull request #28061 from guilhermefelipecgs/fix_19137
[Input] Release keys/actions pressed if window loses focus
This commit is contained in:
commit
b2f6beb888
5 changed files with 23 additions and 0 deletions
|
@ -677,6 +677,19 @@ void InputDefault::set_use_accumulated_input(bool p_enable) {
|
||||||
use_accumulated_input = p_enable;
|
use_accumulated_input = p_enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputDefault::release_pressed_events() {
|
||||||
|
|
||||||
|
flush_accumulated_events(); // this is needed to release actions strengths
|
||||||
|
|
||||||
|
keys_pressed.clear();
|
||||||
|
joy_buttons_pressed.clear();
|
||||||
|
_joy_axis.clear();
|
||||||
|
|
||||||
|
for (Map<StringName, InputDefault::Action>::Element *E = action_state.front(); E; E = E->next()) {
|
||||||
|
action_release(E->key());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
InputDefault::InputDefault() {
|
InputDefault::InputDefault() {
|
||||||
|
|
||||||
use_accumulated_input = true;
|
use_accumulated_input = true;
|
||||||
|
|
|
@ -272,6 +272,7 @@ public:
|
||||||
virtual void flush_accumulated_events();
|
virtual void flush_accumulated_events();
|
||||||
virtual void set_use_accumulated_input(bool p_enable);
|
virtual void set_use_accumulated_input(bool p_enable);
|
||||||
|
|
||||||
|
virtual void release_pressed_events();
|
||||||
InputDefault();
|
InputDefault();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -337,6 +337,11 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidMove:(NSNotification *)notification {
|
- (void)windowDidMove:(NSNotification *)notification {
|
||||||
|
|
||||||
|
if (OS_OSX::singleton->get_main_loop()) {
|
||||||
|
OS_OSX::singleton->input->release_pressed_events();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
[window->nsgl.context update];
|
[window->nsgl.context update];
|
||||||
|
|
||||||
|
|
|
@ -346,6 +346,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
control_mem = false;
|
control_mem = false;
|
||||||
shift_mem = false;
|
shift_mem = false;
|
||||||
} else { // WM_INACTIVE
|
} else { // WM_INACTIVE
|
||||||
|
input->release_pressed_events();
|
||||||
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
||||||
alt_mem = false;
|
alt_mem = false;
|
||||||
};
|
};
|
||||||
|
@ -786,6 +787,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case WM_ENTERSIZEMOVE: {
|
case WM_ENTERSIZEMOVE: {
|
||||||
|
input->release_pressed_events();
|
||||||
move_timer_id = SetTimer(hWnd, 1, USER_TIMER_MINIMUM, (TIMERPROC)NULL);
|
move_timer_id = SetTimer(hWnd, 1, USER_TIMER_MINIMUM, (TIMERPROC)NULL);
|
||||||
} break;
|
} break;
|
||||||
case WM_EXITSIZEMOVE: {
|
case WM_EXITSIZEMOVE: {
|
||||||
|
|
|
@ -2076,7 +2076,9 @@ void OS_X11::process_xevents() {
|
||||||
|
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
window_has_focus = false;
|
window_has_focus = false;
|
||||||
|
input->release_pressed_events();
|
||||||
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
||||||
|
|
||||||
if (mouse_mode_grab) {
|
if (mouse_mode_grab) {
|
||||||
//dear X11, I try, I really try, but you never work, you do whathever you want.
|
//dear X11, I try, I really try, but you never work, you do whathever you want.
|
||||||
if (mouse_mode == MOUSE_MODE_CAPTURED) {
|
if (mouse_mode == MOUSE_MODE_CAPTURED) {
|
||||||
|
|
Loading…
Reference in a new issue