[orca] Try to make typeahead search in Gtk+ 2 suck less
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Try to make typeahead search in Gtk+ 2 suck less
- Date: Thu, 22 Dec 2016 10:18:11 +0000 (UTC)
commit f298e2692d760bdf67a38df68e539067667b228f
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Thu Dec 22 04:56:18 2016 -0500
Try to make typeahead search in Gtk+ 2 suck less
src/orca/scripts/toolkits/GAIL/script.py | 34 ++++++++++++-------
src/orca/scripts/toolkits/GAIL/script_utilities.py | 23 ++++++++++++-
2 files changed, 42 insertions(+), 15 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/GAIL/script.py b/src/orca/scripts/toolkits/GAIL/script.py
index 6e8a213..d61dc33 100644
--- a/src/orca/scripts/toolkits/GAIL/script.py
+++ b/src/orca/scripts/toolkits/GAIL/script.py
@@ -27,6 +27,7 @@ __license__ = "LGPL"
import pyatspi
+import orca.debug as debug
import orca.orca as orca
import orca.orca_state as orca_state
import orca.scripts.default as default
@@ -44,19 +45,13 @@ class Script(default.Script):
def onActiveDescendantChanged(self, event):
"""Callback for object:active-descendant-changed accessibility events."""
- role = event.source.getRole()
-
- try:
- focusedRole = orca_state.locusOfFocus.getRole()
- except:
- pass
- else:
- # This is very likely typeahead search and not a real focus change.
- tableRoles = [pyatspi.ROLE_TABLE, pyatspi.ROLE_TREE_TABLE]
- if focusedRole == pyatspi.ROLE_TEXT and role in tableRoles:
- orca.setLocusOfFocus(event, event.source, False)
+ if not self.utilities.isTypeahead(orca_state.locusOfFocus):
+ super().onActiveDescendantChanged(event)
+ return
- default.Script.onActiveDescendantChanged(self, event)
+ msg = "GAIL: locusOfFocus believed to be typeahead. Presenting change."
+ debug.println(debug.LEVEL_INFO, msg, True)
+ self.presentObject(event.any_data)
def onFocus(self, event):
"""Callback for focus: accessibility events."""
@@ -140,7 +135,20 @@ class Script(default.Script):
def onSelectionChanged(self, event):
"""Callback for object:selection-changed accessibility events."""
- if event.source.getRole() == pyatspi.ROLE_LAYERED_PANE \
+ isFocused = event.source.getState().contains(pyatspi.STATE_FOCUSED)
+ role = event.source.getRole()
+
+ if not isFocused and self.utilities.isTypeahead(orca_state.locusOfFocus):
+ msg = "GAIL: locusOfFocus believed to be typeahead. Presenting change."
+ debug.println(debug.LEVEL_INFO, msg, True)
+
+ selectedChildren = self.utilities.selectedChildren(event.source)
+ for child in selectedChildren:
+ if not self.utilities.isLayoutOnly(child):
+ self.presentObject(child)
+ return
+
+ if role == pyatspi.ROLE_LAYERED_PANE \
and self.utilities.selectedChildCount(event.source) > 1:
return
diff --git a/src/orca/scripts/toolkits/GAIL/script_utilities.py
b/src/orca/scripts/toolkits/GAIL/script_utilities.py
index 07463d1..0739f3d 100644
--- a/src/orca/scripts/toolkits/GAIL/script_utilities.py
+++ b/src/orca/scripts/toolkits/GAIL/script_utilities.py
@@ -28,13 +28,32 @@ __license__ = "LGPL"
import pyatspi
import re
-import orca.debug as debug
import orca.script_utilities as script_utilities
class Utilities(script_utilities.Utilities):
def __init__(self, script):
- script_utilities.Utilities.__init__(self, script)
+ super().__init__(script)
+ self._isTypeahead = {}
+
+ def clearCachedObjects(self):
+ self._isTypeahead = {}
+
+ def isTypeahead(self, obj):
+ if not (obj and obj.getRole() == pyatspi.ROLE_TEXT):
+ return False
+
+ rv = self._isTypeahead.get(hash(obj))
+ if rv is not None:
+ return rv
+
+ parent = obj.parent
+ while parent and self.isLayoutOnly(parent):
+ parent = parent.parent
+
+ rv = parent and parent.getRole() == pyatspi.ROLE_WINDOW
+ self._isTypeahead[hash(obj)] = rv
+ return rv
def rgbFromString(self, attributeValue):
regex = re.compile("rgb|[^\w,]", re.IGNORECASE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]