Skip to content

Commit

Permalink
Reduce CursorChanged Events for Accessibility (#5196)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
carlos-zamora authored and DHowett committed Apr 14, 2020
1 parent 869bcb6 commit 8de952c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/renderer/uia/UiaRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -246,7 +255,6 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) :
_selectionChanged = false;
_textBufferChanged = false;
_cursorChanged = false;
_prevSelection.clear();
_isPainting = false;

return S_OK;
Expand Down
1 change: 1 addition & 0 deletions src/renderer/uia/UiaRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ namespace Microsoft::Console::Render
Microsoft::Console::Types::IUiaEventDispatcher* _dispatcher;

std::vector<SMALL_RECT> _prevSelection;
til::point _prevCursorPos;
};
}

0 comments on commit 8de952c

Please sign in to comment.