Fix restoring locked cursor state when window gains focus again

This commit is contained in:
2025-03-31 23:25:38 +03:00
parent d355f9eff5
commit c1f76abc22
5 changed files with 22 additions and 2 deletions

View File

@@ -440,6 +440,9 @@ void SDLWindow::HandleEvent(SDL_Event& event)
if (inRelativeMode)
Input::Mouse->SetRelativeMode(true, this);
}
else if (_restoreRelativeMode)
Input::Mouse->SetRelativeMode(true, this);
_restoreRelativeMode = false;
return;
}
case SDL_EVENT_WINDOW_FOCUS_LOST:
@@ -448,6 +451,13 @@ void SDLWindow::HandleEvent(SDL_Event& event)
SDL_StopTextInput(_window);
if (_isClippingCursor)
SDL_SetWindowMouseRect(_window, nullptr);
if (Input::Mouse->IsRelative(this))
{
Input::Mouse->SetRelativeMode(false, this);
_restoreRelativeMode = true;
}
OnLostFocus();
return;
}