[orca] Prevent double-presentation of description when used static text



commit a7e1edd2a8345f3a9192264634cb2e14ee6a7e14
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri May 13 13:57:38 2022 +0200

    Prevent double-presentation of description when used static text
    
    The generators fall back on the accessible description when attempting
    to present the static text for alerts, dialogs, infobars, etc. When
    a description is found and the user has enabled the presentation of
    descriptions, a double-presentation results. This commit fixes that.

 src/orca/formatting.py       |  8 ++++----
 src/orca/generator.py        | 22 +++++++++++++++++++++-
 src/orca/speech_generator.py |  5 +++++
 3 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index cbfe5499c..184a17081 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -212,8 +212,8 @@ formatting = {
             'basicWhereAmI': 'labelOrName + roleName + value + percentage + ' + MNEMONIC + ' + accelerator + 
required'
             },
         pyatspi.ROLE_DIALOG: {
-            'focused': 'labelOrName + roleName + (unrelatedLabels or description)',
-            'unfocused': '(expandedEOCs or (labelOrName + roleName + (unrelatedLabels or description)))'
+            'focused': 'labelOrName + roleName + (unrelatedLabelsOrDescription)',
+            'unfocused': '(expandedEOCs or (labelOrName + roleName + (unrelatedLabelsOrDescription)))'
             },
         pyatspi.ROLE_DOCUMENT_FRAME: {
             'unfocused': 'labelOrName + readOnly + textRole + currentLineText + anyTextSelection + ' + 
MNEMONIC,
@@ -356,7 +356,7 @@ formatting = {
             'basicWhereAmI': 'ancestors + pause + labelOrName + checkedStateIfCheckable + pause + 
accelerator + pause + positionInList + ' + MNEMONIC
             },
         pyatspi.ROLE_NOTIFICATION: {
-            'unfocused': 'roleName + labelOrName + pause + (expandedEOCs or unrelatedLabels or description)'
+            'unfocused': 'roleName + labelOrName + pause + (expandedEOCs or unrelatedLabelsOrDescription)'
             },
         pyatspi.ROLE_PAGE: {
             'focused': 'label + readOnly + currentLineText + anyTextSelection',
@@ -632,7 +632,7 @@ formatting = {
                                      asString(labelOrName + value + roleName + required))]'
             },
         pyatspi.ROLE_DIALOG: {
-            'unfocused': '[Component(obj, asString(labelOrName + roleName + (unrelatedLabels or 
description)))]'
+            'unfocused': '[Component(obj, asString(labelOrName + roleName + 
(unrelatedLabelsOrDescription)))]'
             },
         #pyatspi.ROLE_DIRECTORY_PANE: 'default'
         pyatspi.ROLE_DOCUMENT_FRAME: {
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 54aa2710e..fa3089f8c 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -242,8 +242,10 @@ class Generator:
             msg = '%s GENERATOR: Starting generation for %s' % (self._mode.upper(), obj)
             debug.println(debug.LEVEL_INFO, msg, True)
 
-            # Reset 'usedDescriptionForName' if a previous generator used it.
+            # Reset 'usedDescriptionFor*' if a previous generator used it.
             self._script.pointOfReference['usedDescriptionForName'] = False
+            self._script.pointOfReference['usedDescriptionForUnrelatedLabels'] = False
+            self._script.pointOfReference['usedDescriptionForAlert'] = False
 
             debuginfo = lambda x: self._resultElementToString(x, False)
             assert(formatting)
@@ -430,6 +432,18 @@ class Generator:
 
         return result
 
+    def _generateUnrelatedLabelsOrDescription(self, obj, **args):
+        result = self._generateUnrelatedLabels(obj, **args)
+        if result:
+            self._script.pointOfReference['usedDescriptionForUnrelatedLabels'] = False
+            return result
+
+        result = self._generateDescription(obj, **args)
+        if result:
+            self._script.pointOfReference['usedDescriptionForUnrelatedLabels'] = True
+
+        return result
+
     def _generateDescription(self, obj, **args):
         """Returns an array of strings fo use by speech and braille that
         represent the description of the object, if that description
@@ -439,6 +453,12 @@ class Generator:
         if self._script.pointOfReference.get('usedDescriptionForName'):
             return []
 
+        if self._script.pointOfReference.get('usedDescriptionForAlert'):
+            return []
+
+        if self._script.pointOfReference.get('usedDescriptionForUnrelatedLabels'):
+            return []
+
         role = args.get('role', obj.getRole())
 
         # Unity Panel Service menubar items are labels which claim focus and
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index d71ea03c8..483c7c1a6 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -234,6 +234,11 @@ class SpeechGenerator(generator.Generator):
                 alreadyUsed = self._script.pointOfReference.pop('usedDescriptionForAlert')
             except:
                 pass
+        else:
+            try:
+                alreadyUsed = self._script.pointOfReference.pop('usedDescriptionForUnrelatedLabels')
+            except:
+                pass
 
         if alreadyUsed:
             return []


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