[orca] Eliminate some text-selection chattiness



commit ecc0010999d5bc76258649f2cbfc914b2885c364
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Mar 18 09:48:29 2014 -0400

    Eliminate some text-selection chattiness

 src/orca/scripts/apps/soffice/script.py           |    6 ++++++
 src/orca/scripts/apps/soffice/script_utilities.py |   20 ++++++++++++++++++++
 src/orca/scripts/default.py                       |    5 ++++-
 3 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 2929b75..98dae93 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -956,6 +956,9 @@ class Script(default.Script):
         if start != end:
             return
 
+        if self.utilities._flowsFromOrToSelection(event.source):
+            return
+
         # We should present this in response to active-descendant-changed events
         if event.source.getState().contains(pyatspi.STATE_MANAGES_DESCENDANTS):
             return
@@ -1001,6 +1004,9 @@ class Script(default.Script):
                [pyatspi.ROLE_FRAME]):
             orca.setLocusOfFocus(event, event.source, False)
 
+        if self.utilities._flowsFromOrToSelection(event.source):
+            return
+
         default.Script.onCaretMoved(self, event)
 
     def onCheckedChanged(self, event):
diff --git a/src/orca/scripts/apps/soffice/script_utilities.py 
b/src/orca/scripts/apps/soffice/script_utilities.py
index 4f65614..8f7b81f 100644
--- a/src/orca/scripts/apps/soffice/script_utilities.py
+++ b/src/orca/scripts/apps/soffice/script_utilities.py
@@ -474,6 +474,26 @@ class Utilities(script_utilities.Utilities):
 
         return nextObj
 
+    @staticmethod
+    def _flowsFromOrToSelection(obj):
+        try:
+            relationSet = obj.getRelationSet()
+        except:
+            return False
+
+        flows = [pyatspi.RELATION_FLOWS_FROM, pyatspi.RELATION_FLOWS_TO]
+        relations = filter(lambda r: r.getRelationType() in flows, relationSet)
+        targets = [r.getTarget(0) for r in relations]
+        for target in targets:
+            try:
+                nSelections = target.queryText().getNSelections()
+            except:
+                return False
+            if nSelections:
+                return True
+
+        return False
+
     #########################################################################
     #                                                                       #
     # Impress-Specific Utilities                                            #
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 24f16bc..4591d79 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -2194,7 +2194,10 @@ class Script(script.Script):
 
         text = event.source.queryText()
         self._saveLastCursorPosition(event.source, text.caretOffset)
-        if text.getNSelections():
+
+        textSelections = self.pointOfReference.get('textSelections', {})
+        start, end = textSelections.get(hash(event.source), (0, 0))
+        if text.getNSelections() or start != end:
             return
 
         self._presentTextAtNewCaretPosition(event)


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