[orca] Ignore giant text insertions from plain-text objects



commit 3ccc01ec32ed850bbbc5fe34c8759928af6d6d14
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat Mar 14 13:27:42 2020 -0400

    Ignore giant text insertions from plain-text objects
    
    We get these when the user opens a huge file in Pluma or Gedit. And
    we aren't going to want to present these insertions anyway....

 src/orca/event_manager.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/orca/event_manager.py b/src/orca/event_manager.py
index de75eea79..ecea02f73 100644
--- a/src/orca/event_manager.py
+++ b/src/orca/event_manager.py
@@ -100,10 +100,14 @@ class EventManager:
     def _ignore(self, event):
         """Returns True if this event should be ignored."""
 
+        anydata = event.any_data
+        if isinstance(anydata, str) and len(anydata) > 100:
+            anydata = "%s (...)" % anydata[0:100]
+
         debug.println(debug.LEVEL_INFO, '')
         msg = 'EVENT MANAGER: %s for %s in %s (%s, %s, %s)' % \
               (event.type, event.source, event.host_application,
-               event.detail1,event.detail2, event.any_data)
+               event.detail1,event.detail2, anydata)
         debug.println(debug.LEVEL_INFO, msg, True)
 
         if not self._active:
@@ -180,6 +184,11 @@ class EventManager:
                 msg = 'EVENT MANAGER: Ignoring event type due to role and state'
                 debug.println(debug.LEVEL_INFO, msg, True)
                 return True
+        elif event.type.startswith('object:text-changed:insert') and event.detail2 > 1000 \
+             and role in [pyatspi.ROLE_TEXT, pyatspi.ROLE_STATIC]:
+            msg = 'EVENT MANAGER: Ignoring because inserted text has more than 1000 chars'
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return True
         elif event.type.startswith('object:state-changed:sensitive'):
             if role in [pyatspi.ROLE_MENU_ITEM,
                         pyatspi.ROLE_FILLER,


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