[orca] Filter out duplicate auto text events from Gecko apps
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Filter out duplicate auto text events from Gecko apps
- Date: Fri, 18 Oct 2019 19:46:11 +0000 (UTC)
commit 6b815e9540209a527e7bfc7082aa1ba3dd6a6f62
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Fri Oct 18 15:45:30 2019 -0400
Filter out duplicate auto text events from Gecko apps
src/orca/input_event.py | 18 +++++++++++++++++
src/orca/script_utilities.py | 16 +++++++++++++++
.../scripts/toolkits/Gecko/script_utilities.py | 23 ++++++++++++++++++++++
3 files changed, 57 insertions(+)
---
diff --git a/src/orca/input_event.py b/src/orca/input_event.py
index d335a46ac..96ae51686 100644
--- a/src/orca/input_event.py
+++ b/src/orca/input_event.py
@@ -296,6 +296,24 @@ class KeyboardEvent(InputEvent):
return False
+ def isReleaseFor(self, other):
+ """Return True if this is the release event for other."""
+
+ if not other:
+ return False
+
+ if not other.isPressedKey() or self.isPressedKey():
+ return False
+
+ return self.id == other.id \
+ and self.hw_code == other.hw_code \
+ and self.modifiers == other.modifiers \
+ and self.event_string == other.event_string \
+ and self.keyval_name == other.keyval_name \
+ and self.is_text == other.is_text \
+ and self.keyType == other.keyType \
+ and self._clickCount == other._clickCount
+
def isNavigationKey(self):
"""Return True if this is a navigation key."""
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 2eb2880ba..260de4a7c 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -3295,6 +3295,20 @@ class Utilities:
return text + delimiter + newText
+ def treatAsDuplicateEvent(self, event1, event2):
+ if not (event1 and event2):
+ return False
+
+ # The goal is to find event spam so we can ignore the event.
+ if event1 == event2:
+ return False
+
+ return event1.source == event2.source \
+ and event1.type == event2.type \
+ and event1.detail1 == event2.detail1 \
+ and event1.detail2 == event2.detail2 \
+ and event1.any_data == event2.any_data
+
def isAutoTextEvent(self, event):
"""Returns True if event is associated with text being autocompleted
or autoinserted or autocorrected or autosomethingelsed.
@@ -3325,6 +3339,8 @@ class Utilities:
return True
if lastKey in ["Up", "Down", "Page_Up", "Page_Down"]:
return self.isEditableDescendantOfComboBox(event.source)
+ if not self.lastInputEventWasPrintableKey():
+ return False
string = event.source.queryText().getText(0, -1)
if string.endswith(event.any_data):
diff --git a/src/orca/scripts/toolkits/Gecko/script_utilities.py
b/src/orca/scripts/toolkits/Gecko/script_utilities.py
index 21406d919..c1277d474 100644
--- a/src/orca/scripts/toolkits/Gecko/script_utilities.py
+++ b/src/orca/scripts/toolkits/Gecko/script_utilities.py
@@ -32,6 +32,7 @@ __license__ = "LGPL"
import pyatspi
import re
+import time
from orca import debug
from orca import orca_state
@@ -42,6 +43,9 @@ class Utilities(web.Utilities):
def __init__(self, script):
super().__init__(script)
+ self._lastAutoTextObjectEvent = None
+ self._lastAutoTextInputEvent = None
+ self._lastAutoTextEventTime = 0
def _attemptBrokenTextRecovery(self, obj, **args):
boundary = args.get('boundary')
@@ -322,3 +326,22 @@ class Utilities(web.Utilities):
label = labels[0]
label.clearCache()
return label.name
+
+ def isAutoTextEvent(self, event):
+ if not super().isAutoTextEvent(event):
+ return False
+
+ if self.inDocumentContent(event.source):
+ return True
+
+ if self.treatAsDuplicateEvent(self._lastAutoTextObjectEvent, event) \
+ and time.time() - self._lastAutoTextEventTime < 0.5 \
+ and orca_state.lastInputEvent.isReleaseFor(self._lastAutoTextInputEvent):
+ msg = "GECKO: Event believed to be duplicate auto text event."
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return False
+
+ self._lastAutoTextObjectEvent = event
+ self._lastAutoTextInputEvent = orca_state.lastInputEvent
+ self._lastAutoTextEventTime = time.time()
+ return True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]