[orca] Attempt to hack around SeaMonkey's broken events for HTML input popups



commit 486f1f823ba2f1e6d2547b8779142f9bd3cb416a
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Jul 11 22:16:50 2016 -0400

    Attempt to hack around SeaMonkey's broken events for HTML input popups
    
    The popup claims focus when the user is inserting text in the input.
    The input claims focus when the user is navigating within the popup.
    And the popup is otherwise inaccessible, failing to emit focus or
    selection change events. We cannot fix this, but we can try to make
    it suck a bit less by ignoring popup focus claims when the user is
    inserting text in the input.

 src/orca/script_utilities.py              |    7 ++++++
 src/orca/scripts/apps/SeaMonkey/script.py |   30 ++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index ac5e25e..bbed192 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -3705,6 +3705,13 @@ class Utilities:
         text = "%s\n%s" % (text, newText)
         clipboard.set_text(text, -1)
 
+    def lastInputEventWasPrintableKey(self):
+        event = orca_state.lastInputEvent
+        if not isinstance(event, input_event.KeyboardEvent):
+            return False
+
+        return event.isPrintableKey()
+
     def lastInputEventWasCommand(self):
         keyString, mods = self.lastKeyAndModifiers()
         return mods & keybindings.CTRL_MODIFIER_MASK
diff --git a/src/orca/scripts/apps/SeaMonkey/script.py b/src/orca/scripts/apps/SeaMonkey/script.py
index 4ec3dc7..e0f69a2 100644
--- a/src/orca/scripts/apps/SeaMonkey/script.py
+++ b/src/orca/scripts/apps/SeaMonkey/script.py
@@ -48,10 +48,38 @@ class Script(Gecko.Script):
             msg = "ERROR: Exception getting role for %s" % orca_state.locusOfFocus
             debug.println(debug.LEVEL_INFO, msg, True)
         else:
-            if focusRole == pyatspi.ROLE_TABLE_ROW :
+            if focusRole == pyatspi.ROLE_TABLE_ROW:
                 msg = "SEAMONKEY: Ignoring, locusOfFocus is %s" % orca_state.locusOfFocus
                 debug.println(debug.LEVEL_INFO, msg, True)
                 return
 
         super().onBusyChanged(event)
 
+    def onFocus(self, event):
+        """Callback for focus: accessibility events."""
+
+        # We should get proper state-changed events for these.
+        if self.utilities.inDocumentContent(event.source):
+            return
+
+        try:
+            focusRole = orca_state.locusOfFocus.getRole()
+        except:
+            msg = "ERROR: Exception getting role for %s" % orca_state.locusOfFocus
+            debug.println(debug.LEVEL_INFO, msg, True)
+            focusRole = None
+
+        if focusRole != pyatspi.ROLE_ENTRY or not self.utilities.inDocumentContent():
+            super().onFocus(event)
+            return
+
+        if event.source.getRole() == pyatspi.ROLE_MENU:
+            msg = "SEAMONKEY: Non-document menu claimed focus from document entry"
+            debug.println(debug.LEVEL_INFO, msg, True)
+
+            if self.utilities.lastInputEventWasPrintableKey():
+                msg = "SEAMONKEY: Ignoring, believed to be result of printable input"
+                debug.println(debug.LEVEL_INFO, msg, True)
+                return
+
+        super().onFocus(event)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]