diff --git a/Cargo.toml b/Cargo.toml index 534fb563..5d52543b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ opengl = [ keyboard-types = { version = "0.6.1", default-features = false } raw-window-handle = "0.5" -[target.'cfg(target_os="linux")'.dependencies] +[target.'cfg(any(target_os="linux", target_os="freebsd"))'.dependencies] x11rb = { version = "0.13.2", features = ["cursor", "resource_manager", "allow-unsafe-code", "dl-libxcb"], default-features = false } x11-dl = { version = "2.21" } polling = "3.11.0" diff --git a/src/clipboard.rs b/src/clipboard.rs index c4f7bc4b..eda3e233 100644 --- a/src/clipboard.rs +++ b/src/clipboard.rs @@ -4,6 +4,8 @@ use crate::macos as platform; use crate::win as platform; #[cfg(target_os = "linux")] use crate::x11 as platform; +#[cfg(target_os = "freebsd")] +use crate::x11 as platform; pub fn copy_to_clipboard(data: &str) { platform::copy_to_clipboard(data) diff --git a/src/gl/mod.rs b/src/gl/mod.rs index 34720290..6571b8f6 100644 --- a/src/gl/mod.rs +++ b/src/gl/mod.rs @@ -13,6 +13,11 @@ pub(crate) mod x11; #[cfg(target_os = "linux")] pub(crate) use self::x11 as platform; +#[cfg(target_os = "freebsd")] +pub(crate) mod x11; +#[cfg(target_os = "freebsd")] +pub(crate) use self::x11 as platform; + #[cfg(target_os = "macos")] mod macos; #[cfg(target_os = "macos")] @@ -93,7 +98,7 @@ impl GlContext { /// The X11 version needs to be set up in a different way compared to the Windows and macOS /// versions. So the platform-specific versions should be used to construct the context within /// baseview, and then this object can be passed to the user. - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "freebsd"))] pub(crate) fn new(context: platform::GlContext) -> GlContext { GlContext { context: AssertUnwindSafe(context), phantom: PhantomData } } diff --git a/src/keyboard.rs b/src/keyboard.rs index c56abd3d..27e3c062 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -17,10 +17,10 @@ //! Keyboard types. -#[cfg(any(target_os = "linux", target_os = "macos"))] +#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))] use keyboard_types::{Code, Location}; -#[cfg(any(target_os = "linux", target_os = "macos"))] +#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))] /// Map key code to location. /// /// The logic for this is adapted from InitKeyEvent in TextInputHandler (in the Mozilla diff --git a/src/lib.rs b/src/lib.rs index 29a7129a..ac5d36a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,8 @@ mod macos; mod win; #[cfg(target_os = "linux")] pub(crate) mod x11; +#[cfg(target_os = "freebsd")] +mod x11; mod clipboard; mod event; diff --git a/src/window.rs b/src/window.rs index 25b53d1e..6269cbc3 100644 --- a/src/window.rs +++ b/src/window.rs @@ -14,6 +14,8 @@ use crate::macos as platform; use crate::win as platform; #[cfg(target_os = "linux")] use crate::x11 as platform; +#[cfg(target_os = "freebsd")] +use crate::x11 as platform; pub struct WindowHandle { window_handle: platform::WindowHandle, diff --git a/src/wrappers.rs b/src/wrappers.rs index d06a6d8b..20ceafdf 100644 --- a/src/wrappers.rs +++ b/src/wrappers.rs @@ -12,14 +12,14 @@ //! Otherwise, this should be considered a bug and reported accordingly. /// Wrappers and utilities around Xlib. (provided by x11_dl) -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "freebsd"))] pub mod xlib; /// Wrappers and utilities around GLX -#[cfg(all(target_os = "linux", feature = "opengl"))] +#[cfg(all(any(target_os = "linux", target_os = "freebsd"), feature = "opengl"))] pub mod glx; -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "freebsd"))] pub mod connection_poller; /// Wrappers and utilities around the Win32 API diff --git a/src/x11/keyboard.rs b/src/x11/keyboard.rs index 634a205a..12312ebc 100644 --- a/src/x11/keyboard.rs +++ b/src/x11/keyboard.rs @@ -201,7 +201,7 @@ fn code_to_key(code: Code, m: Modifiers) -> Key { } } -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "freebsd"))] /// Map hardware keycode to code. /// /// In theory, the hardware keycode is device dependent, but in