You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Displays: the list is a startup snapshot, with no change event and no way to add a window later #146
An app sees the displays once, in the window factory at startup. After that it cannot read the current display list, is not told when a monitor is added, removed or changes scale, and cannot create a new window or overlay. An app that needs one window per monitor (a screenshot region selector, a presentation app, a per-monitor bar) cannot follow a monitor that is plugged in after launch.
app.rs#L248-L268: App::overlay and App::window take &mut self before run, so windows and overlays are fixed at startup.
I found no public display query on AppHandle, Tx or Cx, and no display-change callback.
Asks
A display query that works while running, for example AppHandle::displays() -> Vec<Display> (and on Tx), with the same fields as the factory gets.
A callback when the set of displays or their geometry or scale changes, for example App::on_displays_changed(fn(&mut S, &[Display], &mut Tx)). winit has no monitor event; the platforms do (macOS NSApplicationDidChangeScreenParametersNotification, Windows WM_DISPLAYCHANGE, Wayland wl_output globals added or removed, X11 RandR RRScreenChangeNotify).
A way to open a new window or overlay after run, for example from Tx with a WindowSpec or ConfiguredOverlay.
Our workaround
We create the per-monitor overlay windows at startup from the factory's list, plus two extra hidden windows. When a capture starts, we place a spare on a monitor that has no window with AppHandle::place(DisplayTarget::Native(..), FullScreen). Our monitor list comes from our capture library, not from Rune. A third new monitor gets no overlay. Our test VM has one monitor, so we did not test hotplug; this is from the code.
Done when: an app can read the current displays while running, gets a callback within one second of a monitor being added or removed on macOS, Windows, X11 and Wayland, and can open a full-screen overlay on the new monitor without a restart.
A cost number for the workaround in this issue. Because windows can only be made at startup, our app makes two spare hidden full-screen overlay windows for monitors plugged in later. On macOS each never-shown spare holds about 4 MB of GPU memory.
macOS 26.6 VM (paravirtual Metal GPU), Rune 7ead7d63, our app idle with its main window shown, footprint -v 4 s after the first frame, 3 launches per side:
The spares never show, never draw and never get a drawable; the untagged CPU memory is the same (34 MB) in both. We did not trace which texture each spare makes. With a way to add a window after run (ask 3 here), the app would make an overlay only when a monitor comes, and these 8 MB would go.
Outputs come from wl_output globals on a private queue. One thread, only while a hook is set, asleep in poll, with no timers.
AppHandle::overlay works after run. The overlay is built on the next loop turn, but the handle is usable at once (show, update and close queue until then).
close hides the overlay, releases its GPU surface and drops its host. Dropping a handle doesn't close it, so an app has to close an output's overlays when the output goes.
Trap: Display::name is empty for a headless output on Hyprland, so key by id.
Tested with 50 headless output add/removes on Hyprland: every bar came back, and memory stayed flat after warm-up.
Thanks for the detailed write-up and the memory numbers for the spare windows.
Where each ask stands on dev today:
Reading displays while running: still missing. The list is built from available_monitors() once in resumed (window.rs) and only the factory gets it. I found no query on AppHandle, Tx or Cx.
A display-change callback: still missing. App::on_display_close exists, but it only fires once when the display connection shuts down. It does not report monitors being added, removed or changing scale.
Opening a window after run: partly there. rune::open_window(WindowSpec) opens a window from the UI thread (a handler, an update, on_ready). It starts at the end of the turn and returns a WindowHandle. With WindowOptions::overlay(&display) that window is a transparent, borderless, topmost, click-through cover over one display, which might replace your hidden spares for the window case. ConfiguredOverlay overlays (App::overlay) can still only be made before run.
We'll treat this as a feature request: a display query, a change callback on macOS, Windows, X11 and Wayland, and overlays that can be created and closed after run. @purian23, thanks for the notes on your Wayland version: the API shape, the wl_output thread that only runs while a hook is set, and keying by id because Display::name can be empty on Hyprland. They're useful input.
I updated the PR for part of this issue: rune::displays(), called on the UI thread, returns the current displays with the same fields the factory gets. A headless run now returns the displays from its --script, the same ones its place() uses.
Opening a window on a new monitor already works with rune::windows::open_window and WindowOptions::overlay(&display), so the query is what was missing for that. The PR has not been compiled or tested yet, and nothing was tried with a real monitor being plugged in.
Still open: a callback when displays change, and the query on AppHandle/Tx. Until there is a callback, an app has to call displays() when it needs the list, for example when a capture starts.
A result from an app, for the "open a window after run" part. Our screenshot app kept two spare hidden overlay windows for monitors that come after launch. We removed them. When a capture finds a monitor with no overlay, the app now calls rune::open_window with the same WindowSpec (WindowSpec::from_app with configured_options), and places it with AppHandle::place in the same turn.
Tested on devdacf5d89 in a macOS 26.6 VM. The VM has one monitor, so a test build opened no overlay at launch and opened each one at the first capture. Region and window captures worked (2 runs, 0 errors; region overlay on screen in 25 to 45 ms, window overlay in 6 to 9 ms). Memory without the two spares: 1.0 to 1.1 MB less in each state (5 runs per side, p = 0.008 to 0.03). On 7ead7d63 each spare cost about 4 MB, so dev already made a never-shown window cheaper.
We did not test a real monitor plugged in at runtime.
Activity
godismyjudge95 commentedon Nov 6, 2026
Related:
DisplayTarget::IdandDisplayTarget::Native. Per-monitor overlays on GNOME need both fixes.Posted via Claude
godismyjudge95 commentedon Nov 6, 2026
A cost number for the workaround in this issue. Because windows can only be made at startup, our app makes two spare hidden full-screen overlay windows for monitors plugged in later. On macOS each never-shown spare holds about 4 MB of GPU memory.
macOS 26.6 VM (paravirtual Metal GPU), Rune
7ead7d63, our app idle with its main window shown,footprint -v4 s after the first frame, 3 launches per side:The spares never show, never draw and never get a drawable; the untagged CPU memory is the same (34 MB) in both. We did not trace which texture each spare makes. With a way to add a window after
run(ask 3 here), the app would make an overlay only when a monitor comes, and these 8 MB would go.Posted via Claude
purian23 commentedon Nov 12, 2026
We built the Wayland half of this for a desktop shell (a bar per output that comes and goes with monitors):
wl_outputglobals on a private queue. One thread, only while a hook is set, asleep inpoll, with no timers.AppHandle::overlayworks afterrun. The overlay is built on the next loop turn, but the handle is usable at once (show,updateandclosequeue until then).closehides the overlay, releases its GPU surface and drops its host. Dropping a handle doesn't close it, so an app has to close an output's overlays when the output goes.Display::nameis empty for a headless output on Hyprland, so key by id.Tested with 50 headless output add/removes on Hyprland: every bar came back, and memory stayed flat after warm-up.
opencodejr commentedon Nov 25, 2026
Thanks for the detailed write-up and the memory numbers for the spare windows.
Where each ask stands on
devtoday:available_monitors()once inresumed(window.rs) and only the factory gets it. I found no query onAppHandle,TxorCx.App::on_display_closeexists, but it only fires once when the display connection shuts down. It does not report monitors being added, removed or changing scale.run: partly there.rune::open_window(WindowSpec)opens a window from the UI thread (a handler, an update,on_ready). It starts at the end of the turn and returns aWindowHandle. WithWindowOptions::overlay(&display)that window is a transparent, borderless, topmost, click-through cover over one display, which might replace your hidden spares for the window case.ConfiguredOverlayoverlays (App::overlay) can still only be made beforerun.We'll treat this as a feature request: a display query, a change callback on macOS, Windows, X11 and Wayland, and overlays that can be created and closed after
run. @purian23, thanks for the notes on your Wayland version: the API shape, thewl_outputthread that only runs while a hook is set, and keying by id becauseDisplay::namecan be empty on Hyprland. They're useful input.opencodejr commentedon Nov 25, 2026
I updated the PR for part of this issue:
rune::displays(), called on the UI thread, returns the current displays with the same fields the factory gets. A headless run now returns the displays from its--script, the same ones itsplace()uses.Opening a window on a new monitor already works with
rune::windows::open_windowandWindowOptions::overlay(&display), so the query is what was missing for that. The PR has not been compiled or tested yet, and nothing was tried with a real monitor being plugged in.Still open: a callback when displays change, and the query on
AppHandle/Tx. Until there is a callback, an app has to calldisplays()when it needs the list, for example when a capture starts.Fixed in #2209.
godismyjudge95 commentedon Nov 27, 2026
A result from an app, for the "open a window after run" part. Our screenshot app kept two spare hidden overlay windows for monitors that come after launch. We removed them. When a capture finds a monitor with no overlay, the app now calls
rune::open_windowwith the sameWindowSpec(WindowSpec::from_appwithconfigured_options), and places it withAppHandle::placein the same turn.Tested on
devdacf5d89in a macOS 26.6 VM. The VM has one monitor, so a test build opened no overlay at launch and opened each one at the first capture. Region and window captures worked (2 runs, 0 errors; region overlay on screen in 25 to 45 ms, window overlay in 6 to 9 ms). Memory without the two spares: 1.0 to 1.1 MB less in each state (5 runs per side, p = 0.008 to 0.03). On7ead7d63each spare cost about 4 MB, sodevalready made a never-shown window cheaper.We did not test a real monitor plugged in at runtime.
Posted via Claude