Sometimes when switching from steam to a different workspace and back only the outer window takes focus so some actions don't work. Tentative fix for that.

This commit is contained in:
Storm Dragon committed 2026-10-14 19:51:07 -04:00
1 parent 9205e7280a
commit 12c514aab0
19 files changed
+798 -30

No files matched your search

+75
View File
@@ -0,0 +1,75 @@
"""Steam-shaped X11 browser and popup fixture for a private X server."""
import json
import os
import sys
from Xlib import X, Xatom, XK, display
from Xlib.xobject.drawable import Window
def main() -> None:
connection = display.Display()
root = connection.screen().root
activeAtom = connection.intern_atom("_NET_ACTIVE_WINDOW")
pidAtom = connection.intern_atom("_NET_WM_PID")
def make_window(parent: Window, width: int, height: int) -> Window:
window = parent.create_window(0, 0, width, height, 0,
connection.screen().root_depth,
event_mask=X.KeyPressMask | X.KeyReleaseMask)
window.change_property(pidAtom, Xatom.CARDINAL, 32, [os.getpid()])
window.map()
return window
steam = make_window(root, 800, 600)
steam.set_wm_class("steamwebhelper", "steam")
mainHost = make_window(steam, 800, 600)
browser = make_window(mainHost, 800, 600)
popupHost = make_window(steam, 300, 600)
popup = make_window(popupHost, 300, 600)
other = make_window(root, 800, 600)
other.set_wm_class("example", "Example")
otherChild = make_window(other, 800, 600)
windows = dict(steam=steam, browser=browser, popup=popup,
popupHost=popupHost, other=other, otherChild=otherChild)
root.change_property(activeAtom, Xatom.WINDOW, 32, [steam.id])
browser.set_input_focus(X.RevertToParent, X.CurrentTime)
connection.sync()
print(json.dumps({name: window.id for name, window in windows.items()}), flush=True)
for line in sys.stdin:
command = json.loads(line)
action = command["action"]
window = windows[command.get("window", "steam")]
if action == "activate":
root.change_property(activeAtom, Xatom.WINDOW, 32, [window.id])
window.set_input_focus(X.RevertToParent, X.CurrentTime)
elif action == "focus":
window.set_input_focus(X.RevertToParent, X.CurrentTime)
elif action == "unmap":
window.unmap()
elif action == "map":
window.map()
elif action == "destroy":
window.destroy()
elif action == "class":
window.set_wm_class("example", "Example")
elif action == "pid":
window.change_property(pidAtom, Xatom.CARDINAL, 32, [os.getpid() + 1])
elif action == "events":
connection.sync()
events = []
while connection.pending_events():
event = connection.next_event()
if event.type in (X.KeyPress, X.KeyRelease):
events.append({"window": event.window.id, "pressed": event.type == X.KeyPress,
"escape": event.detail == connection.keysym_to_keycode(XK.string_to_keysym("Escape"))})
print(json.dumps(events), flush=True)
continue
connection.sync()
print("ready", flush=True)
connection.close()
if __name__ == "__main__":
main()
+16
View File
@@ -6,10 +6,18 @@ that window once, retain its pending announcement across Wine control focus
updates, and introduce it again after a foreground switch. Title changes
within the window still follow the application's title-change preference.
Fresh input cancels titles still waiting for their coalescing deadline or an
application override, as well as titles already in the speech queue. Held-key
repeats retain automatic titles; Control and Escape remain explicit stop keys.
Input that initiates a window switch precedes the destination's title and must
not cancel that new introduction. Later title changes remain enabled normally.
Run the focused checks from the repository root:
```sh
go test -race ./internal/app -run 'Title|WineReview|XTerm|Foreground' -count=1
CTHULHU_NATIVE_BROWSER_TESTS=editing GOCACHE=/tmp/cthulhu-go-cache GOPROXY=off python3 tests/native_browser.py
xvfb-run -a dbus-run-session -- env CTHULHU_NATIVE_WINDOW_TITLES=1 GOCACHE=/tmp/cthulhu-go-cache GOPROXY=off go test ./internal/app -run '^TestNativeAutomaticTitleDispatchLatency$' -count=1 -v
dbus-run-session -- env CTHULHU_WINE_TITLE_DBUS=1 go test -race ./internal/app -run '^TestPrivateWineTitleSurvivesReviewFocusBurst$' -count=1 -v
```
@@ -33,6 +41,14 @@ replacement with its user. Review and listening are required before submission.
stay quiet. With the preference enabled, changed titles should speak once.
5. If used, repeat with a Wine virtual desktop and check title messages on a
physical Braille display.
6. In Brave, use Ctrl+L and immediately type several characters. Each character
should echo and interrupt previous speech without an older title following
it. Repeat while a long title is speaking, and use Control and Escape to stop
it. Switch away and back without typing; the window title must still speak.
7. With automatic title reading enabled, change a page's title and verify it
speaks once. The editing fixture's F8 key changes its title to
"Cthulhu Browser Probe updated". Check address suggestions, deletion, and
native caret movement still announce their usual output.
Automated queue assertions do not establish physical Alt+Tab, audible speech,
installed-binary behavior, or physical Braille acceptance.