[orca/gnome-3-34] Improve reliability of unfocusedAlertAndDialogCount()
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/gnome-3-34] Improve reliability of unfocusedAlertAndDialogCount()
- Date: Wed, 13 Nov 2019 16:21:00 +0000 (UTC)
commit 463c383f99c831dbaefefeded75255f8d446b81b
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Wed Nov 13 11:18:53 2019 -0500
Improve reliability of unfocusedAlertAndDialogCount()
src/orca/script_utilities.py | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 1bd18f500..2eec087ed 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2447,19 +2447,13 @@ class Utilities:
Returns the alert and dialog count.
"""
- alertAndDialogCount = 0
- app = obj.getApplication()
- window = self.topLevelObject(obj)
- if window and window.getRole() != pyatspi.ROLE_ALERT and \
- window.getRole() != pyatspi.ROLE_DIALOG and \
- not self.isFunctionalDialog(window):
- for child in app:
- if child.getRole() == pyatspi.ROLE_ALERT or \
- child.getRole() == pyatspi.ROLE_DIALOG or \
- self.isFunctionalDialog(child):
- alertAndDialogCount += 1
-
- return alertAndDialogCount
+ roles = [pyatspi.ROLE_ALERT, pyatspi.ROLE_DIALOG]
+ isDialog = lambda x: x and x.getRole() in roles or self.isFunctionalDialog(x)
+ dialogs = [x for x in obj.getApplication() if isDialog(x)]
+ dialogs.extend([x for x in self.topLevelObject(obj) if isDialog(x)])
+ showing = list(filter(self.isShowingAndVisible, dialogs))
+ unfocused = list(filter(lambda x: not self.canBeActiveWindow(x), showing))
+ return len(unfocused)
def uri(self, obj):
"""Return the URI for a given link object.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]