Skip to content

Commit 24e605b

Browse files
authored
UI Automation in Windows Console and Windows Terminal: block SV2M2 notification events for now and preserve accessibility after UIA class name change (#13261)
Link to issue number: Related to microsoft/terminal#12358 among others (to be released). Summary of the issue: In upcoming Windows Terminal and Windows Console, UIA notification events will be sent when new text is inserted (i.e. for text output) to improve Narrator support. This will result in double-reporting of all terminal output: once from LiveText and once from UIA notifications (but without appropriate filtering for typed characters/passwords etc). As part of the implementation of notifications, I asked Microsoft to change the UIA class name to allow new terminal support (including notifications) in a follow-up NVDA PR, since notifications will require a departure from the terminal strategy used by NVDA in the past. Changing the class name will break NVDA's current ability to identify the terminal and implement accessibility. Description of how this pull request fixes the issue: Suppress any received UIA notification events in UIA console and terminal for now, but log them for development. Support the new UIA class name used by terminals that send notifications. Ideally, NVDA would use these events in place of LiveText. If we could get away without registering for TextChange at all, this could be an extreme stability improvement in the terminal as #11002 would be completely circumvented. Also, having new text pushed to us (instead of having to diff) should improve performance considerably in high-volume scenarios.
1 parent ca41d22 commit 24e605b

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

‎source/NVDAObjects/UIA/__init__.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,12 @@ def findOverlayClasses(self,clsList):
11561156
if self.windowClassName == "ConsoleWindowClass":
11571157
from . import winConsoleUIA
11581158
winConsoleUIA.findExtraOverlayClasses(self, clsList)
1159-
elif UIAClassName == "TermControl":
1159+
elif UIAClassName in ("TermControl", "TermControl2"):
1160+
# microsoft/terminal#12358: Eventually, TermControl2 should have
1161+
# a separate overlay class that is not a descendant of LiveText.
1162+
# TermControl2 sends inserted text using UIA notification events,
1163+
# so it is no longer necessary to diff the object as with all
1164+
# previous terminal implementations.
11601165
from . import winConsoleUIA
11611166
clsList.append(winConsoleUIA.WinTerminalUIA)
11621167

‎source/NVDAObjects/UIA/winConsoleUIA.py‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,17 @@ def detectPossibleSelectionChange(self):
400400
"probably due to a switch to/from the alt buffer."
401401
), exc_info=True)
402402

403+
def event_UIA_notification(self, **kwargs):
404+
"""
405+
In Windows Sun Valley 2 (SV2 M2), UIA notification events will be sent
406+
to announce new text. Block these for now to avoid double-reporting of
407+
text changes.
408+
@note: In the longer term, NVDA should leverage these events in place
409+
of the current LiveText strategy, as performance will likely be
410+
significantly improved and #11002 can be completely mitigated.
411+
"""
412+
log.debugWarning(f"Notification event blocked to avoid double-report: {kwargs}")
413+
403414

404415
def findExtraOverlayClasses(obj, clsList):
405416
if obj.UIAElement.cachedAutomationId == "Text Area":
@@ -409,4 +420,13 @@ def findExtraOverlayClasses(obj, clsList):
409420

410421

411422
class WinTerminalUIA(EnhancedTermTypedCharSupport):
412-
pass
423+
def event_UIA_notification(self, **kwargs):
424+
"""
425+
In an upcoming terminal release, UIA notification events will be sent
426+
to announce new text. Block these for now to avoid double-reporting of
427+
text changes.
428+
@note: In the longer term, NVDA should leverage these events in place
429+
of the current LiveText strategy, as performance will likely be
430+
significantly improved and #11002 can be completely mitigated.
431+
"""
432+
log.debugWarning(f"Notification event blocked to avoid double-report: {kwargs}")

‎user_docs/en/changes.t2t‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ What's New in NVDA
5959
- Fixed a problem where some Focus Blue Braille displays would stop working after waking the computer from sleep. (#9830)
6060
- 'Baseline' is no longer spuriously reported when the 'report superscript and subscript' option is active. (#11078)
6161
- In Windows 11, NVDA will no longer prevent navigation in emoji panel when selecting emojis. (#13104)
62+
- Prevents a bug causing double-reporting when using Windows Console and Terminal. (#13261)
6263
-
6364

6465
== Changes for Developers ==

0 commit comments

Comments
 (0)