// Copyright (c) 2026 Storm Dragon // Authors: Storm Dragon, Angus Kola // SPDX-License-Identifier: GPL-3.0-or-later package app import "git.stormux.org/storm/cthulhu/internal/atspi" // The event loop remembers exactly five control identities for one preferences // child. A new child or focus reset retires them. GTK reports combo selections // as menu-item descendants with the owning combo in OriginPath. type echoPreviewPresentation struct { pid int64 controls [5]atspi.ObjectID } func (preview *echoPreviewPresentation) owns(event atspi.Event, pid int64) bool { if preview.pid != pid { *preview = echoPreviewPresentation{pid: pid} } if pid <= 0 { return false } index := -1 switch event.Source.Name { case "Key echo rate": index = 0 case "Key echo pitch": index = 1 case "Key echo volume": index = 2 case "Key echo speech synthesizer": index = 3 case "Key echo person": index = 4 } if index >= 0 && int64(event.Source.ApplicationPID) == pid && (index < 3 && event.Source.Role == "slider" || index >= 3 && event.Source.Role == "combo box") { preview.controls[index] = event.Source.ID() return true } if event.Type == atspi.SelectionChangedEvent && event.Source.Role == "menu item" { owner := atspi.NewObjectID(event.Source.BusName, event.OriginPath) return owner.Valid() && (owner == preview.controls[3] || owner == preview.controls[4]) } return false }