docking: a missing DISPLAY also counts as a possible Wayland backend

This commit is contained in:
aiongg committed 2026-10-24 20:25:54 +00:00
1 parent e56639ebb8
commit a804afb1d3
2 files changed
+9 -6

No files matched your search

+7 -4
View File
@@ -661,15 +661,18 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> 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<bool> = 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"))
})
}
+2 -2
View File
@@ -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,