Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FreeBSD #125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ core-foundation = {version = "0.7"}
core-foundation-sys = {version = "0.7"}


[target.'cfg(target_os = "linux")'.dependencies]
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
libc = "0.2"
x11 = {version = "2.18", features = ["xlib", "xrecord", "xinput"]}
evdev-rs = {version = "0.4.0", optional=true}
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ pub use crate::macos::Keyboard;
#[cfg(target_os = "macos")]
use crate::macos::{display_size as _display_size, listen as _listen, simulate as _simulate};

#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "linux")]
pub use crate::linux::Keyboard;
#[cfg(target_os = "linux")]
use crate::linux::{display_size as _display_size, listen as _listen, simulate as _simulate};
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
mod x11;
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub use crate::x11::Keyboard;
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
use crate::x11::{display_size as _display_size, listen as _listen, simulate as _simulate};

#[cfg(target_os = "windows")]
mod windows;
Expand Down Expand Up @@ -322,8 +322,8 @@ pub fn display_size() -> Result<(u64, u64), DisplayError> {
}

#[cfg(feature = "unstable_grab")]
#[cfg(target_os = "linux")]
pub use crate::linux::grab as _grab;
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub use crate::x11::grab as _grab;
#[cfg(feature = "unstable_grab")]
#[cfg(target_os = "macos")]
pub use crate::macos::grab as _grab;
Expand Down
18 changes: 0 additions & 18 deletions src/linux/mod.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/linux/common.rs → src/x11/common.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::linux::keyboard::Keyboard;
use crate::linux::keycodes::key_from_code;
use crate::x11::keyboard::Keyboard;
use crate::x11::keycodes::key_from_code;
use crate::rdev::{Button, Event, EventType, KeyboardState};
use std::convert::TryInto;
use std::os::raw::{c_int, c_uchar, c_uint};
Expand Down
2 changes: 1 addition & 1 deletion src/linux/display.rs → src/x11/display.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::linux::common::Display;
use crate::x11::common::Display;
use crate::rdev::DisplayError;

pub fn display_size() -> Result<(u64, u64), DisplayError> {
Expand Down
4 changes: 2 additions & 2 deletions src/linux/grab.rs → src/x11/grab.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::linux::common::Display;
use crate::linux::keyboard::Keyboard;
use crate::x11::common::Display;
use crate::x11::keyboard::Keyboard;
use crate::rdev::{Button, Event, EventType, GrabError, Key, KeyboardState};
use epoll::ControlOptions::{EPOLL_CTL_ADD, EPOLL_CTL_DEL};
use evdev_rs::{
Expand Down
2 changes: 1 addition & 1 deletion src/linux/keyboard.rs → src/x11/keyboard.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate x11;
use crate::linux::keycodes::code_from_key;
use crate::x11::keycodes::code_from_key;
use crate::rdev::{EventType, Key, KeyboardState};
use std::ffi::CString;
use std::os::raw::{c_char, c_int, c_uint, c_ulong, c_void};
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/linux/listen.rs → src/x11/listen.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate libc;
extern crate x11;
use crate::linux::common::{convert, FALSE, KEYBOARD};
use crate::linux::keyboard::Keyboard;
use crate::x11::common::{convert, FALSE, KEYBOARD};
use crate::x11::keyboard::Keyboard;
use crate::rdev::{Event, ListenError};
use std::convert::TryInto;
use std::ffi::CStr;
Expand Down
18 changes: 18 additions & 0 deletions src/x11/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extern crate libc;
extern crate x11;

mod common;
mod display;
#[cfg(feature = "unstable_grab")]
mod grab;
mod keyboard;
mod keycodes;
mod listen;
mod simulate;

pub use crate::x11::display::display_size;
#[cfg(feature = "unstable_grab")]
pub use crate::x11::grab::grab;
pub use crate::x11::keyboard::Keyboard;
pub use crate::x11::listen::listen;
pub use crate::x11::simulate::simulate;
4 changes: 2 additions & 2 deletions src/linux/simulate.rs → src/x11/simulate.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::linux::common::{FALSE, TRUE};
use crate::linux::keycodes::code_from_key;
use crate::x11::common::{FALSE, TRUE};
use crate::x11::keycodes::code_from_key;
use crate::rdev::{Button, EventType, SimulateError};
use std::convert::TryInto;
use std::os::raw::c_int;
Expand Down