[orca] Move lastKeyEchoTime to speechdispatcherfactory.py



commit bc8a689db42bb8ed8b46cad29effc514ca8258d5
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Mar 2 14:51:23 2015 -0500

    Move lastKeyEchoTime to speechdispatcherfactory.py
    
    Ultimately it should probably just be deleted as it appears it hasn't been
    used in years. But regardless, it should not be an orca-wide value checked
    and set by things other than the speech server.

 src/orca/orca_state.py              |    4 ----
 src/orca/scripts/default.py         |    1 -
 src/orca/speech.py                  |    6 ------
 src/orca/speechdispatcherfactory.py |   11 +++++++++++
 4 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/src/orca/orca_state.py b/src/orca/orca_state.py
index 42b5d9d..df9dcdd 100644
--- a/src/orca/orca_state.py
+++ b/src/orca/orca_state.py
@@ -67,10 +67,6 @@ lastInputEvent = None
 #
 bypassNextCommand = False
 
-# Records the last time a key was echoed.
-#
-lastKeyEchoTime = None
-
 # The last searchQuery
 #
 searchQuery = None
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 1919cec..ff627a7 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -4243,7 +4243,6 @@ class Script(script.Script):
         elif not event.isPressedKey():
             return False
 
-        orca_state.lastKeyEchoTime = time.time()
         debug.println(debug.LEVEL_FINEST,
                       "Script.presentKeyboardEvent: %s" % event.event_string)
 
diff --git a/src/orca/speech.py b/src/orca/speech.py
index f8ad088..cbf76be 100644
--- a/src/orca/speech.py
+++ b/src/orca/speech.py
@@ -180,12 +180,6 @@ def speak(content, acss=None, interrupt=True):
         debug.println(debug.LEVEL_WARNING, error % content)
         return
 
-    # We will not interrupt a key echo in progress.
-    #
-    if orca_state.lastKeyEchoTime:
-        interrupt = interrupt \
-            and ((time.time() - orca_state.lastKeyEchoTime) > 0.5)
-
     if isinstance(content, str):
         _speak(content, acss, interrupt)
     elif isinstance(content, sound.Sound):
diff --git a/src/orca/speechdispatcherfactory.py b/src/orca/speechdispatcherfactory.py
index 786dd02..f61544b 100644
--- a/src/orca/speechdispatcherfactory.py
+++ b/src/orca/speechdispatcherfactory.py
@@ -37,6 +37,7 @@ __license__   = "LGPL"
 
 from gi.repository import GLib
 import re
+import time
 
 from . import chnames
 from . import debug
@@ -160,6 +161,8 @@ class SpeechServer(speechserver.SpeechServer):
         else:
             SpeechServer._active_servers[serverId] = self
 
+        self._lastKeyEchoTime = None
+
     def _init(self):
         self._client = client = speechd.SSIPClient('Orca', component=self._id)
         client.set_priority(speechd.Priority.MESSAGE)
@@ -401,6 +404,13 @@ class SpeechServer(speechserver.SpeechServer):
         #if interrupt:
         #    self._cancel()
 
+        # "We will not interrupt a key echo in progress." (Said the comment in
+        # speech.py where these next two lines used to live. But the code here
+        # suggests we haven't been doing anything with the lastKeyEchoTime in
+        # years. TODO - JD: Dig into this and if it's truly useless, kill it.)
+        if self._lastKeyEchoTime:
+            interrupt = interrupt and (time.time() - self._lastKeyEchoTime) > 0.5
+
         if text:
             self._speak(text, acss)
 
@@ -444,6 +454,7 @@ class SpeechServer(speechserver.SpeechServer):
         lockingStateString = event.getLockingStateString()
         event_string = "%s %s" % (event_string, lockingStateString)
         self.speak(event_string, acss=acss)
+        self._lastKeyEchoTime = time.time()
 
     def increaseSpeechRate(self, step=5):
         self._change_default_speech_rate(step)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]