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:
Storm DragonandClaude Opus 5.5 committed 2026-12-01 02:18:32 -05:00
1 parent 5c919016bb
commit 87b6aa49da
13 files changed
+236 -3

No files matched your search

@@ -312,6 +312,10 @@ func (adapter *Adapter) enrichNativeWindowEvent(event *C.AtspiEvent, target *C.A
focusEvent.ForegroundMismatch = !adapter.matchForeground(target, window, focusEvent.Window, &focusEvent.ForegroundCheck, false)
} else {
focusEvent.ForegroundMismatch = !adapter.matchForeground(target, window, focusEvent.Window, nil, focusedMenuItem)
if focusEvent.ForegroundMismatch && (eventType == FocusEvent || eventType == FocusedStateEvent) && snapshot.Focused &&
adapter.matchSteamOverlayFocus(window) {
focusEvent.ForegroundMismatch = false
}
}
if !focusEvent.ForegroundMismatch && window != nil &&
(eventType == WindowActivatedEvent || snapshot.Role == "table" || snapshot.Role == "table cell") {
@@ -9,6 +9,8 @@ package atspi
*/
import "C"
import "git.stormux.org/storm/cthulhu/internal/webscripts"
// Reject routine background updates before resolving a selected descendant or
// capturing text, attributes, values and geometry. Global lifecycle events and
// supported notifications retain their existing handling. No new ownership is
@@ -61,6 +63,10 @@ func (adapter *Adapter) filterNativeBackgroundEvent(event *C.AtspiEvent, eventTy
if adapter.matchForeground(event.source, window, windowID, nil, focusedMenuItem) {
return false
}
if (eventType == FocusEvent || eventType == FocusedStateEvent && event.detail1 != 0) &&
adapter.matchSteamOverlayFocus(window) {
return false
}
if origin.BusName == adapter.foregroundWindow.BusName {
// Browser suggestions and tooltips can occupy a different top-level
// without taking X11 focus. Preserve their existing event-loop checks;
@@ -83,3 +89,26 @@ func (adapter *Adapter) filterNativeBackgroundEvent(event *C.AtspiEvent, eventTy
}
return true
}
// matchSteamOverlayFocus checks fresh frame state for a Steam overlay focus
// gain. It never changes the correlated foreground window: the main Big
// Picture frame keeps that role and reclaims focus when the overlay closes.
func (adapter *Adapter) matchSteamOverlayFocus(window *C.AtspiAccessible) bool {
if window == nil {
return false
}
process := adapter.applicationProcess(window)
if webscripts.MatchProcess(process) != webscripts.Steam {
return false
}
pid := adapter.foregroundProcessID(int(C.atspi_accessible_get_process_id(window, nil)))
C.atspi_accessible_clear_cache_single(window)
states := C.atspi_accessible_get_state_set(window)
if states == nil {
return false
}
showing := C.atspi_state_set_contains(states, C.ATSPI_STATE_SHOWING) != 0
iconified := C.atspi_state_set_contains(states, C.ATSPI_STATE_ICONIFIED) != 0
C.g_object_unref(C.gpointer(states))
return steamOverlayFocusMatches(adapter.Foreground().Client, process, pid, true, showing, iconified)
}
+11
View File
@@ -9,6 +9,7 @@ import (
"slices"
"git.stormux.org/storm/cthulhu/internal/platform/xorg"
"git.stormux.org/storm/cthulhu/internal/webscripts"
)
// The native caller supplies a complete, fresh, bounded application window
@@ -37,6 +38,16 @@ func preferencesForegroundMatches(client xorg.Foreground, pid int, preferencesPI
int64(pid) == preferencesPID && client.PID == pid
}
// Steam Big Picture draws overlays such as Quick Access and the main menu as
// separate Chromium frames inside its one X11 window. Steam moves focus into
// them but never marks their frame active, so the normal active-frame check
// discards that focus. Accept only a confirmed focus gain in a showing frame
// owned by the X11 foreground process itself.
func steamOverlayFocusMatches(client xorg.Foreground, process string, pid int, focusGain, showing, iconified bool) bool {
return focusGain && showing && !iconified && webscripts.MatchProcess(process) == webscripts.Steam &&
client.Known && client.Window != 0 && client.PID > 0 && pid == client.PID
}
func foregroundWindowMatches(client xorg.Foreground, pid int, bounds Rectangle) bool {
if client.PID > 0 && pid > 0 && client.PID != pid {
return false
+27
View File
@@ -216,3 +216,30 @@ func TestForegroundWindowReplacement(t *testing.T) {
})
}
}
func TestSteamOverlayFocusMatchesForegroundProcessOnly(t *testing.T) {
client := xorg.Foreground{Known: true, Window: 83886130, PID: 111, Width: 1920, Height: 1080}
if !steamOverlayFocusMatches(client, "steamwebhelper", 111, true, true, false) {
t.Fatal("Quick Access focus in the foreground Steam process was rejected")
}
cases := map[string]struct {
client xorg.Foreground
process string
pid int
focusGain, showing, iconified bool
}{
"other application": {client, "chrome", 111, true, true, false},
"other process": {client, "steamwebhelper", 222, true, true, false},
"not a focus gain": {client, "steamwebhelper", 111, false, true, false},
"hidden overlay": {client, "steamwebhelper", 111, true, false, false},
"iconified overlay": {client, "steamwebhelper", 111, true, true, true},
"no foreground window": {xorg.Foreground{Known: true, PID: 111}, "steamwebhelper", 111, true, true, false},
"unknown foreground": {xorg.Foreground{Window: 83886130, PID: 111}, "steamwebhelper", 111, true, true, false},
"unknown foreground pid": {xorg.Foreground{Known: true, Window: 83886130}, "steamwebhelper", 0, true, true, false},
}
for name, test := range cases {
if steamOverlayFocusMatches(test.client, test.process, test.pid, test.focusGain, test.showing, test.iconified) {
t.Errorf("%s: accepted Steam overlay focus", name)
}
}
}
+7 -1
View File
@@ -93,9 +93,15 @@ func (adapter *Adapter) webNotification(event *C.AtspiEvent) *webscripts.Notific
C.g_object_unref(C.gpointer(ancestor))
}
}()
documentName, documentFound := "", false
for current := C.web_ref(source); current != nil; {
ancestors = append(ancestors, current)
role := C.atspi_accessible_get_role(current, nil)
if role == C.ATSPI_ROLE_DOCUMENT_WEB && !documentFound {
name := C.atspi_accessible_get_name(current, nil)
documentName, documentFound = C.GoString(name), true
C.g_free(C.gpointer(name))
}
candidate := webscripts.NotificationCandidate{}
switch role {
case C.ATSPI_ROLE_NOTIFICATION:
@@ -116,7 +122,7 @@ func (adapter *Adapter) webNotification(event *C.AtspiEvent) *webscripts.Notific
current = C.atspi_accessible_get_parent(current, nil)
}
index := webscripts.NotificationRoot(candidates)
if index < 0 {
if index < 0 || candidates[index].Role == "" && !webscripts.ToastDocument(documentName) {
return nil
}
root := ancestors[index]