Name Steam popups and tabs, skip empty editor placeholder
Steam popup documents spoke their internal names (QuickAccess_uid2); they now say "Quick Access" and "Main Menu". The unnamed Quick Access tab is named Friends from its quickaccess_tab id. An empty rich editor whose text is only an object replacement character (ChatGPT's message box) no longer speaks that character on focus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b4fca03bf
commit
d47a0c0d5d
5 files changed
+73
-1
No files matched your search
@@ -15,6 +15,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"git.stormux.org/storm/cthulhu/internal/webscripts"
|
||||
)
|
||||
|
||||
func shouldSpeakEvent(eventType string, detail1 int) bool {
|
||||
@@ -151,6 +153,9 @@ func (adapter *Adapter) captureNativeEventSnapshot(event *C.AtspiEvent, target *
|
||||
}
|
||||
}
|
||||
snapshot.ApplicationProcess = adapter.applicationProcess(target)
|
||||
if name, ok := webscripts.SteamName(snapshot.ApplicationProcess, snapshot.Role, snapshot.Name, snapshot.ElementID); ok {
|
||||
snapshot.Name = name
|
||||
}
|
||||
if snapshot.Role == "slider" ||
|
||||
snapshot.Role == "combo box" && (snapshot.Name == "Key echo speech synthesizer" || snapshot.Name == "Key echo person") {
|
||||
snapshot.ApplicationPID = int(C.atspi_accessible_get_process_id(target, nil))
|
||||
|
||||
@@ -158,7 +158,9 @@ func FocusSpeechWithOptions(snapshot atspi.Snapshot, options Options) Speech {
|
||||
if options.SpeakDescription {
|
||||
fields = append(fields, snapshot.Description)
|
||||
}
|
||||
if snapshot.Role != "spin button" {
|
||||
// An empty rich editor can expose only an embedded paragraph's object
|
||||
// replacement character (ChatGPT's message box). It is not content.
|
||||
if snapshot.Role != "spin button" && strings.TrimSpace(strings.ReplaceAll(snapshot.Text, "\ufffc", "")) != "" {
|
||||
fields = append(fields, snapshot.Text)
|
||||
}
|
||||
if snapshot.Autocomplete && snapshot.SelectionEnd > snapshot.SelectionStart {
|
||||
|
||||
@@ -292,3 +292,14 @@ func TestDocumentLoadAnnouncesOnlyTitle(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFocusTextOmitsEmbeddedObjectPlaceholder(t *testing.T) {
|
||||
entry := atspi.Snapshot{Name: "Ask ChatGPT", Role: "entry", Editable: true, Text: ""}
|
||||
if got := FocusTextWithOptions(entry, DefaultOptions()); strings.ContainsRune(got, '') || got != FocusTextWithOptions(atspi.Snapshot{Name: "Ask ChatGPT", Role: "entry", Editable: true}, DefaultOptions()) {
|
||||
t.Fatalf("empty rich editor focus = %q", got)
|
||||
}
|
||||
entry.Text = "Hello"
|
||||
if got := FocusTextWithOptions(entry, DefaultOptions()); !strings.Contains(got, "Hello") {
|
||||
t.Fatalf("editor with text lost its content: %q", got)
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,39 @@ func GamepadPopupDocument(processName, documentName string) bool {
|
||||
return MatchProcess(processName) == Steam && steamPopupDocument.MatchString(strings.TrimSpace(documentName))
|
||||
}
|
||||
|
||||
// Steam's Quick Access tab keys, from its client UI. Some tabs, such as
|
||||
// Friends, carry an icon and no aria-label, so their tab has no name.
|
||||
var steamQuickAccessTabs = map[string]string{
|
||||
"quickaccess_tab_0": "Notifications",
|
||||
"quickaccess_tab_1": "Remote Play Together",
|
||||
"quickaccess_tab_2": "Voice Chat",
|
||||
"quickaccess_tab_3": "Friends",
|
||||
"quickaccess_tab_4": "Quick Settings",
|
||||
"quickaccess_tab_5": "Performance",
|
||||
"quickaccess_tab_6": "Help",
|
||||
"quickaccess_tab_7": "Soundtracks",
|
||||
}
|
||||
|
||||
var steamPopupNameWord = regexp.MustCompile(`[A-Z][a-z0-9]*|[a-z0-9]+`)
|
||||
|
||||
// SteamName replaces names Steam leaves internal or empty: a popup document's
|
||||
// browser name ("QuickAccess_uid2" becomes "Quick Access") and an unnamed
|
||||
// Quick Access tab. It returns false when the name should stay as it is.
|
||||
func SteamName(processName, role, name, elementID string) (string, bool) {
|
||||
if MatchProcess(processName) != Steam {
|
||||
return "", false
|
||||
}
|
||||
switch {
|
||||
case role == "document web" && GamepadPopupDocument(processName, name):
|
||||
base, _, _ := strings.Cut(strings.TrimSpace(name), "_uid")
|
||||
return strings.Join(steamPopupNameWord.FindAllString(base, -1), " "), true
|
||||
case role == "page tab" && strings.TrimSpace(name) == "":
|
||||
title, ok := steamQuickAccessTabs[elementID]
|
||||
return title, ok
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// ToastDocument reports Steam's toast popup, named notificationtoasts_uid<n>-<id>
|
||||
// in Big Picture and notificationtoasts_<id>_desktop otherwise. Live regions
|
||||
// elsewhere, such as the store's event calendar, are page content, not toasts.
|
||||
|
||||
@@ -174,3 +174,24 @@ func TestToastDocument(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSteamName(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
process, role, name, elementID, want string
|
||||
ok bool
|
||||
}{
|
||||
{"steamwebhelper", "document web", "QuickAccess_uid2", "", "Quick Access", true},
|
||||
{"steamwebhelper", "document web", "MainMenu_uid12", "", "Main Menu", true},
|
||||
{"steamwebhelper", "document web", "Steam Big Picture Mode", "", "", false},
|
||||
{"steamwebhelper", "page tab", "", "quickaccess_tab_3", "Friends", true},
|
||||
{"steamwebhelper", "page tab", "Notifications", "quickaccess_tab_0", "", false},
|
||||
{"steamwebhelper", "page tab", "", "other_tab", "", false},
|
||||
{"chrome", "page tab", "", "quickaccess_tab_3", "", false},
|
||||
{"chrome", "document web", "QuickAccess_uid2", "", "", false},
|
||||
} {
|
||||
got, ok := SteamName(test.process, test.role, test.name, test.elementID)
|
||||
if got != test.want || ok != test.ok {
|
||||
t.Errorf("SteamName(%q, %q, %q, %q) = %q, %v; want %q, %v", test.process, test.role, test.name, test.elementID, got, ok, test.want, test.ok)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user