Add check to cursor hidden/showing loops.

This commit is contained in:
Chandler Cox
2024-05-30 08:47:41 -05:00
parent 7c4b8758ea
commit f01784108d
2 changed files with 21 additions and 2 deletions

View File

@@ -778,7 +778,16 @@ void WindowsWindow::UpdateCursor()
if (!_lastCursorHidden)
{
_lastCursorHidden = true;
while(::ShowCursor(FALSE) >= 0);
while(::ShowCursor(FALSE) >= 0)
{
if (_cursorHiddenSafetyCount >= 100)
{
LOG(Warning, "Cursor has failed to hide.");
break;
}
_cursorHiddenSafetyCount += 1;
}
_cursorHiddenSafetyCount = 0;
}
::SetCursor(nullptr);
return;
@@ -786,7 +795,16 @@ void WindowsWindow::UpdateCursor()
else if (_lastCursorHidden)
{
_lastCursorHidden = false;
while(::ShowCursor(TRUE) < 0);
while(::ShowCursor(TRUE) < 0)
{
if (_cursorHiddenSafetyCount >= 100)
{
LOG(Warning, "Cursor has failed to show.");
break;
}
_cursorHiddenSafetyCount += 1;
}
_cursorHiddenSafetyCount = 0;
}
int32 index = 0;

View File

@@ -29,6 +29,7 @@ private:
bool _trackingMouse = false;
bool _clipCursorSet = false;
bool _lastCursorHidden = false;
int _cursorHiddenSafetyCount = 0;
bool _isDuringMaximize = false;
Windows::HANDLE _monitor = nullptr;
Windows::LONG _clipCursorRect[4];