mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Simulate all keys being released when when game loses focus (#13336)
This commit is contained in:
parent
fe75ec8d0d
commit
e139749b5c
3 changed files with 44 additions and 8 deletions
|
@ -1005,6 +1005,7 @@ private:
|
|||
bool m_invert_mouse = false;
|
||||
bool m_first_loop_after_window_activation = false;
|
||||
bool m_camera_offset_changed = false;
|
||||
bool m_game_focused;
|
||||
|
||||
bool m_does_lost_focus_pause_game = false;
|
||||
|
||||
|
@ -1965,20 +1966,29 @@ void Game::processUserInput(f32 dtime)
|
|||
{
|
||||
// Reset input if window not active or some menu is active
|
||||
if (!device->isWindowActive() || isMenuActive() || guienv->hasFocus(gui_chat_console)) {
|
||||
input->clear();
|
||||
if(m_game_focused) {
|
||||
m_game_focused = false;
|
||||
infostream << "Game lost focus" << std::endl;
|
||||
input->releaseAllKeys();
|
||||
} else {
|
||||
input->clear();
|
||||
}
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
g_touchscreengui->hide();
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
else if (g_touchscreengui) {
|
||||
/* on touchscreengui step may generate own input events which ain't
|
||||
* what we want in case we just did clear them */
|
||||
g_touchscreengui->show();
|
||||
g_touchscreengui->step(dtime);
|
||||
}
|
||||
if (g_touchscreengui) {
|
||||
/* on touchscreengui step may generate own input events which ain't
|
||||
* what we want in case we just did clear them */
|
||||
g_touchscreengui->show();
|
||||
g_touchscreengui->step(dtime);
|
||||
}
|
||||
#endif
|
||||
|
||||
m_game_focused = true;
|
||||
}
|
||||
|
||||
if (!guienv->hasFocus(gui_chat_console) && gui_chat_console->isOpen()) {
|
||||
gui_chat_console->closeConsoleAtOnce();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue