[orca] Handle issues associated with using Gecko apps with Gtk+ 3



commit c31e95289b673cfea1e838e921a7f562be3bce3d
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Feb 23 05:05:37 2017 -0500

    Handle issues associated with using Gecko apps with Gtk+ 3

 src/orca/script_manager.py                        |    9 +++++++-
 src/orca/script_utilities.py                      |    3 ++
 src/orca/scripts/toolkits/gtk/script.py           |   13 ++++++++++++
 src/orca/scripts/toolkits/gtk/script_utilities.py |   22 +++++++++++++++++++++
 4 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/script_manager.py b/src/orca/script_manager.py
index 27ca455..9d6b6ba 100644
--- a/src/orca/script_manager.py
+++ b/src/orca/script_manager.py
@@ -272,9 +272,16 @@ class ScriptManager:
         if customScript:
             return customScript
 
+        try:
+            role = obj.getRole()
+        except:
+            forceAppScript = False
+        else:
+            forceAppScript = role == pyatspi.ROLE_FRAME
+
         # Only defer to the toolkit script for this object if the app script
         # is based on a different toolkit.
-        if toolkitScript \
+        if toolkitScript and not forceAppScript \
            and not issubclass(appScript.__class__, toolkitScript.__class__):
             return toolkitScript
 
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index cea4db9..1d9fe7d 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -3455,6 +3455,9 @@ class Utilities:
 
         return not state.contains(pyatspi.STATE_MODAL)
 
+    def isUselessPanel(self, obj):
+        return False
+
     def rgbFromString(self, attributeValue):
         regex = re.compile("rgb|[^\w,]", re.IGNORECASE)
         string = re.sub(regex, "", attributeValue)
diff --git a/src/orca/scripts/toolkits/gtk/script.py b/src/orca/scripts/toolkits/gtk/script.py
index 106b7f2..2a94c67 100644
--- a/src/orca/scripts/toolkits/gtk/script.py
+++ b/src/orca/scripts/toolkits/gtk/script.py
@@ -199,6 +199,16 @@ class Script(default.Script):
             orca.setLocusOfFocus(event, obj)
             return
 
+    def onFocusedChanged(self, event):
+        """Callback for object:state-changed:focused accessibility events."""
+
+        if self.utilities.isUselessPanel(event.source):
+            msg = "GTK: Event source believed to be useless panel"
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return
+
+        super().onFocusedChanged(event)
+
     def onSelectedChanged(self, event):
         """Callback for object:state-changed:selected accessibility events."""
 
@@ -270,4 +280,7 @@ class Script(default.Script):
         if self.utilities.eventIsCanvasNoise(event):
             return False
 
+        if self.utilities.isUselessPanel(event.source):
+            return False
+
         return super().isActivatableEvent(event)
diff --git a/src/orca/scripts/toolkits/gtk/script_utilities.py 
b/src/orca/scripts/toolkits/gtk/script_utilities.py
index 930817f..f46653f 100644
--- a/src/orca/scripts/toolkits/gtk/script_utilities.py
+++ b/src/orca/scripts/toolkits/gtk/script_utilities.py
@@ -39,11 +39,13 @@ class Utilities(script_utilities.Utilities):
         self._isComboBoxWithToggleDescendant = {}
         self._isToggleDescendantOfComboBox = {}
         self._isTypeahead = {}
+        self._isUselessPanel = {}
 
     def clearCachedObjects(self):
         self._isComboBoxWithToggleDescendant = {}
         self._isToggleDescendantOfComboBox = {}
         self._isTypeahead = {}
+        self._isUselessPanel = {}
 
     def displayedText(self, obj):
         displayedText = script_utilities.Utilities.displayedText(self, obj)
@@ -160,6 +162,26 @@ class Utilities(script_utilities.Utilities):
 
         return False
 
+    def isUselessPanel(self, obj):
+        if not (obj and obj.getRole() == pyatspi.ROLE_PANEL):
+            return False
+
+        rv = self._isUselessPanel.get(hash(obj))
+        if rv is not None:
+            return rv
+
+        try:
+            name = obj.name
+            childCount = obj.childCount
+            supportsText = "Text" in pyatspi.listInterfaces(obj)
+        except:
+            rv = True
+        else:
+            rv = not (name or childCount or supportsText)
+
+        self._isUselessPanel[hash(obj)] = rv
+        return rv
+
     def rgbFromString(self, attributeValue):
         regex = re.compile("rgb|[^\w,]", re.IGNORECASE)
         string = re.sub(regex, "", attributeValue)


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