From 0c20986b848a1116d12092ff65545930e5620d5d Mon Sep 17 00:00:00 2001 From: x71c9 <108585118+x71c9@users.noreply.github.com> Date: Tue, 30 Jun 2026 16:01:11 +0200 Subject: [PATCH] fix: do not compile x11 in macos --- src/backend/mod.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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)),