[orca] Ignore certain children-changed:add events



commit 5da47d6421e1d6baa602e04a6f84fcd8fba4a55e
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Jun 3 16:48:31 2015 -0400

    Ignore certain children-changed:add events
    
    * If the child being added is missing
    * If the child being added is defunct
    * If the child being added is an image <cough>matrix.org</cough>

 src/orca/event_manager.py |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/event_manager.py b/src/orca/event_manager.py
index d522c9f..b4996cb 100644
--- a/src/orca/event_manager.py
+++ b/src/orca/event_manager.py
@@ -105,6 +105,33 @@ class EventManager:
            and event.source != self.registry.getDesktop(0):
             return True
 
+        if event.type.startswith('object:children-changed:add'):
+            if not event.any_data:
+                msg = 'ERROR: Children changed add event without child'
+                debug.println(debug.LEVEL_INFO, msg)
+                return True
+            try:
+                state = event.any_data.getState()
+                role = event.any_data.getRole()
+            except:
+                msg = 'ERROR: Children changed add event with potentially-defunct child'
+                debug.println(debug.LEVEL_INFO, msg)
+                return True
+            if state.contains(pyatspi.STATE_DEFUNCT):
+                msg = 'ERROR: Children changed add event with defunct child'
+                debug.println(debug.LEVEL_INFO, msg)
+                return True
+
+            # This should be safe. We do not have a reason to present a newly-added,
+            # but not focused image. We do not need to update live regions for images.
+            # This is very likely a completely and utterly useless event for us. The
+            # reason for ignoring it here rather than quickly processing it is the
+            # potential for event floods like we're seeing from matrix.org.
+            if role == pyatspi.ROLE_IMAGE:
+                msg = 'INFO: Children changed add event for child image. Who cares?'
+                debug.println(debug.LEVEL_INFO, msg)
+                return True
+
         return False
 
     def _addToQueue(self, event, asyncMode):


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