From a804afb1d3402b0acef7826522e37da87b5f41e5 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 24 Oct 2026 20:25:54 +0000 Subject: [PATCH] docking: a missing DISPLAY also counts as a possible Wayland backend --- crates/ui/src/docking/render/native.rs | 11 +++++++---- docs/ui-docking.md | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/ui/src/docking/render/native.rs b/crates/ui/src/docking/render/native.rs index 4985300d..53b13cc1 100644 --- a/crates/ui/src/docking/render/native.rs +++ b/crates/ui/src/docking/render/native.rs @@ -661,15 +661,18 @@ impl Renderer<'_, P> { #[cfg(debug_assertions)] const REBUILT_FRAMES: usize = 3; -/// Whether winit picks Wayland: `WAYLAND_DISPLAY` or `WAYLAND_SOCKET` is set and not empty. -/// winit reads no variable that forces X11; an app forces it in code -/// (`EventLoopBuilderExtX11::with_x11`), which [`wayland`] tells apart by the window positions. +/// Whether winit may have picked Wayland: `WAYLAND_DISPLAY` or `WAYLAND_SOCKET` is set and not +/// empty, or `DISPLAY` is not, which leaves X11 no server. Connecting to `WAYLAND_SOCKET` unsets +/// it, and this runs after the event loop connected, so a Wayland app started with only that +/// socket is known by its missing `DISPLAY`. winit reads no variable that forces X11; an app +/// forces it in code (`EventLoopBuilderExtX11::with_x11`), which [`wayland`] tells apart by +/// the window positions. fn wayland_display() -> bool { static WAYLAND: std::sync::OnceLock = std::sync::OnceLock::new(); *WAYLAND.get_or_init(|| { let set = |name: &str| std::env::var_os(name).is_some_and(|value| !value.is_empty()); cfg!(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd")) - && (set("WAYLAND_DISPLAY") || set("WAYLAND_SOCKET")) + && (set("WAYLAND_DISPLAY") || set("WAYLAND_SOCKET") || !set("DISPLAY")) }) } diff --git a/docs/ui-docking.md b/docs/ui-docking.md index c010efa2..4a856b74 100644 --- a/docs/ui-docking.md +++ b/docs/ui-docking.md @@ -340,8 +340,8 @@ that is not floatable, stays in-window. Floating windows get no taskbar or Alt-T On Wayland floating windows stay in-window: the compositor reports no window positions, so a native window could not dock again by drag or reopen where it was. Their `native` rects are kept, and the same layout opens native windows on X11, macOS and Windows. The dock area takes -Wayland to be the backend when `WAYLAND_DISPLAY` or `WAYLAND_SOCKET` is set (winit's rule) and -the main window has never reported its `outer_rect`; an app that forces X11 in code gets native +Wayland to be the backend when `WAYLAND_DISPLAY` or `WAYLAND_SOCKET` is set (winit's rule) or +`DISPLAY` is not, and the main window has never reported its `outer_rect`; an app that forces X11 in code gets native windows from the first frame. `DockArea::native_windows(bool)` overrides the choice either way. - **Identity.** `Floating::id` names the OS window, so a window keeps it when its panels change,