Files
zed/crates/gpui_linux/src/linux.rs
T
Zax71andTom Houlé dae3e574e4 gpui_linux: Improve error message when X11 and Wayland feature flags are missing (#58685)
Improves `gpui_linux` error messages for missing feature flags.
Currently, you'd need to look at the source & Rust backtrace to diagnose
the error shown when the feature flags are missing.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable


Release Notes:

- Improve `gpui_linux` error messages for missing feature flags

---------

Co-authored-by: Tom Houlé <tom@tomhoule.com>
2026-06-25 16:28:21 +00:00

60 lines
1.5 KiB
Rust

mod dispatcher;
mod headless;
mod keyboard;
mod platform;
#[cfg(any(feature = "wayland", feature = "x11"))]
mod text_system;
#[cfg(feature = "wayland")]
mod wayland;
#[cfg(feature = "x11")]
mod x11;
#[cfg(any(feature = "wayland", feature = "x11"))]
mod xdg_desktop_portal;
pub use dispatcher::*;
pub(crate) use headless::*;
pub(crate) use keyboard::*;
pub(crate) use platform::*;
#[cfg(any(feature = "wayland", feature = "x11"))]
pub(crate) use text_system::*;
#[cfg(feature = "wayland")]
pub(crate) use wayland::*;
#[cfg(feature = "x11")]
pub(crate) use x11::*;
use std::rc::Rc;
/// Returns the default platform implementation for the current OS.
pub fn current_platform(headless: bool) -> Rc<dyn gpui::Platform> {
#[cfg(feature = "x11")]
use anyhow::Context as _;
if headless {
return Rc::new(LinuxPlatform {
inner: HeadlessClient::new(),
});
}
match gpui::guess_compositor() {
#[cfg(feature = "wayland")]
"Wayland" => Rc::new(LinuxPlatform {
inner: WaylandClient::new(),
}),
#[cfg(feature = "x11")]
"X11" => Rc::new(LinuxPlatform {
inner: X11Client::new()
.context("Failed to initialize X11 client.")
.unwrap(),
}),
"Headless" => Rc::new(LinuxPlatform {
inner: HeadlessClient::new(),
}),
_ => unreachable!(
r#"At least one of the "wayland" or "x11" features must be enabled on gpui_linux or gpui_platform."#
),
}
}