Skip to content

Commit babbb7e

Browse files
yurivictprokopyl
authored andcommitted
Add FreeBSD support
1 parent 9424f0b commit babbb7e

6 files changed

Lines changed: 19 additions & 4 deletions

File tree

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ polling = "3.11.0"
4242
percent-encoding = "2.3.1"
4343
bytemuck = "1.15.0"
4444

45+
[target.'cfg(target_os="freebsd")'.dependencies]
46+
xcb = { version = "0.9", features = ["thread", "xlib_xcb", "dri2"] }
47+
x11 = { version = "2.18", features = ["xlib", "xcursor"] }
48+
xcb-util = { version = "0.3", features = ["icccm"] }
49+
nix = "0.22.0"
50+
4551
[target.'cfg(target_os="windows")'.dependencies]
4652
# Later versions of the windows crates need MSRV 1.80
4753
windows = { version = "=0.61.3", features = [

src/gl/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ pub(crate) mod x11;
1313
#[cfg(target_os = "linux")]
1414
pub(crate) use self::x11 as platform;
1515

16+
#[cfg(target_os = "freebsd")]
17+
pub(crate) mod x11;
18+
#[cfg(target_os = "freebsd")]
19+
pub(crate) use self::x11 as platform;
20+
1621
#[cfg(target_os = "macos")]
1722
mod macos;
1823
#[cfg(target_os = "macos")]
@@ -93,7 +98,7 @@ impl GlContext {
9398
/// The X11 version needs to be set up in a different way compared to the Windows and macOS
9499
/// versions. So the platform-specific versions should be used to construct the context within
95100
/// baseview, and then this object can be passed to the user.
96-
#[cfg(target_os = "linux")]
101+
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
97102
pub(crate) fn new(context: platform::GlContext) -> GlContext {
98103
GlContext { context: AssertUnwindSafe(context), phantom: PhantomData }
99104
}

src/keyboard.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
//! Keyboard types.
1919
20-
#[cfg(any(target_os = "linux", target_os = "macos"))]
20+
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
2121
use keyboard_types::{Code, Location};
2222

23-
#[cfg(any(target_os = "linux", target_os = "macos"))]
23+
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
2424
/// Map key code to location.
2525
///
2626
/// The logic for this is adapted from InitKeyEvent in TextInputHandler (in the Mozilla

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ mod macos;
44
mod win;
55
#[cfg(target_os = "linux")]
66
pub(crate) mod x11;
7+
#[cfg(target_os = "freebsd")]
8+
mod x11;
79

810
mod clipboard;
911
mod event;

src/window.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use crate::macos as platform;
1414
use crate::win as platform;
1515
#[cfg(target_os = "linux")]
1616
use crate::x11 as platform;
17+
#[cfg(target_os = "freebsd")]
18+
use crate::x11 as platform;
1719

1820
pub struct WindowHandle {
1921
window_handle: platform::WindowHandle,

src/x11/keyboard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fn code_to_key(code: Code, m: Modifiers) -> Key {
201201
}
202202
}
203203

204-
#[cfg(target_os = "linux")]
204+
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
205205
/// Map hardware keycode to code.
206206
///
207207
/// In theory, the hardware keycode is device dependent, but in

0 commit comments

Comments
 (0)