Reduce CursorChanged Events for Accessibility (#5196)

## Summary of the Pull Request
Reduce the number of times we dispatch a cursor changed event. We were firing it every time the renderer had to do anything related to the cursor. Unfortunately, blinking the cursor triggered this behavior. Now we just check if the position has changed.

## PR Checklist
* [X] Closes #5143


## Validation Steps Performed
Verified using Narrator
Also verified #3791 still works right
This commit is contained in:
Carlos Zamora 2020-04-01 08:56:20 -07:00 committed by GitHub
parent 8585bc6bde
commit f8227e6fa2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View file

@ -68,12 +68,21 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) :
// Arguments:
// - pcoordCursor - the new position of the cursor
// Return Value:
// - S_FALSE
[[nodiscard]] HRESULT UiaEngine::InvalidateCursor(const COORD* const /*pcoordCursor*/) noexcept
// - S_OK
[[nodiscard]] HRESULT UiaEngine::InvalidateCursor(const COORD* const pcoordCursor) noexcept
try
{
_cursorChanged = true;
return S_FALSE;
RETURN_HR_IF_NULL(E_INVALIDARG, pcoordCursor);
// check if cursor moved
if (*pcoordCursor != _prevCursorPos)
{
_prevCursorPos = *pcoordCursor;
_cursorChanged = true;
}
return S_OK;
}
CATCH_RETURN();
// Routine Description:
// - Invalidates a rectangle describing a pixel area on the display
@ -246,7 +255,6 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) :
_selectionChanged = false;
_textBufferChanged = false;
_cursorChanged = false;
_prevSelection.clear();
_isPainting = false;
return S_OK;

View file

@ -88,5 +88,6 @@ namespace Microsoft::Console::Render
Microsoft::Console::Types::IUiaEventDispatcher* _dispatcher;
std::vector<SMALL_RECT> _prevSelection;
til::point _prevCursorPos;
};
}