[orca] Move event synthesis error handling to the eventsynthesizer
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Move event synthesis error handling to the eventsynthesizer
- Date: Fri, 28 Jun 2019 14:26:19 +0000 (UTC)
commit 56d47743a96c387d883453a9bd3117803954d927
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Fri Jun 28 10:25:44 2019 -0400
Move event synthesis error handling to the eventsynthesizer
src/orca/eventsynthesizer.py | 18 +++++++++++---
src/orca/scripts/default.py | 59 ++++++++++++++++++++++----------------------
2 files changed, 45 insertions(+), 32 deletions(-)
---
diff --git a/src/orca/eventsynthesizer.py b/src/orca/eventsynthesizer.py
index d42bc9f25..832c0bc63 100644
--- a/src/orca/eventsynthesizer.py
+++ b/src/orca/eventsynthesizer.py
@@ -69,8 +69,14 @@ def _generateMouseEvent(x, y, event):
def _mouseEventOnCharacter(obj, event):
"""Performs the specified mouse event on the current character in obj."""
- text = obj.queryText()
- extents = text.getCharacterExtents(text.caretOffset, pyatspi.DESKTOP_COORDS)
+ try:
+ text = obj.queryText()
+ extents = text.getCharacterExtents(text.caretOffset, pyatspi.DESKTOP_COORDS)
+ except:
+ msg = "ERROR: Exception getting character extents for %s" % obj
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return False
+
x = max(extents[0], extents[0] + (extents[2] / 2) - 1)
y = extents[1] + extents[3] / 2
return _generateMouseEvent(x, y, event)
@@ -78,7 +84,13 @@ def _mouseEventOnCharacter(obj, event):
def _mouseEventOnObject(obj, event):
"""Performs the specified mouse event on obj."""
- extents = obj.queryComponent().getExtents(pyatspi.DESKTOP_COORDS)
+ try:
+ extents = obj.queryComponent().getExtents(pyatspi.DESKTOP_COORDS)
+ except:
+ msg = "ERROR: Exception getting extents for %s" % obj
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return False
+
x = extents.x + extents.width/2
y = extents.y + extents.height/2
return _generateMouseEvent(x, y, event)
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 5b97aaf95..7a13fd761 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -1224,18 +1224,18 @@ class Script(script.Script):
self.lastMouseRoutingTime = time.time()
if self.flatReviewContext:
self.flatReviewContext.routeToCurrent()
- else:
- try:
- eventsynthesizer.routeToCharacter(orca_state.locusOfFocus)
- except:
- try:
- eventsynthesizer.routeToObject(orca_state.locusOfFocus)
- except:
- full = messages.LOCATION_NOT_FOUND_FULL
- brief = messages.LOCATION_NOT_FOUND_BRIEF
- self.presentMessage(full, brief)
+ return True
- return True
+ if eventsynthesizer.routeToCharacter(orca_state.locusOfFocus):
+ return True
+
+ if eventsynthesizer.routeToObject(orca_state.locusOfFocus):
+ return True
+
+ full = messages.LOCATION_NOT_FOUND_FULL
+ brief = messages.LOCATION_NOT_FOUND_BRIEF
+ self.presentMessage(full, brief)
+ return False
def presentStatusBar(self, inputEvent):
"""Speaks and brailles the contents of the status bar and/or default
@@ -1309,33 +1309,34 @@ class Script(script.Script):
return True
if self.utilities.queryNonEmptyText(orca_state.locusOfFocus):
- eventsynthesizer.clickCharacter(orca_state.locusOfFocus, 1)
- return True
+ if eventsynthesizer.clickCharacter(orca_state.locusOfFocus, 1):
+ return True
- try:
- eventsynthesizer.clickObject(orca_state.locusOfFocus, 1)
- except:
- self.speakMessage(messages.LOCATION_NOT_FOUND_FULL)
+ if eventsynthesizer.clickObject(orca_state.locusOfFocus, 1):
+ return True
- return True
+ full = messages.LOCATION_NOT_FOUND_FULL
+ brief = messages.LOCATION_NOT_FOUND_BRIEF
+ self.presentMessage(full, brief)
+ return False
def rightClickReviewItem(self, inputEvent=None):
"""Performs a right mouse button click on the current item."""
if self.flatReviewContext:
self.flatReviewContext.clickCurrent(3)
- else:
- try:
- eventsynthesizer.clickCharacter(orca_state.locusOfFocus, 3)
- except:
- try:
- eventsynthesizer.clickObject(orca_state.locusOfFocus, 3)
- except:
- full = messages.LOCATION_NOT_FOUND_FULL
- brief = messages.LOCATION_NOT_FOUND_BRIEF
- self.presentMessage(full, brief)
+ return True
- return True
+ if eventsynthesizer.clickCharacter(orca_state.locusOfFocus, 3):
+ return True
+
+ if eventsynthesizer.clickObject(orca_state.locusOfFocus, 3):
+ return True
+
+ full = messages.LOCATION_NOT_FOUND_FULL
+ brief = messages.LOCATION_NOT_FOUND_BRIEF
+ self.presentMessage(full, brief)
+ return False
def spellCurrentItem(self, itemString):
"""Spell the current flat review word or line.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]