diff --git a/src/cthulhu/scripts/apps/Thunderbird/spellcheck.py b/src/cthulhu/scripts/apps/Thunderbird/spellcheck.py index 5e1f615..1752d2f 100644 --- a/src/cthulhu/scripts/apps/Thunderbird/spellcheck.py +++ b/src/cthulhu/scripts/apps/Thunderbird/spellcheck.py @@ -31,6 +31,7 @@ __date__ = "$Date$" __copyright__ = "Copyright (c) 2014 Igalia, S.L." __license__ = "LGPL" +import cthulhu.debug as debug import cthulhu.cthulhu_state as cthulhu_state import cthulhu.spellcheck as spellcheck from cthulhu.ax_object import AXObject @@ -59,7 +60,10 @@ class SpellCheck(spellcheck.SpellCheck): return False def _isCandidateWindow(self, window): - if not AXUtilities.is_dialog(window): + # Check for dialog or modal window (Thunderbird may use either) + if not (AXUtilities.is_dialog(window) or AXUtilities.is_modal(window)): + tokens = ["THUNDERBIRD SPELL CHECK:", window, "is not a dialog or modal window"] + debug.printTokens(debug.LEVEL_INFO, tokens, True) return False def isNonSpellCheckChild(x): diff --git a/src/cthulhu/scripts/toolkits/Gecko/script.py b/src/cthulhu/scripts/toolkits/Gecko/script.py index c840234..f856d8f 100644 --- a/src/cthulhu/scripts/toolkits/Gecko/script.py +++ b/src/cthulhu/scripts/toolkits/Gecko/script.py @@ -39,6 +39,7 @@ from cthulhu import debug from cthulhu import cthulhu from cthulhu import cthulhu_state from cthulhu.ax_object import AXObject +from cthulhu.ax_utilities import AXUtilities from cthulhu.scripts import default from cthulhu.scripts import web from .script_utilities import Utilities @@ -241,6 +242,13 @@ class Script(web.Script): debug.printMessage(debug.LEVEL_INFO, msg, True) return + # We're sometimes getting a spurious focus claim from the Firefox/Thunderbird + # window after opening a file from file manager. + if AXObject.get_role(event.source) == Atspi.Role.FRAME: + msg = "GECKO: Ignoring event believed to be noise." + debug.printMessage(debug.LEVEL_INFO, msg, True) + return + msg = "GECKO: Passing along event to default script" debug.printMessage(debug.LEVEL_INFO, msg, True) default.Script.onFocusedChanged(self, event) @@ -301,6 +309,14 @@ class Script(web.Script): if super().onShowingChanged(event): return + # Set focus to newly shown menus outside of document content + if event.detail1 and AXUtilities.is_menu(event.source) \ + and not self.utilities.inDocumentContent(event.source): + msg = "GECKO: Setting locus of focus to newly shown menu." + debug.printMessage(debug.LEVEL_INFO, msg, True) + cthulhu.setLocusOfFocus(event, event.source) + return + msg = "GECKO: Passing along event to default script" debug.printMessage(debug.LEVEL_INFO, msg, True) default.Script.onShowingChanged(self, event)