From 7994c0212b0c43ea13d761675913a1d71815bfea Mon Sep 17 00:00:00 2001 From: selikhov Date: Sat, 3 Oct 2026 01:56:31 +0300 Subject: [PATCH] Take screenshots on the Xvfb server, not on the Wayland desktop winit prefers Wayland when WAYLAND_DISPLAY is set, so `xvfb-run` in a Wayland session still opened the window on the desktop, where the compositor chose its size. That looked like the X server ignoring the requested size. Remove the variable for the screenshot run, and size the Xvfb screen like the window. Co-Authored-By: Claude Opus 5.5 --- crates/voelin-ui/src/dev.rs | 3 ++- docs/ui.md | 15 ++++++++++----- scripts/shots.sh | 20 ++++++++++++-------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/crates/voelin-ui/src/dev.rs b/crates/voelin-ui/src/dev.rs index 6847cbc..6d861c0 100644 --- a/crates/voelin-ui/src/dev.rs +++ b/crates/voelin-ui/src/dev.rs @@ -167,7 +167,8 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running { } } // A window manager can refuse the size set before the window opened, - // so ask again once it is up (a bare X server ignores both). + // so ask again once it is up. (Under `xvfb-run` in a Wayland session, + // remove WAYLAND_DISPLAY, or winit opens the window on the desktop.) let resize = switches.window_size.map(|(w, h)| { let weak = ui.as_weak(); let timer = slint::Timer::default(); diff --git a/docs/ui.md b/docs/ui.md index d055ead..0861134 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -187,14 +187,19 @@ Environment variables (see `src/dev.rs`): `VOELIN_AUTOSHARE`, `VOELIN_DATA_DIR` as before. ```sh -SLINT_BACKEND=winit-software VOELIN_DATA_DIR=$(mktemp -d) VOELIN_DEMO_UI=1 \ -VOELIN_OPEN=settings:appearance VOELIN_WINDOW_SIZE=1440x960 \ +scripts/shots.sh shot.png settings:appearance 1440x960 +# which runs, headless: +env -u WAYLAND_DISPLAY SLINT_BACKEND=winit-software VOELIN_DATA_DIR=$(mktemp -d) \ +VOELIN_DEMO_UI=1 VOELIN_OPEN=settings:appearance VOELIN_WINDOW_SIZE=1440x960 \ VOELIN_SCREENSHOT=shot.png VOELIN_SCREENSHOT_DELAY=4 \ -xvfb-run -a -s "-screen 0 1600x1100x24" target/debug/voelin +xvfb-run -a -s "-screen 0 1440x960x24" target/debug/voelin ``` -The pictures in `docs/screenshots/` were made this way (reduced to 256 -colours with `convert -colors 256 PNG8:`). +Remove `WAYLAND_DISPLAY` as above in a Wayland session: winit prefers +Wayland, so the window would open on the desktop instead of on the Xvfb +server (and take whatever size the compositor gives it). The pictures in +`docs/screenshots/` were made this way (reduced to 256 colours with +`convert -colors 256 PNG8:`). | Desktop | | |---|---| diff --git a/scripts/shots.sh b/scripts/shots.sh index 443ec96..f42da97 100755 --- a/scripts/shots.sh +++ b/scripts/shots.sh @@ -5,16 +5,20 @@ # # The pictures in docs/screenshots/ are made this way (and reduced to 256 # colours with `convert -colors 256 PNG8:`). +# +# WAYLAND_DISPLAY is removed so the window opens on the Xvfb server and not +# on the desktop of a Wayland session (winit prefers Wayland when it can). set -eu out=$1 open=$2 size=${3:-1440x960} bin=${VOELIN_BIN:-$CARGO_TARGET_DIR/debug/voelin} -SLINT_BACKEND=winit-software \ -VOELIN_DATA_DIR=$(mktemp -d) \ -VOELIN_DEMO_UI=1 \ -VOELIN_OPEN="$open" \ -VOELIN_WINDOW_SIZE="$size" \ -VOELIN_SCREENSHOT="$out" \ -VOELIN_SCREENSHOT_DELAY="${DELAY:-4}" \ - xvfb-run -a -s "-screen 0 1920x1200x24" "$bin" >/dev/null 2>&1 +env -u WAYLAND_DISPLAY \ + SLINT_BACKEND=winit-software \ + VOELIN_DATA_DIR="$(mktemp -d)" \ + VOELIN_DEMO_UI=1 \ + VOELIN_OPEN="$open" \ + VOELIN_WINDOW_SIZE="$size" \ + VOELIN_SCREENSHOT="$out" \ + VOELIN_SCREENSHOT_DELAY="${DELAY:-4}" \ + xvfb-run -a -s "-screen 0 ${size}x24" "$bin" >/dev/null 2>&1