[orca] LibreOffice: Work around missing focus event for Calc spreadsheet



commit a40593f3fe12b63c7ce2ab7d0dc0965390400c19
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Aug 12 14:18:58 2021 +0200

    LibreOffice: Work around missing focus event for Calc spreadsheet
    
    After saving a document and returning to the Calc spreadsheet, there
    is no object:state-changed:focused event for the table. As a result,
    AT-SPI2 does not update its cache and we're given active-descendant-
    changed events on an object which claims to be unfocused. Thus we
    ignore them.
    
    Therefore, check in the app script for this condition and clear the
    cache on the table before handing the event off to the default script.

 src/orca/scripts/apps/soffice/script.py | 7 +++++++
 src/orca/scripts/default.py             | 2 ++
 2 files changed, 9 insertions(+)
---
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 8fc200326..f3617799f 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -641,6 +641,13 @@ class Script(default.Script):
                 self.spellcheck.presentErrorDetails()
             return
 
+        if self.utilities.isSpreadSheetCell(event.any_data) \
+           and not event.any_data.getState().contains(pyatspi.STATE_FOCUSED) \
+           and not event.source.getState().contains(pyatspi.STATE_FOCUSED) :
+            msg = "SOFFICE: Neither source nor child have focused state. Clearing cache on table."
+            debug.println(debug.LEVEL_INFO, msg, True)
+            event.source.clearCache()
+
         default.Script.onActiveDescendantChanged(self, event)
 
     def onChildrenAdded(self, event):
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index b891f9df4..e60045f3f 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -2285,6 +2285,8 @@ class Script(script.Script):
 
         if not event.source.getState().contains(pyatspi.STATE_FOCUSED) \
            and not event.any_data.getState().contains(pyatspi.STATE_FOCUSED):
+            msg = "DEFAULT: Ignoring event. Neither source nor child have focused state."
+            debug.println(debug.LEVEL_INFO, msg, True)
             return
 
         if self.stopSpeechOnActiveDescendantChanged(event):


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