Skip to content

Commit 5caf543

Browse files
authored
Merge bac8204 into 157ac49
2 parents 157ac49 + bac8204 commit 5caf543

6 files changed

Lines changed: 93 additions & 25 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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,9 @@ def _getConhostAPILevel(hwnd: int) -> WinConsoleAPILevel:
350350
except (COMError, ValueError):
351351
log.exception()
352352
return WinConsoleAPILevel.END_INCLUSIVE
353+
354+
355+
def _shouldSelectivelyRegister() -> bool:
356+
"Determines whether to register for UIA events selectively or globally."
357+
setting = config.conf['UIA']['eventRegistration']
358+
return setting == "selective"

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: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- coding: UTF-8 -*-
2-
#A part of NonVisual Desktop Access (NVDA)
3-
#Copyright (C) 2016 NV Access Limited
4-
#This file is covered by the GNU General Public License.
5-
#See the file COPYING for more details.
2+
# A part of NonVisual Desktop Access (NVDA)
3+
# Copyright (C) 2016–2022 NV Access Limited, Bill Dengler
4+
# This file is covered by the GNU General Public License.
5+
# See the file COPYING for more details.
66

77
"""
88
Contains upgrade steps for the NVDA configuration files. These steps are run to ensure that a configuration file
@@ -15,6 +15,9 @@
1515
"""
1616

1717
from logHandler import log
18+
from typing import (
19+
Dict,
20+
)
1821

1922

2023
def upgradeConfigFrom_0_to_1(profile):
@@ -99,3 +102,18 @@ def upgradeConfigFrom_5_to_6(profile: dict):
99102
if useInMSWord:
100103
from . import AllowUiaInMSWord
101104
profile['UIA']['allowInMSWord'] = AllowUiaInMSWord.ALWAYS.value
105+
106+
107+
def upgradeConfigFrom_6_to_7(profile: Dict[str, str]) -> None:
108+
"""
109+
Selective UIA registration check box has been replaced with event registration multi choice.
110+
If the user has explicitly enabled selective UIA event registration, set the new eventRegistration preference to selective.
111+
Otherwise, the default value, auto, will be used.
112+
"""
113+
try:
114+
selectiveEventRegistration = profile['UIA']['selectiveEventRegistration']
115+
del profile['UIA']['selectiveEventRegistration']
116+
except KeyError:
117+
selectiveEventRegistration = False
118+
if selectiveEventRegistration:
119+
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 (globally)"),
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: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,12 +2113,22 @@ If you wish to distribute custom code to others, you should package it as an NVD
21132113
This button opens the directory where you can place custom code while developing it.
21142114
This button is only enabled if NVDA is configured to enable loading custom code from the Developer Scratchpad Directory.
21152115

2116-
==== Enable selective registration for UI Automation events and property changes ====[AdvancedSettingsSelectiveUIAEventRegistration]
2116+
==== Registration for UI Automation events and property changes ====[AdvancedSettingsSelectiveUIAEventRegistration]
2117+
: Default
2118+
Automatic
2119+
: Options
2120+
Automatic, Selectively, Globally
2121+
:
2122+
21172123
This option changes how NVDA registers for events fired by the Microsoft UI Automation accessibility API.
2118-
When this option is disabled, NVDA registers for many UIA events that are processed and discarded within NVDA itself.
2119-
This has a major negative impact on performance, especially in applications like Microsoft Visual Studio.
2120-
Therefore, when this option is enabled, NVDA will limit event registration to the system focus for most events.
2124+
The registration for UI Automation events and property changes combo box has three options:
2125+
- Automatic: Currently equivalent to "globally".
2126+
- Selectively: NVDA will limit event registration to the system focus for most events.
21212127
If you suffer from performance issues in one or more applications, We recommend you to try this functionality to see whether performance improves.
2128+
However, on older versions of Windows, NVDA may have trouble tracking focus in some controls (such as the task manager and emoji panel).
2129+
- Globally: NVDA registers for many UIA events that are processed and discarded within NVDA itself.
2130+
While focus tracking is more reliable in more situations, performance is significantly degraded, especially in applications like Microsoft Visual Studio.
2131+
-
21222132

21232133
==== Use UI automation to access Microsoft Word document controls ====[MSWordUIA]
21242134
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)