Skip to content

Commit b9ff2fd

Browse files
authored
Merge 09d6cc3 into b718782
2 parents b718782 + 09d6cc3 commit b9ff2fd

4 files changed

Lines changed: 47 additions & 14 deletions

File tree

source/braille.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,8 +2599,7 @@ def _getTryPorts(
25992599
yield match
26002600

26012601
#: Global input gesture map for this display driver.
2602-
#: @type: L{inputCore.GlobalGestureMap}
2603-
gestureMap = None
2602+
gestureMap: Optional[inputCore.GlobalGestureMap] = None
26042603

26052604
@classmethod
26062605
def _getModifierGestures(cls, model=None):

source/inputCore.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@
1313
import os
1414
import weakref
1515
import time
16-
from typing import Dict, Any, Tuple, List, Union
16+
from typing import (
17+
Any,
18+
Dict,
19+
Generator,
20+
List,
21+
Optional,
22+
Tuple,
23+
TypeVar,
24+
Union,
25+
)
1726
from gui import blockAction
1827
import configobj
1928
from speech import sayAll
@@ -32,6 +41,16 @@
3241
import controlTypes
3342
import winKernel
3443

44+
45+
InputGestureBindingClassT = TypeVar("InputGestureBindingClassT")
46+
ScriptNameT = str
47+
InputGestureScriptT = Tuple[InputGestureBindingClassT, Optional[ScriptNameT]]
48+
"""
49+
The Python class and script name for each script;
50+
the script name may be C{None} indicating that the gesture should be unbound for this class.
51+
"""
52+
53+
3554
#: Script category for emulated keyboard keys.
3655
# Translators: The name of a category of NVDA commands.
3756
SCRCAT_KBEMU = _("Emulated system keyboard keys")
@@ -321,13 +340,11 @@ def update(self, entries):
321340
self.lastUpdateContainedError = True
322341
continue
323342

324-
def getScriptsForGesture(self, gesture):
343+
def getScriptsForGesture(self, gesture: str) -> Generator[InputGestureScriptT, None, None]:
325344
"""Get the scripts associated with a particular gesture.
326345
@param gesture: The gesture identifier.
327-
@type gesture: str
328346
@return: The Python class and script name for each script;
329347
the script name may be C{None} indicating that the gesture should be unbound for this class.
330-
@rtype: generator of (class, str)
331348
"""
332349
try:
333350
scripts = self._map[gesture]
@@ -845,9 +862,10 @@ def getDisplayTextForGestureIdentifier(identifier):
845862
raise
846863
raise LookupError("Couldn't get display text for identifier: %s" % identifier)
847864

865+
848866
#: The singleton input manager instance.
849-
#: @type: L{InputManager}
850-
manager = None
867+
manager: Optional[InputManager] = None
868+
851869

852870
def initialize():
853871
"""Initializes input core, creating a global L{InputManager} singleton.

source/scriptHandler.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2007-2022 NV Access Limited, Babbage B.V., Julien Cochuyt
2+
# Copyright (C) 2007-2022 NV Access Limited, Babbage B.V., Julien Cochuyt, Leonard de Ruijter
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
55

@@ -8,7 +8,6 @@
88
Optional,
99
Iterator,
1010
List,
11-
Set,
1211
)
1312
import time
1413
import weakref
@@ -49,8 +48,13 @@ def _makeKbEmulateScript(scriptName):
4948
def _getObjScript(
5049
obj: "NVDAObjects.NVDAObject",
5150
gesture: "inputCore.InputGesture",
52-
globalMapScripts: Set[_ScriptFunctionT],
51+
globalMapScripts: List[inputCore.InputGestureScriptT],
5352
) -> Optional[_ScriptFunctionT]:
53+
"""
54+
@param globalMapScripts: An ordered list of scripts.
55+
The list is ordered by resolution priority,
56+
the first map in the list should be used to resolve the script first.
57+
"""
5458
# Search the scripts from the global gesture maps.
5559
for cls, scriptName in globalMapScripts:
5660
if isinstance(obj, cls):
@@ -72,15 +76,20 @@ def _getObjScript(
7276
log.exception()
7377

7478

75-
def getGlobalMapScripts(gesture: "inputCore.InputGesture") -> Set[_ScriptFunctionT]:
76-
globalMapScripts: Set[_ScriptFunctionT] = set()
79+
def getGlobalMapScripts(gesture: "inputCore.InputGesture") -> List[inputCore.InputGestureScriptT]:
80+
"""
81+
@returns: An ordered list of scripts.
82+
The list is ordered by resolution priority,
83+
the first map in the list should be used to resolve scripts first.
84+
"""
85+
globalMapScripts: List[inputCore.InputGestureScriptT] = []
7786
globalMaps = [inputCore.manager.userGestureMap, inputCore.manager.localeGestureMap]
7887
globalMap = braille.handler.display.gestureMap if braille.handler and braille.handler.display else None
7988
if globalMap:
8089
globalMaps.append(globalMap)
8190
for globalMap in globalMaps:
8291
for identifier in gesture.normalizedIdentifiers:
83-
globalMapScripts.update(globalMap.getScriptsForGesture(identifier))
92+
globalMapScripts.extend(globalMap.getScriptsForGesture(identifier))
8493
return globalMapScripts
8594

8695

user_docs/en/changes.t2t

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ What's New in NVDA
33

44
%!includeconf: ../changes.t2tconf
55

6+
= 2022.2.2 =
7+
This is a patch release to fix a bug introduced in 2022.2.1 with input gestures.
8+
9+
== Bug Fixes ==
10+
- Fixed a bug where input gestures didn't always work. (#14065)
11+
-
12+
613
= 2022.2.1 =
714
This is a minor release to fix a security issue.
815
Please responsibly disclose security issues to info@nvaccess.org.

0 commit comments

Comments
 (0)