Skip to content

Commit f2926f5

Browse files
authored
Merge 7ce1e20 into 0f9c0da
2 parents 0f9c0da + 7ce1e20 commit f2926f5

6 files changed

Lines changed: 84 additions & 21 deletions

File tree

source/UIAHandler/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def MTAThreadFunc(self):
356356
self.rootElement=self.clientObject.getRootElementBuildCache(self.baseCacheRequest)
357357
self.reservedNotSupportedValue=self.clientObject.ReservedNotSupportedValue
358358
self.ReservedMixedAttributeValue=self.clientObject.ReservedMixedAttributeValue
359-
if config.conf['UIA']['selectiveEventRegistration']:
359+
if utils._shouldSelectivelyRegister():
360360
self._createLocalEventHandlerGroup()
361361
self._registerGlobalEventHandlers()
362362
if winVersion.getWinVer() >= winVersion.WIN11:
@@ -388,13 +388,13 @@ def _registerGlobalEventHandlers(self):
388388
self,
389389
*self.clientObject.IntSafeArrayToNativeArray(
390390
globalEventHandlerGroupUIAPropertyIds
391-
if config.conf['UIA']['selectiveEventRegistration']
391+
if utils._shouldSelectivelyRegister()
392392
else UIAPropertyIdsToNVDAEventNames
393393
)
394394
)
395395
for eventId in (
396396
globalEventHandlerGroupUIAEventIds
397-
if config.conf['UIA']['selectiveEventRegistration']
397+
if utils._shouldSelectivelyRegister()
398398
else UIAEventIdsToNVDAEventNames
399399
):
400400
self.globalEventHandlerGroup.AddAutomationEventHandler(

source/UIAHandler/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import ctypes
1010
import UIAHandler
1111
import weakref
12+
import winVersion
1213
from functools import lru_cache
1314
from logHandler import log
1415
from .constants import WinConsoleAPILevel
@@ -350,3 +351,14 @@ def _getConhostAPILevel(hwnd: int) -> WinConsoleAPILevel:
350351
except (COMError, ValueError):
351352
log.exception()
352353
return WinConsoleAPILevel.END_INCLUSIVE
354+
355+
356+
def _shouldSelectivelyRegister() -> bool:
357+
"Determinbes whether to register for UIA events selectively or globally."
358+
setting = config.conf['UIA']['eventRegistration']
359+
if setting == "selective":
360+
return True
361+
elif setting == "global":
362+
return False
363+
else:
364+
return winVersion.getWinVer() >= winVersion.WIN11

source/config/configSpec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#: provide an upgrade step (@see profileUpgradeSteps.py). An upgrade step does not need to be added when
1313
#: just adding a new element to (or removing from) the schema, only when old versions of the config
1414
#: (conforming to old schema versions) will not work correctly with the new schema.
15-
latestSchemaVersion = 6
15+
latestSchemaVersion = 7
1616

1717
#: The configuration specification string
1818
#: @type: String
@@ -234,7 +234,7 @@
234234
enabled = boolean(default=true)
235235
useInMSExcelWhenAvailable = boolean(default=false)
236236
winConsoleImplementation= option("auto", "legacy", "UIA", default="auto")
237-
selectiveEventRegistration = boolean(default=false)
237+
eventRegistration = option("auto", "selective", "global", default="auto")
238238
# 0:default, 1:Only when necessary, 2:yes, 3:no
239239
allowInChromium = integer(0, 3, default=0)
240240
# 0:default (where suitable), 1:Only when necessary, 2: where suitable, 3: always

source/config/profileUpgradeSteps.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,16 @@ def upgradeConfigFrom_5_to_6(profile: dict):
9999
if useInMSWord:
100100
from . import AllowUiaInMSWord
101101
profile['UIA']['allowInMSWord'] = AllowUiaInMSWord.ALWAYS.value
102+
103+
104+
def upgradeConfigFrom_6_to_7(profile: dict):
105+
"""
106+
Selective UIA registration check box has been replaced with event registration multi choice.
107+
"""
108+
try:
109+
selectiveEventRegistration = profile['UIA']['selectiveEventRegistration']
110+
del profile['UIA']['selectiveEventRegistration']
111+
except KeyError:
112+
selectiveEventRegistration = False
113+
if selectiveEventRegistration:
114+
profile['UIA']['eventRegistration'] = "selective"

source/gui/settingsDialogs.py

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,17 +2654,46 @@ def __init__(self, parent):
26542654
UIAGroup = guiHelper.BoxSizerHelper(self, sizer=UIASizer)
26552655
sHelper.addItem(UIAGroup)
26562656

2657-
# Translators: This is the label for a checkbox in the
2658-
# Advanced settings panel.
2659-
label = _("Enable &selective registration for UI Automation events and property changes")
2660-
self.selectiveUIAEventRegistrationCheckBox = UIAGroup.addItem(wx.CheckBox(UIABox, label=label))
2657+
# Translators: This is the label for a combo box for selecting the
2658+
# means of registering for UI Automation events in the advanced settings panel.
2659+
# Choices are automatic, selectively, and globally.
2660+
selectiveUIAEventRegistrationComboText = _("Regi&stration for UI Automation events and property changes:")
2661+
selectiveUIAEventRegistrationChoices = [
2662+
# Translators: A choice in a combo box in the advanced settings
2663+
# panel to have NVDA decide whether to register
2664+
# selectively or globally for UI Automation events.
2665+
_("Automatic (prefer selectively)"),
2666+
# Translators: A choice in a combo box in the advanced settings
2667+
# panel to have NVDA register selectively for UI Automation events
2668+
# (i.e. not to request events for objects outside immediate focus).
2669+
_("Selectively"),
2670+
# Translators: A choice in a combo box in the advanced settings
2671+
# panel to have NVDA register for all UI Automation events
2672+
# in all cases.
2673+
_("Globally")
2674+
]
2675+
#: The possible event registration config values, in the order they appear
2676+
#: in the combo box.
2677+
self.selectiveUIAEventRegistrationVals = (
2678+
"auto",
2679+
"selective",
2680+
"global"
2681+
)
2682+
self.selectiveUIAEventRegistrationCombo = UIAGroup.addLabeledControl(
2683+
selectiveUIAEventRegistrationComboText,
2684+
wx.Choice,
2685+
choices=selectiveUIAEventRegistrationChoices
2686+
)
26612687
self.bindHelpEvent(
26622688
"AdvancedSettingsSelectiveUIAEventRegistration",
2663-
self.selectiveUIAEventRegistrationCheckBox
2689+
self.selectiveUIAEventRegistrationCombo
2690+
)
2691+
curChoice = self.selectiveUIAEventRegistrationVals.index(
2692+
config.conf['UIA']['eventRegistration']
26642693
)
2665-
self.selectiveUIAEventRegistrationCheckBox.SetValue(config.conf["UIA"]["selectiveEventRegistration"])
2666-
self.selectiveUIAEventRegistrationCheckBox.defaultValue = (
2667-
self._getDefaultValue(["UIA", "selectiveEventRegistration"])
2694+
self.selectiveUIAEventRegistrationCombo.SetSelection(curChoice)
2695+
self.selectiveUIAEventRegistrationCombo.defaultValue = self.selectiveUIAEventRegistrationVals.index(
2696+
self._getDefaultValue(["UIA", "eventRegistration"])
26682697
)
26692698

26702699
label = pgettext(
@@ -3031,8 +3060,8 @@ def haveConfigDefaultsBeenRestored(self):
30313060
self._defaultsRestored
30323061
and self.scratchpadCheckBox.IsChecked() == self.scratchpadCheckBox.defaultValue
30333062
and (
3034-
self.selectiveUIAEventRegistrationCheckBox.IsChecked()
3035-
== self.selectiveUIAEventRegistrationCheckBox.defaultValue
3063+
self.selectiveUIAEventRegistrationCombo.GetSelection()
3064+
== self.selectiveUIAEventRegistrationCombo.defaultValue
30363065
)
30373066
and self.UIAInMSWordCombo.GetSelection() == self.UIAInMSWordCombo.defaultValue
30383067
and self.UIAInMSExcelCheckBox.IsChecked() == self.UIAInMSExcelCheckBox.defaultValue
@@ -3054,7 +3083,9 @@ def haveConfigDefaultsBeenRestored(self):
30543083

30553084
def restoreToDefaults(self):
30563085
self.scratchpadCheckBox.SetValue(self.scratchpadCheckBox.defaultValue)
3057-
self.selectiveUIAEventRegistrationCheckBox.SetValue(self.selectiveUIAEventRegistrationCheckBox.defaultValue)
3086+
self.selectiveUIAEventRegistrationCombo.SetSelection(
3087+
self.selectiveUIAEventRegistrationCombo.defaultValue == 'auto'
3088+
)
30583089
self.UIAInMSWordCombo.SetSelection(self.UIAInMSWordCombo.defaultValue)
30593090
self.UIAInMSExcelCheckBox.SetValue(self.UIAInMSExcelCheckBox.defaultValue)
30603091
self.consoleCombo.SetSelection(self.consoleCombo.defaultValue == 'auto')
@@ -3075,7 +3106,10 @@ def restoreToDefaults(self):
30753106
def onSave(self):
30763107
log.debug("Saving advanced config")
30773108
config.conf["development"]["enableScratchpadDir"]=self.scratchpadCheckBox.IsChecked()
3078-
config.conf["UIA"]["selectiveEventRegistration"] = self.selectiveUIAEventRegistrationCheckBox.IsChecked()
3109+
selectiveUIAEventRegistrationChoice = self.selectiveUIAEventRegistrationCombo.GetSelection()
3110+
config.conf['UIA']['eventRegistration'] = (
3111+
self.selectiveUIAEventRegistrationVals[selectiveUIAEventRegistrationChoice]
3112+
)
30793113
config.conf["UIA"]["allowInMSWord"] = self.UIAInMSWordCombo.GetSelection()
30803114
config.conf["UIA"]["useInMSExcelWhenAvailable"] = self.UIAInMSExcelCheckBox.IsChecked()
30813115
consoleChoice = self.consoleCombo.GetSelection()

user_docs/en/userGuide.t2t

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,12 +1905,16 @@ If you wish to distribute custom code to others, you should package it as an NVD
19051905
This button opens the directory where you can place custom code while developing it.
19061906
This button is only enabled if NVDA is configured to enable loading custom code from the Developer Scratchpad Directory.
19071907

1908-
==== Enable selective registration for UI Automation events and property changes ====[AdvancedSettingsSelectiveUIAEventRegistration]
1908+
==== Registration for UI Automation events and property changes ====[AdvancedSettingsSelectiveUIAEventRegistration]
19091909
This option changes how NVDA registers for events fired by the Microsoft UI Automation accessibility API.
1910-
When this option is disabled, NVDA registers for many UIA events that are processed and discarded within NVDA itself.
1911-
This has a major negative impact on performance, especially in applications like Microsoft Visual Studio.
1912-
Therefore, when this option is enabled, NVDA will limit event registration to the system focus for most events.
1910+
The registration for UI Automation events and property changes combo box has three options:
1911+
- Automatic: "selectively" on Windows 11 and later, "globally" otherwise.
1912+
- Selectively: NVDA will limit event registration to the system focus for most events.
19131913
If you suffer from performance issues in one or more applications, We recommend you to try this functionality to see whether performance improves.
1914+
However, on older versions of Windows, NVDA may have trouble tracking focus in some controls (such as the task manager and emoji panel).
1915+
- Globally: NVDA registers for many UIA events that are processed and discarded within NVDA itself.
1916+
While focus tracking is more reliable in more situations, performance is significantly degraded, especially in applications like Microsoft Visual Studio.
1917+
-
19141918

19151919
==== Use UI automation to access Microsoft Word document controls ====[MSWordUIA]
19161920
Configures whether or not NVDA should use the UI Automation accessibility API to access Microsoft Word documents, rather than the older Microsoft Word object model.

0 commit comments

Comments
 (0)