Commit 6b815e95 authored by Joanmarie Diggs's avatar Joanmarie Diggs

Filter out duplicate auto text events from Gecko apps

parent 9982bd9e
......@@ -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."""
......
......@@ -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):
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment