* Improve mouse grabbing.

This fixes a bug where the mouse would be restricted to the window after the level is loaded even if the window isn't focused.
This commit is contained in:
iProgramInCpp
2023-08-01 11:08:56 +03:00
parent 67d1fc4f44
commit af11c5281c
6 changed files with 30 additions and 2 deletions

View File

@@ -244,8 +244,13 @@ void AppPlatform_windows::setMouseGrabbed(bool b)
m_bGrabbedMouse = b;
if (!b)
if (m_bActuallyGrabbedMouse == (b && m_bIsFocused))
return;
if (!b || !m_bIsFocused)
{
m_bActuallyGrabbedMouse = false;
//show the cursor
ShowCursor(TRUE);
@@ -256,6 +261,8 @@ void AppPlatform_windows::setMouseGrabbed(bool b)
}
else
{
m_bActuallyGrabbedMouse = true;
//hide the cursor
ShowCursor(FALSE);
@@ -290,6 +297,12 @@ void AppPlatform_windows::clearDiff()
m_MouseDiffX = m_MouseDiffY = 0;
}
void AppPlatform_windows::updateFocused(bool focused)
{
m_bIsFocused = focused;
setMouseGrabbed(m_bGrabbedMouse);
}
bool AppPlatform_windows::shiftPressed()
{
return m_bShiftPressed;