Skip to content

feat(window): rune::displays() reads the current displays while running - #2209

Merged
opencodejr[bot] merged 1 commit into
devfrom
bot/issue-146
Nov 25, 2026
Merged

opencodejr[bot] merged 1 commit into
devfrom
bot/issue-146

Conversation

@opencodejr

@opencodejr opencodejr Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Part of #146: the first ask, a display query that works while the app runs. It does not close the issue. Still open: a display-change callback (ask 2, which needs native hooks on macOS, Windows, X11 and Wayland), ConfiguredOverlay overlays created after run, a Tx/AppHandle form of the query, and the issue's 'Done when'.

  • New rune::displays() -> Vec<Display> (crates/rune/src/window/displays.rs). Called on the UI thread, it reads monitors from the first open native window (winit's Window::available_monitors and primary_monitor; Window also provides the display handle for the Wayland output query). It returns the fields a run_windows factory gets, so an app can find a monitor plugged in after launch and open_window a WindowOptions::overlay on it.
  • No unsafe code. Each native window Rune creates is recorded as a Weak<Window>: main windows in window/host/create.rs, overlays in overlay/lifetime.rs, the web canvas in platform/web.rs. A small Monitors trait implemented for ActiveEventLoop and Window lets the factory's startup list (moved out of resumed) and displays() share one reading path, including the Wayland output resolution.
  • With no window open (a tray-only app, headless runs) it returns the list last read. Headless runs, both the single-window and multi-window paths, save their virtual desktop at start. reset() clears the saved windows and the list at the start of every native and headless run, so one run never sees the previous run's displays. On another thread the list is empty.
  • Changelog entry, a README paragraph, and unit tests for the no-window fallback and for reset() (window/displays_tests.rs).

Testing: not compiled or run. The environment that made this change had no Rust toolchain, so cargo check --workspace --all-targets, cargo lint and cargo test -p rune still need to run. scripts/file-size.sh passes and the public-repo hygiene grep is clean. Nothing was tried with a monitor plugged in or removed. Whether a new monitor appears depends on winit's Window::available_monitors() returning current monitors on each platform, which needs checking on X11 and Wayland in particular.

Closes #146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Displays: the list is a startup snapshot, with no change event and no way to add a window later

0 participants