[orca] More work on Calc input line event spam



commit ec2af38954c645cc9a6b3726d19add1565701945
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Feb 18 22:14:55 2016 -0500

    More work on Calc input line event spam

 src/orca/scripts/apps/soffice/script.py           |   21 ++++-----
 src/orca/scripts/apps/soffice/script_utilities.py |   47 +++++++++++++++++++--
 2 files changed, 52 insertions(+), 16 deletions(-)
---
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 43f99c8..6ceefd9 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -736,19 +736,16 @@ class Script(default.Script):
         if not event.detail1:
             return
 
-        parent = event.source.parent
-        inputLine = self.utilities.locateInputLine(orca_state.locusOfFocus)
-        if inputLine:
-            if inputLine == event.source:
-                msg = "SOFFICE: Event ignored: spam from inputLine"
-                debug.println(debug.LEVEL_INFO, msg, True)
-                return
-            if self.utilities.isSameObject(inputLine.parent, parent) \
-               or self.utilities.isSameObject(inputLine.parent, event.source):
-                msg = "SOFFICE: Event ignored: spam from inputLine clone"
-                debug.println(debug.LEVEL_INFO, msg, True)
-                return
+        if self.utilities.isAnInputLine(event.source):
+            msg = "SOFFICE: Event ignored: spam from inputLine"
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return
+        if event.source.childCount and self.utilities.isAnInputLine(event.source[0]):
+            msg = "SOFFICE: Event ignored: spam from inputLine parent"
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return
 
+        parent = event.source.parent
         if parent and parent.getRole() == pyatspi.ROLE_TOOL_BAR:
             default.Script.onFocusedChanged(self, event)
             return
diff --git a/src/orca/scripts/apps/soffice/script_utilities.py 
b/src/orca/scripts/apps/soffice/script_utilities.py
index 7b96a90..238c42d 100644
--- a/src/orca/scripts/apps/soffice/script_utilities.py
+++ b/src/orca/scripts/apps/soffice/script_utilities.py
@@ -106,9 +106,15 @@ class Utilities(script_utilities.Utilities):
             return False
 
         parent = obj.parent
-        if parent and parent.getRoleName() == 'text frame':
-            if self.spreadSheetCellName(parent):
-                return True
+        try:
+            role = parent.getRole()
+        except:
+            msg = "SOFFICE: Exception getting role of %s" % parent
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
+
+        if role in [pyatspi.ROLE_EXTENDED, pyatspi.ROLE_PANEL]:
+            return self.spreadSheetCellName(parent)
 
         return False
 
@@ -297,6 +303,37 @@ class Utilities(script_utilities.Utilities):
 
         return script_utilities.Utilities.isLayoutOnly(self, obj)
 
+    def isAnInputLine(self, obj):
+        if not obj:
+            return False
+        if obj == self.locateInputLine(obj):
+            return True
+
+        parent = obj.parent
+        try:
+            role = parent.getRole()
+        except:
+            msg = "SOFFICE: Exception getting role of %s" % parent
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
+
+        if role in [pyatspi.ROLE_EXTENDED, pyatspi.ROLE_PANEL]:
+            if self.spreadSheetCellName(parent):
+                return False
+
+        parent = parent.parent
+        try:
+            role = parent.getRole()
+        except:
+            msg = "SOFFICE: Exception getting role of %s" % parent
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
+
+        if role == pyatspi.ROLE_TEXT:
+            return True
+
+        return False
+
     def locateInputLine(self, obj):
         """Return the spread sheet input line. This only needs to be found
         the very first time a spread sheet table cell gets focus. We use the
@@ -312,7 +349,9 @@ class Utilities(script_utilities.Utilities):
         """
 
         if self._script.inputLineForCell:
-            return self._script.inputLineForCell
+            topLevel = self.topLevelObject(self._script.inputLineForCell)
+            if self.isSameObject(orca_state.activeWindow, topLevel):
+                return self._script.inputLineForCell
 
         isScrollPane = lambda x: x and x.getRole() == pyatspi.ROLE_SCROLL_PANE
         scrollPane = pyatspi.findAncestor(obj, isScrollPane)


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