Follow Steam Big Picture overlays and stop false Steam notifications
Big Picture draws Quick Access, the Steam menu and the power menu as separate Chromium frames in its one X11 window and never marks them active, so their focus was discarded and Cthulhu kept reading the library. Accept a focus gain in a showing Steam frame owned by the X11 foreground process. Steam closes these popups when focus leaves them, which browse-mode caret movement caused, so Steam popup documents (<Name>_uid<n>) start in focus mode. Steam's events calendar sits in a live region and was spoken as dozens of "Steam:" notifications. Live regions now count as Steam notifications only inside toast popups; notification and alert roles are unchanged. Verified live: F2, Notifications, Right reached and completed the hardware survey. The toast restriction is not yet checked against a real toast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c919016bb
commit
87b6aa49da
13 files changed
+236
-3
No files matched your search
@@ -15,6 +15,7 @@ import (
|
||||
"git.stormux.org/storm/cthulhu/internal/input"
|
||||
"git.stormux.org/storm/cthulhu/internal/review"
|
||||
"git.stormux.org/storm/cthulhu/internal/sound"
|
||||
"git.stormux.org/storm/cthulhu/internal/webscripts"
|
||||
)
|
||||
|
||||
type documentContextCapturer interface {
|
||||
@@ -52,6 +53,7 @@ type browserModeController struct {
|
||||
cancel context.CancelFunc
|
||||
done chan struct{}
|
||||
document atspi.ObjectID
|
||||
focusProcess string // provider process of the latest native focus
|
||||
navigation atspi.ObjectID
|
||||
navigationDocument atspi.ObjectID
|
||||
navigationFocus atspi.ObjectID
|
||||
@@ -240,6 +242,11 @@ func (browser *browserModeController) accept(result browserModeResult, speech sp
|
||||
browser.mutex.Unlock()
|
||||
browser.state = review.DocumentModeState{}
|
||||
browser.state.SetSticky(browser.stickyModes[browser.document.BusName])
|
||||
// Steam popups own their arrow keys and close when focus leaves.
|
||||
// Start them in focus mode; a manual toggle still clears this.
|
||||
if browser.state.Sticky() == review.InactiveMode && gamepadPopupDocument(browser.focusProcess, result.owner) {
|
||||
browser.state.SetSticky(review.FocusMode)
|
||||
}
|
||||
}
|
||||
browser.ready = true
|
||||
modeInput := runtimeModeInput(result.owner)
|
||||
@@ -247,6 +254,16 @@ func (browser *browserModeController) accept(result browserModeResult, speech sp
|
||||
mode := browser.state.Update(modeInput, browser.modeSettings())
|
||||
browser.set(mode, speech, false)
|
||||
}
|
||||
func gamepadPopupDocument(process string, owner atspi.DocumentContext) bool {
|
||||
document := owner.TopLevel.ID()
|
||||
for _, ancestor := range owner.Ancestors {
|
||||
if ancestor.ID() == document {
|
||||
return webscripts.GamepadPopupDocument(process, ancestor.Name)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (browser *browserModeController) modeSettings() review.ModeSettings {
|
||||
if browser.settings != nil {
|
||||
return browser.settings()
|
||||
|
||||
@@ -806,3 +806,56 @@ func TestStructuralNavigationAutomaticFocus(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func steamDocumentContext(t *testing.T, documentPath, documentName string) atspi.DocumentContext {
|
||||
t.Helper()
|
||||
button := atspi.Snapshot{BusName: ":1.42", Path: documentPath + "/button", Role: "button", StatesKnown: true, Focusable: true}
|
||||
doc := atspi.Snapshot{BusName: ":1.42", Path: documentPath, Name: documentName, Role: "document web", StatesKnown: true}
|
||||
tree, err := atspi.NewAccessibleTree(doc.ID(), []atspi.TreeNode{{Snapshot: doc, Children: []atspi.ObjectID{button.ID()}}, {Snapshot: button}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ref, _ := tree.Reference(button.ID())
|
||||
owner, err := tree.DocumentContext(ref)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return owner
|
||||
}
|
||||
|
||||
func TestBrowserModeSteamPopupStartsInFocusMode(t *testing.T) {
|
||||
keys := &modeKeys{}
|
||||
browser := newBrowserModeController(nil, keys, nil)
|
||||
queue := &fakeSpeechQueue{spoken: make(chan string, 16)}
|
||||
main := steamDocumentContext(t, "/main", "Steam Big Picture Mode")
|
||||
popup := steamDocumentContext(t, "/popup", "QuickAccess_uid2")
|
||||
browser.focusProcess = "steamwebhelper"
|
||||
|
||||
browser.follow(main.Ancestors[0].ID())
|
||||
browser.accept(browserModeResult{focus: main.Ancestors[0].ID(), generation: 1, owner: main}, queue)
|
||||
if browser.mode != review.BrowseMode || !keys.enabled {
|
||||
t.Fatalf("main Big Picture view mode = %v, want browse", browser.mode)
|
||||
}
|
||||
browser.follow(popup.Ancestors[0].ID())
|
||||
browser.accept(browserModeResult{focus: popup.Ancestors[0].ID(), generation: 2, owner: popup}, queue)
|
||||
if browser.mode != review.FocusMode || keys.enabled {
|
||||
t.Fatalf("Quick Access mode = %v, want focus so Steam keeps its arrow keys", browser.mode)
|
||||
}
|
||||
browser.toggle(queue)
|
||||
if browser.mode != review.BrowseMode {
|
||||
t.Fatal("manual toggle could not leave focus mode in a Steam popup")
|
||||
}
|
||||
browser.follow(main.Ancestors[0].ID())
|
||||
browser.accept(browserModeResult{focus: main.Ancestors[0].ID(), generation: 3, owner: main}, queue)
|
||||
if browser.mode != review.BrowseMode {
|
||||
t.Fatalf("returning to the main view kept mode %v", browser.mode)
|
||||
}
|
||||
|
||||
other := newBrowserModeController(nil, &modeKeys{}, nil)
|
||||
other.focusProcess = "chrome"
|
||||
other.follow(popup.Ancestors[0].ID())
|
||||
other.accept(browserModeResult{focus: popup.Ancestors[0].ID(), generation: 1, owner: popup}, queue)
|
||||
if other.mode != review.BrowseMode {
|
||||
t.Fatalf("non-Steam document named like a popup got mode %v", other.mode)
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,7 @@ func (handler *accessibilityEventHandler) filterNavigationAndNames(event atspi.E
|
||||
}
|
||||
if browser != nil && isFocusEvent(event.Type) && !ownedAutocompletePopup(event) {
|
||||
browser.nativeButtonFocus(isFocusGainEvent(event) && (event.Source.Role == "button" || event.Source.Role == "push button" || event.Source.Role == "toggle button"))
|
||||
browser.focusProcess = event.Source.ApplicationProcess
|
||||
browser.follow(event.Source.ID())
|
||||
} else if browser != nil && event.Type == atspi.CaretEvent && !event.Source.Editable {
|
||||
browser.followCaret(event.Source.ID())
|
||||
|
||||
Reference in new issue
Block a user