diff --git a/src/backend/mod.rs b/src/backend/mod.rs index f1abd15..d16353b 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -1,3 +1,4 @@ +#[cfg(not(target_os = "macos"))] pub mod x11; #[cfg(not(target_os = "macos"))] @@ -15,6 +16,7 @@ pub trait Backend { pub enum DisplayServer { #[cfg(not(target_os = "macos"))] Wayland, + #[cfg(not(target_os = "macos"))] X11, #[cfg(target_os = "macos")] MacOs, @@ -25,21 +27,24 @@ pub fn detect() -> anyhow::Result { return Ok(DisplayServer::MacOs); #[cfg(not(target_os = "macos"))] - if std::env::var("WAYLAND_DISPLAY").is_ok() { - return Ok(DisplayServer::Wayland); - } - - if std::env::var("DISPLAY").is_ok() { - return Ok(DisplayServer::X11); + { + if std::env::var("WAYLAND_DISPLAY").is_ok() { + return Ok(DisplayServer::Wayland); + } + if std::env::var("DISPLAY").is_ok() { + return Ok(DisplayServer::X11); + } + anyhow::bail!( + "no display found: neither WAYLAND_DISPLAY nor DISPLAY is set" + ) } - - anyhow::bail!("no display found: neither WAYLAND_DISPLAY nor DISPLAY is set") } pub fn build() -> anyhow::Result> { match detect()? { #[cfg(not(target_os = "macos"))] DisplayServer::Wayland => Ok(Box::new(wayland::WaylandBackend)), + #[cfg(not(target_os = "macos"))] DisplayServer::X11 => Ok(Box::new(x11::X11Backend::new()?)), #[cfg(target_os = "macos")] DisplayServer::MacOs => Ok(Box::new(macos::MacOsBackend)),