diff --git a/apps/desktop/README.md b/apps/desktop/README.md index 96677d0f..ecfad3d2 100644 --- a/apps/desktop/README.md +++ b/apps/desktop/README.md @@ -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` v2–5, while WSLg advertises v1. diff --git a/apps/desktop/src/main.rs b/apps/desktop/src/main.rs index af5e999f..d4e1c7e5 100644 --- a/apps/desktop/src/main.rs +++ b/apps/desktop/src/main.rs @@ -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(