[orca] Try to make typeahead search in Gtk+ 3 suck less
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Try to make typeahead search in Gtk+ 3 suck less
- Date: Tue, 13 Dec 2016 17:21:15 +0000 (UTC)
commit ba06b53ece427f1fe2f4c34e9d1437bc9687ef79
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Tue Dec 13 11:41:19 2016 -0500
Try to make typeahead search in Gtk+ 3 suck less
src/orca/script_utilities.py | 3 ++
src/orca/scripts/toolkits/gtk/script.py | 32 +++++++++++---------
src/orca/scripts/toolkits/gtk/script_utilities.py | 18 +++++++++++
3 files changed, 39 insertions(+), 14 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 14b4b07..0e9f11e 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -637,6 +637,9 @@ class Utilities:
def isToggleDescendantOfComboBox(self, obj):
return False
+ def isTypeahead(self, obj):
+ return False
+
def isFunctionalDialog(self, obj):
"""Returns True if the window is a functioning as a dialog.
This method should be subclassed by application scripts as
diff --git a/src/orca/scripts/toolkits/gtk/script.py b/src/orca/scripts/toolkits/gtk/script.py
index 7392352..6177275 100644
--- a/src/orca/scripts/toolkits/gtk/script.py
+++ b/src/orca/scripts/toolkits/gtk/script.py
@@ -62,19 +62,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 = "GTK: locusOfFocus believed to be typeahead. Presenting change."
+ debug.println(debug.LEVEL_INFO, msg, True)
+ self.presentObject(event.any_data)
def onCheckedChanged(self, event):
"""Callback for object:state-changed:checked accessibility events."""
@@ -218,9 +212,19 @@ class Script(default.Script):
super().onSelectionChanged(event)
return
+ isFocused = event.source.getState().contains(pyatspi.STATE_FOCUSED)
role = event.source.getRole()
- if role == pyatspi.ROLE_COMBO_BOX \
- and not event.source.getState().contains(pyatspi.STATE_FOCUSED):
+ if role == pyatspi.ROLE_COMBO_BOX and not isFocused:
+ return
+
+ if not isFocused and self.utilities.isTypeahead(orca_state.locusOfFocus):
+ msg = "GTK: 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 \
diff --git a/src/orca/scripts/toolkits/gtk/script_utilities.py
b/src/orca/scripts/toolkits/gtk/script_utilities.py
index 0e90997..812acc5 100644
--- a/src/orca/scripts/toolkits/gtk/script_utilities.py
+++ b/src/orca/scripts/toolkits/gtk/script_utilities.py
@@ -38,10 +38,12 @@ class Utilities(script_utilities.Utilities):
super().__init__(script)
self._isComboBoxWithToggleDescendant = {}
self._isToggleDescendantOfComboBox = {}
+ self._isTypeahead = {}
def clearCachedObjects(self):
self._isComboBoxWithToggleDescendant = {}
self._isToggleDescendantOfComboBox = {}
+ self._isTypeahead = {}
def displayedText(self, obj):
displayedText = script_utilities.Utilities.displayedText(self, obj)
@@ -96,6 +98,22 @@ class Utilities(script_utilities.Utilities):
self._isToggleDescendantOfComboBox[hash(obj)] = rv
return rv
+ 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 isSearchEntry(self, obj, focusedOnly=False):
# Another example of why we need subrole support in ATK and AT-SPI2.
try:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]