[orca/gnome-2-30] Fix for bgo#619101 - Duplicate caret-moved events in OOo Writer are causing Orca to double-speak lin



commit 4cfad29d870b5693943e0147609be6d4edc058aa
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Thu May 20 13:46:42 2010 +0000

    Fix for bgo#619101 - Duplicate caret-moved events in OOo Writer are causing Orca to double-speak lines of text

 src/orca/scripts/apps/soffice/script.py |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index ece6ac2..fc4bf9d 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -472,6 +472,27 @@ class Script(default.Script):
         except:
             debug.printException(debug.LEVEL_WARNING)
 
+    def isDuplicateEvent(self, event):
+        """Returns True if we believe this event is a duplicate which we
+        wish to ignore."""
+
+        if not event:
+            return False
+
+        if event.type.startswith("object:text-caret-moved"):
+            try:
+                obj, offset = self.pointOfReference["lastCursorPosition"]
+            except:
+                return False
+            else:
+                # Doing an intentional equality check rather than calling
+                # isSameObject() because we'd rather double-present an
+                # object than not present it at all.
+                #
+                return obj == event.source and offset == event.detail1
+
+        return False
+
     def isStructuralNavigationCommand(self, inputEvent=None):
         """Checks to see if the inputEvent was a structural navigation
         command. This is necessary to prevent double-presentation of
@@ -2201,6 +2222,9 @@ class Script(default.Script):
         if self.isStructuralNavigationCommand():
             return
 
+        if self.isDuplicateEvent(event):
+            return
+
         # If we are losing focus and we in:
         # 1/ a paragraph in an ooimpress slide presentation
         # 2/ a paragraph in an oowriter text document



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