Merge branch 'testing' into wine-access
This commit is contained in:
@@ -121,6 +121,9 @@ class InputEventManager:
|
||||
self._wnck = None
|
||||
self._did_attempt_wnck_load: bool = False
|
||||
self._scriptWithSuspendedGrabsForXterm = None
|
||||
self._xtermFocusScreen = None
|
||||
self._xtermFocusHandlerId: int = 0
|
||||
self._xtermRecoverySourceId: int = 0
|
||||
|
||||
def activate_device(self) -> Atspi.Device:
|
||||
"""Creates and returns the AT-SPI device used by this manager."""
|
||||
@@ -196,6 +199,9 @@ class InputEventManager:
|
||||
self._key_pressed_id = 0
|
||||
self._key_released_id = 0
|
||||
self._device = None
|
||||
self._stop_xterm_focus_monitor()
|
||||
self._stop_xterm_recovery_timer()
|
||||
self._scriptWithSuspendedGrabsForXterm = None
|
||||
|
||||
def get_debug_snapshot(self) -> Dict[str, object]:
|
||||
"""Returns read-only counters useful for long-uptime diagnostics."""
|
||||
@@ -315,17 +321,27 @@ class InputEventManager:
|
||||
return []
|
||||
|
||||
grab_ids = []
|
||||
for kd in binding.key_definitions():
|
||||
definitionKeycode = kd.keycode or binding.keycode
|
||||
if self._signal_event_uses_selective_legacy_listener(
|
||||
definitionKeycode, kd.modifiers
|
||||
):
|
||||
continue
|
||||
grab_id = self._device.add_key_grab(kd, None)
|
||||
if grab_id == 0:
|
||||
continue
|
||||
grab_ids.append(grab_id)
|
||||
self._grabbed_bindings[grab_id] = binding
|
||||
try:
|
||||
for kd in binding.key_definitions():
|
||||
definitionKeycode = kd.keycode or binding.keycode
|
||||
if self._signal_event_uses_selective_legacy_listener(
|
||||
definitionKeycode, kd.modifiers
|
||||
):
|
||||
continue
|
||||
grab_id = self._device.add_key_grab(kd, None)
|
||||
if grab_id == 0:
|
||||
continue
|
||||
grab_ids.append(grab_id)
|
||||
self._grabbed_bindings[grab_id] = binding
|
||||
except Exception:
|
||||
for grab_id in grab_ids:
|
||||
try:
|
||||
self._device.remove_key_grab(grab_id)
|
||||
except Exception as error:
|
||||
msg = f"INPUT EVENT MANAGER: Could not roll back key grab {grab_id}: {error}"
|
||||
debug.print_message(debug.LEVEL_INFO, msg, True)
|
||||
self._grabbed_bindings.pop(grab_id, None)
|
||||
raise
|
||||
|
||||
return grab_ids
|
||||
|
||||
@@ -519,6 +535,7 @@ class InputEventManager:
|
||||
screen = wnck.Screen.get_default()
|
||||
if screen is None:
|
||||
return None
|
||||
self._ensure_xterm_focus_monitor(screen)
|
||||
screen.force_update()
|
||||
return screen.get_active_window()
|
||||
except Exception as error:
|
||||
@@ -588,10 +605,118 @@ class InputEventManager:
|
||||
]
|
||||
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
|
||||
|
||||
def _stop_xterm_focus_monitor(self) -> None:
|
||||
"""Stops monitoring X11 focus changes used for XTerm grab recovery."""
|
||||
|
||||
screen = self._xtermFocusScreen
|
||||
handlerId = self._xtermFocusHandlerId
|
||||
self._xtermFocusScreen = None
|
||||
self._xtermFocusHandlerId = 0
|
||||
if screen is None or not handlerId:
|
||||
return
|
||||
|
||||
try:
|
||||
screen.disconnect(handlerId)
|
||||
except Exception as error:
|
||||
msg = f"INPUT EVENT MANAGER: Could not stop XTerm focus monitor: {error}"
|
||||
debug.print_message(debug.LEVEL_INFO, msg, True)
|
||||
|
||||
def _ensure_xterm_focus_monitor(self, screen: Any) -> None:
|
||||
"""Monitors X11 focus so suspended grabs recover without another key event."""
|
||||
|
||||
if screen is self._xtermFocusScreen and self._xtermFocusHandlerId:
|
||||
return
|
||||
|
||||
self._stop_xterm_focus_monitor()
|
||||
try:
|
||||
handlerId = screen.connect(
|
||||
"active-window-changed",
|
||||
self._on_active_x11_window_changed,
|
||||
)
|
||||
except Exception as error:
|
||||
msg = f"INPUT EVENT MANAGER: Could not start XTerm focus monitor: {error}"
|
||||
debug.print_message(debug.LEVEL_INFO, msg, True)
|
||||
return
|
||||
|
||||
self._xtermFocusScreen = screen
|
||||
self._xtermFocusHandlerId = handlerId
|
||||
|
||||
def _stop_xterm_recovery_timer(self) -> None:
|
||||
"""Stops the fallback timer used to recover XTerm-suspended grabs."""
|
||||
|
||||
sourceId = self._xtermRecoverySourceId
|
||||
self._xtermRecoverySourceId = 0
|
||||
if not sourceId:
|
||||
return
|
||||
|
||||
try:
|
||||
GLib.source_remove(sourceId)
|
||||
except GLib.GError as error:
|
||||
msg = f"INPUT EVENT MANAGER: Could not stop XTerm recovery timer: {error}"
|
||||
debug.print_message(debug.LEVEL_INFO, msg, True)
|
||||
|
||||
def _ensure_xterm_recovery_timer(self) -> None:
|
||||
"""Starts fallback recovery when X11 focus notifications are insufficient."""
|
||||
|
||||
if self._device is None or self._xtermRecoverySourceId:
|
||||
return
|
||||
|
||||
self._xtermRecoverySourceId = GLib.timeout_add(
|
||||
100,
|
||||
self._poll_xterm_grab_recovery,
|
||||
)
|
||||
|
||||
def _poll_xterm_grab_recovery(self) -> bool:
|
||||
"""Checks whether XTerm-suspended grabs can now be restored."""
|
||||
|
||||
if self._scriptWithSuspendedGrabsForXterm is None:
|
||||
self._xtermRecoverySourceId = 0
|
||||
return False
|
||||
|
||||
match = self._active_x11_window_xterm_match()
|
||||
tokens = ["INPUT EVENT MANAGER: XTerm recovery matcher returned", match]
|
||||
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
|
||||
if match is False:
|
||||
self._xtermRecoverySourceId = 0
|
||||
self._restore_key_grabs_after_xterm()
|
||||
return False
|
||||
|
||||
keepPolling = not self._xtermFocusHandlerId or match is None
|
||||
if not keepPolling:
|
||||
self._xtermRecoverySourceId = 0
|
||||
return keepPolling
|
||||
|
||||
def _on_active_x11_window_changed(self, screen: Any, _previousWindow: Any) -> None:
|
||||
"""Restores suspended grabs as soon as X11 focus leaves XTerm."""
|
||||
|
||||
if self._scriptWithSuspendedGrabsForXterm is None:
|
||||
return
|
||||
|
||||
try:
|
||||
window = screen.get_active_window()
|
||||
except Exception as error:
|
||||
msg = f"INPUT EVENT MANAGER: Could not check changed X11 focus: {error}"
|
||||
debug.print_message(debug.LEVEL_INFO, msg, True)
|
||||
self._ensure_xterm_recovery_timer()
|
||||
return
|
||||
|
||||
match = self._x11_window_xterm_match(window)
|
||||
tokens = ["INPUT EVENT MANAGER: XTerm focus-change matcher returned", match]
|
||||
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
|
||||
if match is False:
|
||||
self._restore_key_grabs_after_xterm()
|
||||
elif match is None:
|
||||
self._ensure_xterm_recovery_timer()
|
||||
|
||||
def _active_x11_window_xterm_match(self) -> Optional[bool]:
|
||||
"""Returns whether the active X11 window is XTerm, or None when unknown."""
|
||||
|
||||
window = self._get_active_x11_window()
|
||||
return self._x11_window_xterm_match(window)
|
||||
|
||||
def _x11_window_xterm_match(self, window: Any) -> Optional[bool]:
|
||||
"""Returns whether window is XTerm, or None when it cannot be identified."""
|
||||
|
||||
if window is None:
|
||||
msg = "INPUT EVENT MANAGER: XTerm matcher cannot identify active X11 window."
|
||||
debug.print_message(debug.LEVEL_INFO, msg, True)
|
||||
@@ -816,12 +941,13 @@ class InputEventManager:
|
||||
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
|
||||
removeGrabs()
|
||||
self._scriptWithSuspendedGrabsForXterm = script
|
||||
if not self._xtermFocusHandlerId:
|
||||
self._ensure_xterm_recovery_timer()
|
||||
|
||||
def _restore_key_grabs_after_xterm(self) -> None:
|
||||
"""Restores key grabs after leaving XTerm."""
|
||||
|
||||
script = self._scriptWithSuspendedGrabsForXterm
|
||||
self._scriptWithSuspendedGrabsForXterm = None
|
||||
if script is None:
|
||||
return
|
||||
|
||||
@@ -833,6 +959,8 @@ class InputEventManager:
|
||||
activeScript,
|
||||
]
|
||||
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
|
||||
self._scriptWithSuspendedGrabsForXterm = None
|
||||
self._stop_xterm_recovery_timer()
|
||||
return
|
||||
|
||||
addGrabs = getattr(script, "addKeyGrabs", None)
|
||||
@@ -844,7 +972,29 @@ class InputEventManager:
|
||||
script,
|
||||
]
|
||||
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
|
||||
addGrabs()
|
||||
try:
|
||||
addGrabs()
|
||||
except Exception as error:
|
||||
msg = f"INPUT EVENT MANAGER: Could not restore XTerm-suspended key grabs: {error}"
|
||||
debug.print_message(debug.LEVEL_INFO, msg, True)
|
||||
removeGrabs = getattr(script, "removeKeyGrabs", None)
|
||||
if callable(removeGrabs):
|
||||
try:
|
||||
removeGrabs()
|
||||
except Exception as rollbackError:
|
||||
msg = (
|
||||
"INPUT EVENT MANAGER: Could not roll back partial XTerm grab "
|
||||
f"restoration: {rollbackError}"
|
||||
)
|
||||
debug.print_message(debug.LEVEL_INFO, msg, True)
|
||||
self._scriptWithSuspendedGrabsForXterm = None
|
||||
self._stop_xterm_recovery_timer()
|
||||
return
|
||||
self._ensure_xterm_recovery_timer()
|
||||
return
|
||||
|
||||
self._scriptWithSuspendedGrabsForXterm = None
|
||||
self._stop_xterm_recovery_timer()
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
# pylint: disable=too-many-positional-arguments
|
||||
|
||||
@@ -34,6 +34,7 @@ __license__ = "LGPL"
|
||||
from cthulhu import debug
|
||||
from cthulhu import cthulhu
|
||||
from cthulhu import cthulhu_state
|
||||
from cthulhu import keybindings
|
||||
from cthulhu.ax_object import AXObject
|
||||
from cthulhu.ax_utilities import AXUtilities
|
||||
from cthulhu.scripts import default
|
||||
@@ -49,6 +50,7 @@ class Script(web.Script):
|
||||
super().__init__(app)
|
||||
|
||||
self.presentIfInactive = False
|
||||
self._lastAutocompletePopupItem = None
|
||||
|
||||
def getBrailleGenerator(self):
|
||||
"""Returns the braille generator for this script."""
|
||||
@@ -325,7 +327,9 @@ class Script(web.Script):
|
||||
if AXUtilities.is_frame(parent) and not AXObject.get_name(parent):
|
||||
msg = "CHROMIUM: Event source believed to be in autocomplete popup"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
cthulhu_state.locusOfFocus = event.source
|
||||
if event.source != self._lastAutocompletePopupItem:
|
||||
self.presentObject(event.source, interrupt=True)
|
||||
self._lastAutocompletePopupItem = event.source
|
||||
return
|
||||
|
||||
msg = "CHROMIUM: Passing along event to default script"
|
||||
@@ -416,6 +420,22 @@ class Script(web.Script):
|
||||
if not self.utilities.canBeActiveWindow(event.source):
|
||||
return
|
||||
|
||||
autocomplete = self.utilities.autocompletePopupForFrame(event.source)
|
||||
if autocomplete:
|
||||
msg = "CHROMIUM: Treating nameless listbox frame as autocomplete popup"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
|
||||
selected = self.utilities.selectedChildren(autocomplete)
|
||||
activeItem = selected[0] if len(selected) == 1 else None
|
||||
if activeItem is None:
|
||||
activeItem = AXUtilities.get_focused_object(autocomplete)
|
||||
activeItem = activeItem or autocomplete
|
||||
tokens = ["CHROMIUM: Presenting active autocomplete popup item", activeItem]
|
||||
debug.printTokens(debug.LEVEL_INFO, tokens, True)
|
||||
self.presentObject(activeItem, interrupt=True)
|
||||
self._lastAutocompletePopupItem = activeItem
|
||||
return
|
||||
|
||||
# If this is a frame for a popup menu, we don't want to treat
|
||||
# it like a proper window:activate event because it's not as
|
||||
# far as the end-user experience is concerned.
|
||||
@@ -460,6 +480,30 @@ class Script(web.Script):
|
||||
def onWindowDeactivated(self, event):
|
||||
"""Callback for window:deactivate accessibility events."""
|
||||
|
||||
if self.utilities.autocompletePopupForFrame(event.source):
|
||||
msg = "CHROMIUM: Ignoring autocomplete popup deactivation"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
self._lastAutocompletePopupItem = None
|
||||
return
|
||||
|
||||
focus = cthulhu_state.locusOfFocus
|
||||
isAutocompleteCombo = AXUtilities.is_combo_box(focus) \
|
||||
and AXUtilities.supports_autocompletion(focus)
|
||||
if isAutocompleteCombo:
|
||||
lastKey, mods = self.utilities.lastKeyAndModifiers()
|
||||
if lastKey in ("Down", "Up") and mods & keybindings.ALT_MODIFIER_MASK:
|
||||
msg = "CHROMIUM: Preserving state while opening autocomplete popup"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return
|
||||
|
||||
app = AXObject.get_application(event.source)
|
||||
for child in AXObject.iter_children(app):
|
||||
popup = self.utilities.autocompletePopupForFrame(child)
|
||||
if popup and AXUtilities.is_showing(child):
|
||||
msg = "CHROMIUM: Preserving state during autocomplete popup activation"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return
|
||||
|
||||
if super().onWindowDeactivated(event):
|
||||
return
|
||||
|
||||
|
||||
@@ -170,6 +170,20 @@ class Utilities(web.Utilities):
|
||||
debug.printTokens(debug.LEVEL_INFO, tokens, True)
|
||||
return menu
|
||||
|
||||
def autocompletePopupForFrame(self, obj):
|
||||
"""Returns the listbox in a Chromium autocomplete popup frame."""
|
||||
|
||||
if not AXUtilities.is_frame(obj) or AXObject.get_name(obj):
|
||||
return None
|
||||
|
||||
# Native datalist/autofill popups are exposed as a direct listbox child
|
||||
# of a separate nameless frame, without a popup-for relation.
|
||||
if AXObject.get_child_count(obj) != 1:
|
||||
return None
|
||||
|
||||
child = AXObject.get_child(obj, 0)
|
||||
return child if AXUtilities.is_list_box(child) else None
|
||||
|
||||
def topLevelObject(self, obj, useFallbackSearch=False):
|
||||
if not obj:
|
||||
return None
|
||||
|
||||
@@ -2175,14 +2175,18 @@ class Script(default.Script):
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if self.utilities.textEventIsDueToInsertion(event):
|
||||
msg = "WEB: Event handled: Updating position due to insertion"
|
||||
typingReasons = (TextEventReason.TYPING, TextEventReason.TYPING_ECHOABLE)
|
||||
if reason in typingReasons \
|
||||
and event.source == cthulhu_state.locusOfFocus \
|
||||
and AXUtilities.is_editable(event.source):
|
||||
msg = f"WEB: Event handled: Updating position due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
self._saveLastCursorPosition(event.source, event.detail1)
|
||||
return True
|
||||
|
||||
if self.utilities.textEventIsDueToDeletion(event):
|
||||
msg = "WEB: Event handled: Updating position due to deletion"
|
||||
deletionReasons = (TextEventReason.BACKSPACE, TextEventReason.DELETE)
|
||||
if reason in deletionReasons and AXUtilities.is_editable(event.source):
|
||||
msg = f"WEB: Event handled: Updating position due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
self._saveLastCursorPosition(event.source, event.detail1)
|
||||
return True
|
||||
@@ -2885,7 +2889,7 @@ class Script(default.Script):
|
||||
self._currentTextAttrs = {}
|
||||
return False
|
||||
|
||||
def onTextDeleted(self, event):
|
||||
def onTextDeleted(self, event: Atspi.Event) -> bool:
|
||||
"""Callback for object:text-changed:delete accessibility events."""
|
||||
|
||||
if self.utilities.isZombie(event.source):
|
||||
@@ -2893,26 +2897,52 @@ class Script(default.Script):
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
reason = AXUtilitiesEvent.get_text_event_reason(event)
|
||||
if reason == TextEventReason.PAGE_SWITCH:
|
||||
msg = f"WEB: Deletion is due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
# UI and live-region classification precedes page-switch classification.
|
||||
# Preserve page-switch ownership when those conditions overlap.
|
||||
if self.utilities.lastInputEventWasPageSwitch():
|
||||
msg = "WEB: Deletion is believed to be due to page switch"
|
||||
msg = "WEB: Deletion is due to legacy page-switch fallback"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if reason == TextEventReason.LIVE_REGION_UPDATE:
|
||||
msg = f"WEB: Ignoring deletion due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
# Preserve web-specific live-region detection for values the shared
|
||||
# classifier does not currently identify.
|
||||
if self.utilities.isLiveRegion(event.source):
|
||||
msg = "WEB: Ignoring deletion from live region"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if self.utilities.eventIsBrowserUINoise(event):
|
||||
msg = "WEB: Ignoring event believed to be browser UI noise"
|
||||
msg = "WEB: Ignoring deletion from legacy live-region fallback"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if not self.utilities.inDocumentContent(event.source):
|
||||
msg = "WEB: Event source is not in document content"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
|
||||
if reason == TextEventReason.UI_UPDATE:
|
||||
msg = f"WEB: Ignoring browser UI event due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if self.utilities.eventIsBrowserUINoise(event):
|
||||
msg = "WEB: Ignoring event believed to be browser UI noise"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
if reason == TextEventReason.SPIN_BUTTON_VALUE_CHANGE:
|
||||
msg = f"WEB: Ignoring event due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if self.utilities.eventIsSpinnerNoise(event):
|
||||
msg = "WEB: Ignoring: Event believed to be spinner noise"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
@@ -2927,13 +2957,26 @@ class Script(default.Script):
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
self.utilities.clearContentCache()
|
||||
|
||||
if self.utilities.textEventIsDueToDeletion(event):
|
||||
msg = "WEB: Event believed to be due to editable text deletion"
|
||||
deletionReasons = (TextEventReason.BACKSPACE, TextEventReason.DELETE)
|
||||
if reason in deletionReasons \
|
||||
and AXUtilities.is_editable(event.source) \
|
||||
and (reason == TextEventReason.DELETE or not self.utilities.isHidden(event.source)):
|
||||
msg = f"WEB: Event is due to editable text deletion: {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return False
|
||||
|
||||
if self.utilities.textEventIsDueToInsertion(event):
|
||||
msg = "WEB: Ignoring event believed to be due to text insertion"
|
||||
inputEvent = cthulhu_state.lastNonModifierKeyEvent
|
||||
unmodifiedPrintableInput = \
|
||||
isinstance(cthulhu_state.lastInputEvent, input_event.KeyboardEvent) \
|
||||
and inputEvent \
|
||||
and inputEvent.is_printable_key() \
|
||||
and not inputEvent.modifiers
|
||||
typingReasons = (TextEventReason.TYPING, TextEventReason.TYPING_ECHOABLE)
|
||||
if reason in typingReasons \
|
||||
and event.source == cthulhu_state.locusOfFocus \
|
||||
and AXUtilities.is_editable(event.source) \
|
||||
and unmodifiedPrintableInput:
|
||||
msg = f"WEB: Ignoring insertion-caused deletion: {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
@@ -2986,13 +3029,33 @@ class Script(default.Script):
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if self.utilities.lastInputEventWasPageSwitch():
|
||||
msg = "WEB: Insertion is believed to be due to page switch"
|
||||
reason = AXUtilitiesEvent.get_text_event_reason(event)
|
||||
if reason == TextEventReason.PAGE_SWITCH:
|
||||
msg = f"WEB: Insertion is due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
# UI and live-region classification precedes page-switch classification.
|
||||
# Preserve page-switch ownership when those conditions overlap.
|
||||
if self.utilities.lastInputEventWasPageSwitch():
|
||||
msg = "WEB: Insertion is due to legacy page-switch fallback"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if reason == TextEventReason.LIVE_REGION_UPDATE:
|
||||
if self.utilities.handleAsLiveRegion(event):
|
||||
msg = f"WEB: Event handled as {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
self.liveRegionManager.handleEvent(event)
|
||||
else:
|
||||
msg = f"WEB: Ignoring unpresented {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
# Preserve web-specific live-region detection for values the shared
|
||||
# classifier does not currently identify, such as container-live=off.
|
||||
if self.utilities.handleAsLiveRegion(event):
|
||||
msg = "WEB: Event to be handled as live region"
|
||||
msg = "WEB: Event handled by legacy live-region fallback"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
self.liveRegionManager.handleEvent(event)
|
||||
return True
|
||||
@@ -3002,21 +3065,39 @@ class Script(default.Script):
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if self.utilities.eventIsEOCAdded(event):
|
||||
msg = "WEB: Ignoring: Event was for embedded object char"
|
||||
if reason == TextEventReason.CHILDREN_CHANGE:
|
||||
msg = f"WEB: Ignoring event due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if self.utilities.eventIsBrowserUINoise(event):
|
||||
msg = "WEB: Ignoring event believed to be browser UI noise"
|
||||
# Preserve the broader legacy match for whitespace plus embedded
|
||||
# object characters until the shared classifier owns that pattern.
|
||||
if self.utilities.eventIsEOCAdded(event):
|
||||
msg = "WEB: Ignoring: Event was for embedded object char"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if not self.utilities.inDocumentContent(event.source):
|
||||
msg = "WEB: Event source is not in document content"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
|
||||
if reason == TextEventReason.UI_UPDATE:
|
||||
msg = f"WEB: Ignoring browser UI event due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if self.utilities.eventIsBrowserUINoise(event):
|
||||
msg = "WEB: Ignoring event believed to be browser UI noise"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
if reason == TextEventReason.SPIN_BUTTON_VALUE_CHANGE:
|
||||
msg = f"WEB: Ignoring event due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if self.utilities.eventIsSpinnerNoise(event):
|
||||
msg = "WEB: Ignoring: Event believed to be spinner noise"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
@@ -3027,6 +3108,11 @@ class Script(default.Script):
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return True
|
||||
|
||||
if reason == TextEventReason.AUTO_INSERTION_PRESENTABLE:
|
||||
msg = f"WEB: Deferring presentable event due to {reason}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return False
|
||||
|
||||
msg = "WEB: Clearing content cache due to text insertion"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
self.utilities.clearContentCache()
|
||||
|
||||
@@ -40,7 +40,6 @@ import time
|
||||
import urllib
|
||||
|
||||
from cthulhu import debug
|
||||
from cthulhu import input_event
|
||||
from cthulhu import input_event_manager
|
||||
from cthulhu import messages
|
||||
from cthulhu import cthulhu
|
||||
@@ -4682,32 +4681,6 @@ class Utilities(script_utilities.Utilities):
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
return False
|
||||
|
||||
def textEventIsDueToDeletion(self, event):
|
||||
if not self.inDocumentContent(event.source) \
|
||||
or not AXUtilities.is_editable(event.source):
|
||||
return False
|
||||
|
||||
if self.isDeleteCommandTextDeletionEvent(event) \
|
||||
or self.isBackSpaceCommandTextDeletionEvent(event):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def textEventIsDueToInsertion(self, event):
|
||||
if not event.type.startswith("object:text-"):
|
||||
return False
|
||||
|
||||
if not self.inDocumentContent(event.source) \
|
||||
or event.source != cthulhu_state.locusOfFocus \
|
||||
or not AXUtilities.is_editable(event.source):
|
||||
return False
|
||||
|
||||
if isinstance(cthulhu_state.lastInputEvent, input_event.KeyboardEvent):
|
||||
inputEvent = cthulhu_state.lastNonModifierKeyEvent
|
||||
return inputEvent and inputEvent.is_printable_key() and not inputEvent.modifiers
|
||||
|
||||
return False
|
||||
|
||||
def textEventIsForNonNavigableTextObject(self, event):
|
||||
if not event.type.startswith("object:text-"):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user