Files
faumarayandClaude Opus 5.5 1ffcf690cc spikes/gpui/windows: spike 3, a second window on the shared model
A main window and a Studio-like window (cx.open_window through
gpui_kit::open_window) both render views that observe one root entity: a
counter both change, the push-to-talk state, which window is active, and
the studio's preview. Closing the studio window docks it
(on_window_should_close), closing the main window ends the app, F11
toggles fullscreen, Ctrl+Tab activates the other window. The global
push-to-talk key is voelin-platform's X11 hotkey (XInput2 raw events),
read by a GPUI foreground task. The preview comes from voelin-media's
studio compositor and its preview tap, one BGRA RenderImage shown by both
windows, the replaced one dropped from every atlas. drive.sh runs the
scenario and its checks on the headless display.

From the interrupted attempt, changed here: the window's size after a
fullscreen toggle is logged once the window manager has set it (the
toggle's own bounds are the old ones) and checked (1000x900 back);
drive.sh says how long the app took to end; measure.sh (new) runs the
three cost cases into $OUT instead of the README's commands, which wrote
into the current directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:43:43 +03:00

2.7 KiB

Spike 3: the second window

spike-windows opens a main window and, on Ctrl+O (or the Open Studio button), a Studio-like window with cx.open_window (gpui_kit::open_window, which wraps the view in gpui-component's Root). Both windows render one root entity, Shared: a counter both change (Ctrl+K or +1 in either), the push-to-talk state, which window is active, and the studio's preview.

  • Preview. GPUI cannot read a window's pixels (no take_snapshot), so the studio's preview comes from where the client gets it today: the engine's compositor (voelin_media::studio::Studio with one scene of the test pattern, 1920x1080 at 30 fps) and its preview tap at the studio's default 960x540, 15 fps (RGBA). A thread converts each preview frame to one BGRA RenderImage; the shared entity holds it and both windows show the same Arc (img()), the replaced one leaves every window's atlas (cx.drop_image(old, None)).
  • Global push-to-talk. voelin_platform::hotkey::HotkeyManager::x11 on the display (XInput2 raw events on the root window: whichever window has focus, nothing grabbed), F8 by default (--hotkey). Its events (a tokio UnboundedReceiver) are read by a GPUI foreground task, which needs no tokio reactor, and set the shared model.
  • Close and fullscreen. Closing the studio window (on_window_should_close) docks the studio back into the main window and the app goes on; closing the main window quits. F11 toggles fullscreen in either window; Ctrl+Tab activates the other window (Window::activate_window).

Every change is a JSON line on stdout ({"event": …}); with --seconds the meter adds its once-a-second CPU and memory lines.

Reproducing

spikes/gpui/shell.sh sh -c 'cd spikes/gpui && cargo build --locked --release'
# the scenario and its eleven checks (PASS/FAIL), screenshots in $OUT:
spikes/gpui/shell.sh spikes/gpui/headless.sh -- spikes/gpui/windows/drive.sh
# the cost of the shared preview: CPU and memory with the main window
# alone, with both windows showing it, and without the compositor (45 s
# each, 10 s of warm-up; <case>.jsonl and <case>.load in $OUT):
spikes/gpui/shell.sh spikes/gpui/headless.sh -- spikes/gpui/windows/measure.sh

drive.sh (xdotool on the headless display, keys through XTEST so the hotkey's raw events see them): Ctrl+O in the main window; Ctrl+K twice in the studio window; F8 held while the studio window has focus; F11 twice; Ctrl+Tab; Ctrl+K in the main window; Alt+F4 on the studio window (openbox asks it to close); F8 with the main window active; Alt+F4 on the main window. Results: docs/design/gpui-spikes.md.