From ebca71200604412d48f04c296ac7380442b7a2f7 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Mon, 22 Jun 2015 14:47:09 +1000 Subject: [PATCH] InputGesture.execute: if an intercepted command script (script that sends the gesture it intercepts) is queued and or has not yet completed its execution, queue any further gestures that do not have a script via a fake script that just sends the gesture. this ensures that input stays in order even if it was delayed by NVDA. --- source/inputCore.py | 6 ++++++ source/scriptHandler.py | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source/inputCore.py b/source/inputCore.py index 5b62510ebc7..ae721318af5 100644 --- a/source/inputCore.py +++ b/source/inputCore.py @@ -434,6 +434,12 @@ def executeGesture(self, gesture): gesture.reportExtra() + # #2953: if an intercepted command Script (script that sends a gesture) is queued + # then queue all following gestures (that don't have a script) with a fake script so that they remain in order. + if not script and scriptHandler._numUncompleteInterceptedCommandScripts: + script=lambda gesture: gesture.send() + + if script: scriptHandler.queueScript(script, gesture) return diff --git a/source/scriptHandler.py b/source/scriptHandler.py index 70070e6984f..83e73d05620 100644 --- a/source/scriptHandler.py +++ b/source/scriptHandler.py @@ -19,6 +19,7 @@ import braille _numScriptsQueued=0 #Number of scripts that are queued to be executed +_numUncompleteInterceptedCommandScripts=0 #Number of scripts (that send gestures on) that are queued to be executed, or are currently being executed _lastScriptTime=0 #Time in MS of when the last script was executed _lastScriptRef=None #Holds a weakref to the last script that was executed _lastScriptCount=0 #The amount of times the last script was repeated @@ -132,14 +133,21 @@ def getScriptLocation(script): if name in cls.__dict__: return "%s.%s"%(cls.__module__,cls.__name__) +def _isInterceptedCommandScript(script): + return not getattr(script,'__doc__',None) + def _queueScriptCallback(script,gesture): - global _numScriptsQueued + global _numScriptsQueued, _numUncompleteInterceptedCommandScripts _numScriptsQueued-=1 executeScript(script,gesture) + if _isInterceptedCommandScript(script): + _numUncompleteInterceptedCommandScripts-=1 def queueScript(script,gesture): - global _numScriptsQueued + global _numScriptsQueued, _numUncompleteInterceptedCommandScripts _numScriptsQueued+=1 + if _isInterceptedCommandScript(script): + _numUncompleteInterceptedCommandScripts+=1 queueHandler.queueFunction(queueHandler.eventQueue,_queueScriptCallback,script,gesture) def willSayAllResume(gesture):