// Copyright (c) 2026 Storm Dragon // Authors: Storm Dragon, Angus Kola // SPDX-License-Identifier: GPL-3.0-or-later package app import ( "strings" "git.stormux.org/storm/cthulhu/internal/atspi" "git.stormux.org/storm/cthulhu/internal/presentation" ) // A tooltip is transient output. It must not take keyboard focus or replace // the current review position when the provider shows its popup window. func (handler *accessibilityEventHandler) handleTooltip(event atspi.Event) bool { if event.Type != atspi.ShowingStateEvent || event.Source.Role != "tool tip" { return false } if event.Detail1 == 0 || handler.live == nil || !handler.live.Load().Reading.PresentTooltips { return true } options := presentationSettingsFromConfig(handler.live.Load(), true) spoken := presentation.FocusSpeechWithOptions(event.Source, options) if text := strings.TrimSpace(spoken.Text); text != "" && text != "tool tip" { handler.speech.Interrupt() handler.speech.Enqueue(speechRequest{Text: text, Chunks: spoken.WithText(text).Chunks, Role: "system", Cause: "tooltip"}) } return true }