[orca: 1/2] descendantAtPoint: first only look for descendant with "showing" state



commit 34a746f619206ae0fae2910bed030c86a1dd312c
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date:   Fri Aug 30 14:20:23 2019 +0200

    descendantAtPoint: first only look for descendant with "showing" state
    
    This is needed for e.g. evince which has several pages drawn at the same
    place, but only one has the "showing" state.
    
    Normally all widgets that can be pointed at should have "showing" state,
    but some might be missing it and this change would introduce a regression
    in such a case, so this change keeps the fallback of looking at descendants
    which don't have "showing" state too.
    
    Fixes #54

 src/orca/script_utilities.py | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 26ebc5004..7a41b7c31 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -4112,6 +4112,7 @@ class Utilities:
                         return cell
                     return child
 
+        candidates_showing = []
         candidates = []
         for child in root:
             obj = self.descendantAtPoint(child, x, y, coordType)
@@ -4123,8 +4124,13 @@ class Utilities:
                 string = child.queryText().getText(0, -1)
                 if re.search("[^\ufffc\s]", string):
                     candidates.append(child)
+                    if child.getState().contains(pyatspi.STATE_SHOWING):
+                        candidates_showing.append(child)
 
+        if len(candidates_showing) == 1:
+            return candidates_showing[0]
         if len(candidates) == 1:
+            # It should have had state "showing" actually
             return candidates[0]
 
         return None


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