From 32c39c4e3dd1715e69ecd5b1a0c9178b1eaac182 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Mon, 29 Dec 2025 22:42:45 -0500 Subject: [PATCH] Change sound priority a bit for the web. --- src/cthulhu/scripts/web/script.py | 46 ++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/cthulhu/scripts/web/script.py b/src/cthulhu/scripts/web/script.py index d654447..c12c94c 100644 --- a/src/cthulhu/scripts/web/script.py +++ b/src/cthulhu/scripts/web/script.py @@ -1394,7 +1394,8 @@ class Script(default.Script): self.utilities.setCaretContext(AXObject.get_parent(parent), -1) if not self._loadingDocumentContent: self.presentMessage(messages.MODE_BROWSE) - sound_theme_manager.getManager().playBrowseModeSound() + if not self._shouldSuppressBrowseModeSound(obj, inputEvent): + sound_theme_manager.getManager().playBrowseModeSound() else: if not self.utilities.grabFocusWhenSettingCaret(obj) \ and (self._lastCommandWasCaretNav \ @@ -1409,6 +1410,49 @@ class Script(default.Script): self._browseModeIsSticky = False self.refreshKeyGrabs() + def _shouldSuppressBrowseModeSound(self, obj, inputEvent): + if inputEvent is not None: + return False + + if _settingsManager.getSetting('roleSoundPresentation') \ + == settings.ROLE_SOUND_PRESENTATION_SPEECH_ONLY: + return False + + if not _settingsManager.getSetting('enableSound'): + return False + + icon = self._getControlSoundIcon(obj) + return icon is not None and icon.isValid() + + def _getControlSoundIcon(self, obj): + if not obj: + return None + + role = AXObject.get_role(obj) + manager = sound_theme_manager.getManager() + icon = manager.getRoleSoundIcon(role) + if icon: + return icon + + stateKey = None + if AXUtilities.is_checkable(obj) or AXUtilities.is_check_menu_item(obj): + if AXUtilities.is_indeterminate(obj): + stateKey = "mixed" + elif AXUtilities.is_checked(obj): + stateKey = "checked" + else: + stateKey = "unchecked" + elif AXUtilities.is_radio_button(obj): + stateKey = "checked" if AXUtilities.is_checked(obj) else "unchecked" + elif AXUtilities.is_toggle_button(obj) or AXUtilities.is_switch(obj): + stateKey = "checked" if (AXUtilities.is_checked(obj) or AXUtilities.is_pressed(obj)) \ + else "unchecked" + + if stateKey: + return manager.getRoleStateSoundIcon(role, stateKey) + + return None + def _tryClickableActivation(self, keyboardEvent): """Try to activate clickable element - returns True if we should consume the event."""