Skip to content

Commit dbe41ff

Browse files
committed
monkeypatch: inputCore.InputManager.executeGesture -> inputCore.decide_executeGesture
See <nvaccess/nvda#14503>, <LeonarddeR/rdAccess#14>
1 parent ed8d04a commit dbe41ff

1 file changed

Lines changed: 32 additions & 81 deletions

File tree

addon/globalPlugins/brailleExtender/patches.py

Lines changed: 32 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -883,89 +883,41 @@ def previousLine(self, start=False):
883883

884884

885885
# inputCore.InputManager.executeGesture
886-
def executeGesture(self, gesture):
887-
"""Perform the action associated with a gesture.
888-
@param gesture: The gesture to execute.
889-
@type gesture: L{InputGesture}
890-
@raise NoInputGestureAction: If there is no action to perform.
891-
"""
892-
if watchdog.isAttemptingRecovery:
893-
# The core is dead, so don't try to perform an action.
894-
# This lets gestures pass through unhindered where possible,
895-
# as well as stopping a flood of actions when the core revives.
896-
raise NoInputGestureAction
897-
898-
script = gesture.script
899-
if "brailleDisplayDrivers" in str(type(gesture)):
900-
if instanceGP.brailleKeyboardLocked and ((hasattr(script, "__func__") and script.__func__.__name__ != "script_toggleLockBrailleKeyboard") or not hasattr(script, "__func__")): return
901-
if not config.conf["brailleExtender"]['stopSpeechUnknown'] and gesture.script == None: stopSpeech = False
902-
elif hasattr(script, "__func__") and (script.__func__.__name__ in [
903-
"script_braille_dots", "script_braille_enter",
904-
"script_volumePlus", "script_volumeMinus", "script_toggleVolume",
905-
"script_hourDate",
906-
"script_ctrl", "script_alt", "script_nvda", "script_win",
907-
"script_ctrlAlt", "script_ctrlAltWin", "script_ctrlAltWinShift", "script_ctrlAltShift","script_ctrlWin","script_ctrlWinShift","script_ctrlShift","script_altWin","script_altWinShift","script_altShift","script_winShift"]
908-
or (
909-
not config.conf["brailleExtender"]['stopSpeechScroll'] and
910-
script.__func__.__name__ in ["script_braille_scrollBack","script_braille_scrollForward"])):
911-
stopSpeech = False
912-
else: stopSpeech = True
913-
else: stopSpeech = True
914-
915-
focus = api.getFocusObject()
916-
if focus.sleepMode is focus.SLEEP_FULL or (focus.sleepMode and not getattr(script, 'allowInSleepMode', False)):
917-
raise NoInputGestureAction
918-
919-
wasInSayAll=False
920-
if gesture.isModifier:
921-
if not self.lastModifierWasInSayAll:
922-
wasInSayAll=self.lastModifierWasInSayAll=sayAllHandler.isRunning()
923-
elif self.lastModifierWasInSayAll:
924-
wasInSayAll=True
925-
self.lastModifierWasInSayAll=False
926-
else:
927-
wasInSayAll=sayAllHandler.isRunning()
928-
if wasInSayAll:
929-
gesture.wasInSayAll=True
930-
931-
speechEffect = gesture.speechEffectWhenExecuted
932-
if not stopSpeech: pass
933-
elif speechEffect == gesture.SPEECHEFFECT_CANCEL:
934-
queueHandler.queueFunction(queueHandler.eventQueue, speech.cancelSpeech)
935-
elif speechEffect in (gesture.SPEECHEFFECT_PAUSE, gesture.SPEECHEFFECT_RESUME):
936-
queueHandler.queueFunction(queueHandler.eventQueue, speech.pauseSpeech, speechEffect == gesture.SPEECHEFFECT_PAUSE)
937-
938-
if log.isEnabledFor(log.IO) and not gesture.isModifier:
939-
self._lastInputTime = time.time()
940-
log.io("Input: %s" % gesture.identifiers[0])
941-
942-
if self._captureFunc:
943-
try:
944-
if self._captureFunc(gesture) is False:
945-
return
946-
except BaseException:
947-
log.error("Error in capture function, disabling", exc_info=True)
948-
self._captureFunc = None
949-
950-
if gesture.isModifier:
951-
raise NoInputGestureAction
952-
953-
if config.conf["keyboard"]["speakCommandKeys"] and gesture.shouldReportAsCommand:
954-
queueHandler.queueFunction(queueHandler.eventQueue, speech.speakMessage, gesture.displayName)
955-
956-
gesture.reportExtra()
957-
958-
# #2953: if an intercepted command Script (script that sends a gesture) is queued
959-
# then queue all following gestures (that don't have a script) with a fake script so that they remain in order.
960-
if not script and scriptHandler._numIncompleteInterceptedCommandScripts:
961-
script=lambda gesture: gesture.send()
886+
def executeGesture(gesture):
887+
script = gesture.script
888+
if "brailleDisplayDrivers" in str(type(gesture)):
889+
if (
890+
instanceGP.brailleKeyboardLocked
891+
and (
892+
(
893+
hasattr(script, "__func__")
894+
and script.__func__.__name__ != "script_toggleLockBrailleKeyboard"
895+
)
896+
or not hasattr(script, "__func__")
897+
)
898+
):
899+
return
900+
if (
901+
hasattr(script, "__func__")
902+
and (
903+
script.__func__.__name__ in [
904+
"script_braille_dots", "script_braille_enter",
905+
"script_volumePlus", "script_volumeMinus", "script_toggleVolume",
906+
"script_hourDate",
907+
"script_ctrl", "script_alt", "script_nvda", "script_win",
908+
"script_ctrlAlt", "script_ctrlAltWin", "script_ctrlAltWinShift", "script_ctrlAltShift","script_ctrlWin","script_ctrlWinShift","script_ctrlShift","script_altWin","script_altWinShift","script_altShift","script_winShift"
909+
] or (
910+
not config.conf["brailleExtender"]['stopSpeechScroll']
911+
and script.__func__.__name__ in ["script_braille_scrollBack", "script_braille_scrollForward"]
912+
)
913+
)
914+
):
915+
gesture.speechEffectWhenExecuted = None
916+
return True
962917

918+
inputCore.decide_executeGesture.register(executeGesture)
963919

964-
if script:
965-
scriptHandler.queueScript(script, gesture)
966-
return
967920

968-
raise NoInputGestureAction
969921
# brailleInput.BrailleInputHandler.sendChars()
970922
def sendChars(self, chars):
971923
"""Sends the provided unicode characters to the system.
@@ -1234,7 +1186,6 @@ def getTetherWithRoleTerminal(self):
12341186
braille.TextInfoRegion.update = update_TextInfoRegion
12351187
braille.TextInfoRegion.previousLine = previousLine
12361188
braille.TextInfoRegion.nextLine = nextLine
1237-
inputCore.InputManager.executeGesture = executeGesture
12381189
NoInputGestureAction = inputCore.NoInputGestureAction
12391190
brailleInput.BrailleInputHandler._translate = _translate
12401191
brailleInput.BrailleInputHandler.emulateKey = emulateKey

0 commit comments

Comments
 (0)