[orca] Chromium: Attempt to identify and work around possible missing window events



commit f0d57910f531995b3cf9c204e7e7bad33e7bb484
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Mar 18 13:34:19 2020 -0400

    Chromium: Attempt to identify and work around possible missing window events
    
    * Add more debugging output.
    * For each window which claims to not be active, showing, and not
      iconified, clear AT-SPI2's cache on that window and try again.

 src/orca/script_utilities.py                       | 11 ++++++++++-
 .../scripts/toolkits/Chromium/script_utilities.py  | 22 ++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index b4f5d3bd3..d51fb4e3d 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -117,12 +117,21 @@ class Utilities:
             return False
 
         if not state.contains(pyatspi.STATE_ACTIVE):
+            msg = "INFO: %s lacks state active" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
             return False
 
         if state.contains(pyatspi.STATE_ICONIFIED):
+            msg = "INFO: %s has state iconified" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
+
+        if not state.contains(pyatspi.STATE_SHOWING):
+            msg = "INFO: %s lacks state showing" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
             return False
 
-        return state.contains(pyatspi.STATE_SHOWING)
+        return True
 
     @staticmethod
     def _getAppCommandLine(app):
diff --git a/src/orca/scripts/toolkits/Chromium/script_utilities.py 
b/src/orca/scripts/toolkits/Chromium/script_utilities.py
index a7f4ec557..380c279d3 100644
--- a/src/orca/scripts/toolkits/Chromium/script_utilities.py
+++ b/src/orca/scripts/toolkits/Chromium/script_utilities.py
@@ -522,3 +522,25 @@ class Utilities(web.Utilities):
             return result.parent
 
         return result
+
+    def _isActiveAndShowingAndNotIconified(self, obj):
+        if super()._isActiveAndShowingAndNotIconified(obj):
+            return True
+
+        # FIXME: This can potentially be non-performant because AT-SPI2 will recursively
+        # clear the cache of all descendants. This is an attempt to work around what may
+        # be a lack of window:activate and object:state-changed events from Chromium
+        # windows in at least some environments.
+        try:
+            obj.clearCache()
+        except:
+            msg = "CHROMIUM: Exception clearing cache for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
+
+        if super()._isActiveAndShowingAndNotIconified(obj):
+            msg = "CHROMIUM: %s deemed to be active and showing after cache clear" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return True
+
+        return False


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