40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
// 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"
|
|
"git.stormux.org/storm/cthulhu/internal/presentation"
|
|
)
|
|
|
|
// The event loop owns this history. Some toolkits repeat focus on the semantic
|
|
// combo when its internal selection changes; that is not entry into a control.
|
|
type comboPresentation struct {
|
|
focus atspi.ObjectID
|
|
value string
|
|
}
|
|
|
|
func (history *comboPresentation) observe(event atspi.Event) (text string, update, duplicate bool) {
|
|
focusGain := isFocusGainEvent(event)
|
|
if event.Source.Role != "combo box" {
|
|
if focusGain {
|
|
history.focus, history.value = event.Source.ID(), ""
|
|
}
|
|
return "", false, false
|
|
}
|
|
if !focusGain && !isValueChangeEvent(event.Type) &&
|
|
event.Type != atspi.AccessibleNameEvent && !isManagedDescendantEvent(event.Type) {
|
|
return "", false, false
|
|
}
|
|
text = presentation.ComboBoxSelectionText(event.Source)
|
|
update = !focusGain || event.Source.ID() == history.focus
|
|
duplicate = update && event.Source.ID() == history.focus && text == history.value
|
|
history.value = text
|
|
if focusGain {
|
|
history.focus = event.Source.ID()
|
|
}
|
|
return text, update, duplicate
|
|
}
|