fix(desktop): fall back to XWayland under WSL2

This commit is contained in:
Maze Winther 2026-07-24 14:14:47 +02:00
parent 96cad76ed2
commit cef8766acb
2 changed files with 21 additions and 0 deletions

View File

@ -22,3 +22,4 @@ The first build compiles GPUI from source and takes a while. The root `Cargo.loc
- **macOS**: Xcode command line tools (Metal renderer).
- **Windows**: no extra dependencies (Win32 + DirectWrite).
- **Linux**: renders via Vulkan (Blade), windows via Wayland or X11 (both enabled by default). System packages (Debian/Ubuntu names): `libvulkan1` + working Vulkan drivers, `libwayland-dev`, `libx11-xcb-dev`, `libxkbcommon-x11-dev`, `libfontconfig-dev`, plus a C toolchain and `cmake`.
- **WSL2/WSLg**: uses XWayland automatically when available. GPUI 0.2.2 requires `xdg_wm_base` v25, while WSLg advertises v1.

View File

@ -35,6 +35,26 @@ impl Render for Root {
}
fn main() {
#[cfg(target_os = "linux")]
{
let is_wsl = std::fs::read_to_string("/proc/sys/kernel/osrelease")
.is_ok_and(|release| release.to_ascii_lowercase().contains("microsoft"));
let x11_configured =
std::env::var_os("DISPLAY").is_some_and(|display| !display.is_empty());
let wayland_configured =
std::env::var_os("WAYLAND_DISPLAY").is_some_and(|display| !display.is_empty());
if is_wsl && x11_configured && wayland_configured {
// GPUI 0.2.2 requires xdg_wm_base v2+, while current WSLg advertises v1 and panics.
// Safety: this is the first statement in `main`, before GPUI or anything
// else has spawned a thread. No other thread exists yet, so keep this
// block first if anything is added above it.
unsafe {
std::env::remove_var("WAYLAND_DISPLAY");
}
}
}
Application::new().run(|cx: &mut App| {
let bounds = Bounds::centered(None, size(px(960.), px(600.)), cx);
cx.open_window(