From 8403a766d7d1ff3874c55a85500fbfa4d53e23fd Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Mon, 30 Mar 2020 16:44:25 -0700 Subject: [PATCH 1/6] Reduce CursorChanged Events for Accessibility --- src/cascadia/TerminalControl/TermControl.cpp | 5 +++++ src/renderer/uia/UiaRenderer.cpp | 6 +++++- src/renderer/uia/UiaRenderer.hpp | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 7d5d0d76ee6..383498b8e08 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1817,6 +1817,11 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation if (!_closing.load()) { TSFInputControl().TryRedrawCanvas(); + + if (_uiaEngine.get()) + { + _uiaEngine->CursorPositionChanged(); + } } } } diff --git a/src/renderer/uia/UiaRenderer.cpp b/src/renderer/uia/UiaRenderer.cpp index 68c03b7077e..8982dba01c6 100644 --- a/src/renderer/uia/UiaRenderer.cpp +++ b/src/renderer/uia/UiaRenderer.cpp @@ -71,7 +71,6 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) : // - S_FALSE [[nodiscard]] HRESULT UiaEngine::InvalidateCursor(const COORD* const /*pcoordCursor*/) noexcept { - _cursorChanged = true; return S_FALSE; } @@ -454,6 +453,11 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) : return S_FALSE; } +void UiaEngine::CursorPositionChanged() noexcept +{ + _cursorChanged = true; +} + // Method Description: // - Updates the window's title string. // - Currently unused by this renderer. diff --git a/src/renderer/uia/UiaRenderer.hpp b/src/renderer/uia/UiaRenderer.hpp index 3f7ced8e33f..8f91e7ffe2e 100644 --- a/src/renderer/uia/UiaRenderer.hpp +++ b/src/renderer/uia/UiaRenderer.hpp @@ -75,6 +75,7 @@ namespace Microsoft::Console::Render [[nodiscard]] HRESULT GetFontSize(_Out_ COORD* const pFontSize) noexcept override; [[nodiscard]] HRESULT IsGlyphWideByFont(const std::wstring_view glyph, _Out_ bool* const pResult) noexcept override; + void CursorPositionChanged() noexcept; protected: [[nodiscard]] HRESULT _DoUpdateTitle(const std::wstring& newTitle) noexcept override; From 8d869976cf3491cf265fa1ce76bda38124ba1664 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 31 Mar 2020 11:00:30 -0700 Subject: [PATCH 2/6] Revert "Reduce CursorChanged Events for Accessibility" This reverts commit 8403a766d7d1ff3874c55a85500fbfa4d53e23fd. --- src/cascadia/TerminalControl/TermControl.cpp | 5 ----- src/renderer/uia/UiaRenderer.cpp | 6 +----- src/renderer/uia/UiaRenderer.hpp | 1 - 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 383498b8e08..7d5d0d76ee6 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1817,11 +1817,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation if (!_closing.load()) { TSFInputControl().TryRedrawCanvas(); - - if (_uiaEngine.get()) - { - _uiaEngine->CursorPositionChanged(); - } } } } diff --git a/src/renderer/uia/UiaRenderer.cpp b/src/renderer/uia/UiaRenderer.cpp index 8982dba01c6..68c03b7077e 100644 --- a/src/renderer/uia/UiaRenderer.cpp +++ b/src/renderer/uia/UiaRenderer.cpp @@ -71,6 +71,7 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) : // - S_FALSE [[nodiscard]] HRESULT UiaEngine::InvalidateCursor(const COORD* const /*pcoordCursor*/) noexcept { + _cursorChanged = true; return S_FALSE; } @@ -453,11 +454,6 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) : return S_FALSE; } -void UiaEngine::CursorPositionChanged() noexcept -{ - _cursorChanged = true; -} - // Method Description: // - Updates the window's title string. // - Currently unused by this renderer. diff --git a/src/renderer/uia/UiaRenderer.hpp b/src/renderer/uia/UiaRenderer.hpp index 8f91e7ffe2e..3f7ced8e33f 100644 --- a/src/renderer/uia/UiaRenderer.hpp +++ b/src/renderer/uia/UiaRenderer.hpp @@ -75,7 +75,6 @@ namespace Microsoft::Console::Render [[nodiscard]] HRESULT GetFontSize(_Out_ COORD* const pFontSize) noexcept override; [[nodiscard]] HRESULT IsGlyphWideByFont(const std::wstring_view glyph, _Out_ bool* const pResult) noexcept override; - void CursorPositionChanged() noexcept; protected: [[nodiscard]] HRESULT _DoUpdateTitle(const std::wstring& newTitle) noexcept override; From 5eb9f9a594b29f99be50f53fdfc4984e4d51bc3b Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 31 Mar 2020 11:39:35 -0700 Subject: [PATCH 3/6] suppress uia cursor changed events in uiarenderer --- src/renderer/uia/UiaRenderer.cpp | 10 +++++++--- src/renderer/uia/UiaRenderer.hpp | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/renderer/uia/UiaRenderer.cpp b/src/renderer/uia/UiaRenderer.cpp index 68c03b7077e..089aacb22c1 100644 --- a/src/renderer/uia/UiaRenderer.cpp +++ b/src/renderer/uia/UiaRenderer.cpp @@ -69,9 +69,14 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) : // - pcoordCursor - the new position of the cursor // Return Value: // - S_FALSE -[[nodiscard]] HRESULT UiaEngine::InvalidateCursor(const COORD* const /*pcoordCursor*/) noexcept +[[nodiscard]] HRESULT UiaEngine::InvalidateCursor(const COORD* const pcoordCursor) noexcept { - _cursorChanged = true; + // check if cursor moved + if (*pcoordCursor != _prevCursorPos) + { + _prevCursorPos = *pcoordCursor; + _cursorChanged = true; + } return S_FALSE; } @@ -246,7 +251,6 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) : _selectionChanged = false; _textBufferChanged = false; _cursorChanged = false; - _prevSelection.clear(); _isPainting = false; return S_OK; diff --git a/src/renderer/uia/UiaRenderer.hpp b/src/renderer/uia/UiaRenderer.hpp index 3f7ced8e33f..f4a011a5285 100644 --- a/src/renderer/uia/UiaRenderer.hpp +++ b/src/renderer/uia/UiaRenderer.hpp @@ -88,5 +88,6 @@ namespace Microsoft::Console::Render Microsoft::Console::Types::IUiaEventDispatcher* _dispatcher; std::vector _prevSelection; + til::point _prevCursorPos; }; } From 604420ba40b873ca0ead4e3cd5419f56dc8be930 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 31 Mar 2020 11:47:37 -0700 Subject: [PATCH 4/6] idk why this was ever S_FALSE --- src/renderer/uia/UiaRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/uia/UiaRenderer.cpp b/src/renderer/uia/UiaRenderer.cpp index 089aacb22c1..8dffab49597 100644 --- a/src/renderer/uia/UiaRenderer.cpp +++ b/src/renderer/uia/UiaRenderer.cpp @@ -77,7 +77,7 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) : _prevCursorPos = *pcoordCursor; _cursorChanged = true; } - return S_FALSE; + return S_OK; } // Routine Description: From 1abd85c788170a9b1e1e486c5afe953ab243b47b Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 31 Mar 2020 11:49:04 -0700 Subject: [PATCH 5/6] fix comment --- src/renderer/uia/UiaRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/uia/UiaRenderer.cpp b/src/renderer/uia/UiaRenderer.cpp index 8dffab49597..3d34b995486 100644 --- a/src/renderer/uia/UiaRenderer.cpp +++ b/src/renderer/uia/UiaRenderer.cpp @@ -68,7 +68,7 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) : // Arguments: // - pcoordCursor - the new position of the cursor // Return Value: -// - S_FALSE +// - S_OK [[nodiscard]] HRESULT UiaEngine::InvalidateCursor(const COORD* const pcoordCursor) noexcept { // check if cursor moved From 3426a7b8c32b03e00b3e92374fa135be30b44629 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 31 Mar 2020 13:37:03 -0700 Subject: [PATCH 6/6] fix SA --- src/renderer/uia/UiaRenderer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/renderer/uia/UiaRenderer.cpp b/src/renderer/uia/UiaRenderer.cpp index 3d34b995486..8aabf3df7ae 100644 --- a/src/renderer/uia/UiaRenderer.cpp +++ b/src/renderer/uia/UiaRenderer.cpp @@ -70,7 +70,10 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) : // Return Value: // - S_OK [[nodiscard]] HRESULT UiaEngine::InvalidateCursor(const COORD* const pcoordCursor) noexcept +try { + RETURN_HR_IF_NULL(E_INVALIDARG, pcoordCursor); + // check if cursor moved if (*pcoordCursor != _prevCursorPos) { @@ -79,6 +82,7 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) : } return S_OK; } +CATCH_RETURN(); // Routine Description: // - Invalidates a rectangle describing a pixel area on the display