[orca] Do not speak caret-moved and state-changed:focused events triggered by SayAll



commit cce8959b0a170e3bb8dcd67486c2e4bc66dfb38e
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sun Jan 18 16:51:14 2015 -0500

    Do not speak caret-moved and state-changed:focused events triggered by SayAll
    
    Depending on the keystrokes, we are in danger of double-presenting text

 src/orca/scripts/apps/soffice/script.py       |    3 +++
 src/orca/scripts/default.py                   |    9 +++++++++
 src/orca/scripts/toolkits/Gecko/script.py     |    6 ++++++
 src/orca/scripts/toolkits/WebKitGtk/script.py |   11 +++++++++++
 4 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index fec14b8..731f4e7 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -842,6 +842,9 @@ class Script(default.Script):
     def onFocusedChanged(self, event):
         """Callback for object:state-changed:focused accessibility events."""
 
+        if self._inSayAll:
+            return
+
         if self.isStructuralNavigationCommand():
             return
 
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 10f1b90..f51d741 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -138,6 +138,8 @@ class Script(script.Script):
         self._lastWord = ""
         self._lastWordCheckedForSpelling = ""
 
+        self._inSayAll = False
+
     def setupInputEventHandlers(self):
         """Defines InputEventHandler fields for this script that can be
         called by the key and braille bindings."""
@@ -2952,6 +2954,8 @@ class Script(script.Script):
         text = obj.queryText()
 
         self.updateBrailleForNewCaretPosition(obj)
+        if self._inSayAll:
+            return
 
         if not orca_state.lastInputEvent:
             return
@@ -3022,6 +3026,7 @@ class Script(script.Script):
         if progressType == speechserver.SayAllContext.PROGRESS:
             return
         elif progressType == speechserver.SayAllContext.INTERRUPTED:
+            self._inSayAll = False
             text.setCaretOffset(context.currentOffset)
         elif progressType == speechserver.SayAllContext.COMPLETED:
             orca.setLocusOfFocus(None, context.obj, notifyScript=False)
@@ -3813,8 +3818,10 @@ class Script(script.Script):
         try:
             text = obj.queryText()
         except:
+            self._inSayAll = False
             return
 
+        self._inSayAll = True
         length = text.characterCount
         if offset == None:
             offset = text.caretOffset
@@ -3903,6 +3910,8 @@ class Script(script.Script):
             if not moreLines:
                 done = True
 
+        self._inSayAll = False
+
     def getTextLineAtCaret(self, obj, offset=None):
         """Gets the line of text where the caret is.
 
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 9055ac6..d78dd12 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -729,6 +729,7 @@ class Script(default.Script):
         else:
             characterOffset = offset
 
+        self._inSayAll = True
         done = False
         while not done:
             if sayAllBySentence:
@@ -762,6 +763,8 @@ class Script(default.Script):
             [obj, characterOffset] = self.findNextCaretInOrder(obj, characterOffset)
             done = (obj == None)
 
+        self._inSayAll = False
+
     def presentFindResults(self, obj, offset):
         """Updates the caret context to the match indicated by obj and
         offset.  Then presents the results according to the user's
@@ -836,6 +839,9 @@ class Script(default.Script):
             default.Script.__sayAllProgressCallback(self, context, progressType)
             return
 
+        if progressType == speechserver.SayAllContext.INTERRUPTED:
+            self._inSayAll = False
+
         orca.setLocusOfFocus(None, context.obj, notifyScript=False)
         self.setCaretContext(context.obj, context.currentOffset)
 
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
index 99c7f4e..31df702 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -186,6 +186,9 @@ class Script(default.Script):
         - event: the Event
         """
 
+        if self._inSayAll:
+            return
+
         self._lastCaretContext = event.source, event.detail1
 
         lastKey, mods = self.utilities.lastKeyAndModifiers()
@@ -242,6 +245,9 @@ class Script(default.Script):
     def onFocusedChanged(self, event):
         """Callback for object:state-changed:focused accessibility events."""
 
+        if self._inSayAll:
+            return
+
         obj = event.source
         role = obj.getRole()
         self._lastCaretContext = obj, -1
@@ -560,6 +566,7 @@ class Script(default.Script):
         spoken and acss is an ACSS instance for speaking the text.
         """
 
+        self._inSayAll = False
         if not obj:
             return
 
@@ -583,6 +590,7 @@ class Script(default.Script):
         if sayAllStyle == settings.SAYALL_STYLE_SENTENCE:
             boundary = pyatspi.TEXT_BOUNDARY_SENTENCE_START
 
+        self._inSayAll = True
         offset = textObjs[0].queryText().caretOffset
         for textObj in textObjs:
             textSegments = self.getTextSegments(textObj, boundary, offset)
@@ -597,6 +605,8 @@ class Script(default.Script):
 
             offset = 0
 
+        self._inSayAll = False
+
     def __sayAllProgressCallback(self, context, progressType):
         if progressType == speechserver.SayAllContext.PROGRESS:
             return
@@ -608,6 +618,7 @@ class Script(default.Script):
         text = obj.queryText()
 
         if progressType == speechserver.SayAllContext.INTERRUPTED:
+            self._inSayAll = False
             text.setCaretOffset(offset)
             return
 


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