diff --git a/src/api/constraints.rs b/src/api/constraints.rs new file mode 100644 index 0000000..1beaf6d --- /dev/null +++ b/src/api/constraints.rs @@ -0,0 +1,46 @@ +use crate::*; + +use std::os::raw::*; + +#[no_mangle] +extern "C" fn constraints_border_width(border_width: c_int) -> c_int { + constraints::border_width(border_width) +} + +#[no_mangle] +extern "C" fn constraints_default_clients_in_master( + default_clients_in_master: c_int, +) -> c_int { + constraints::default_clients_in_master(default_clients_in_master) +} + +#[no_mangle] +extern "C" fn constraints_default_master_area_factor( + default_master_area_factor: c_float, +) -> c_float { + constraints::default_master_area_factor(default_master_area_factor) +} + +#[no_mangle] +extern "C" fn constraints_gap_size(gap_size: c_int) -> c_int { + constraints::gap_size(gap_size) +} + +#[no_mangle] +extern "C" fn constraints_master_area_factor( + master_area_factor: c_float, +) -> c_float { + constraints::master_area_factor(master_area_factor) +} + +#[no_mangle] +extern "C" fn constraints_max_clients_in_master( + max_clients_in_master: c_int, +) -> c_int { + constraints::max_clients_in_master(max_clients_in_master) +} + +#[no_mangle] +extern "C" fn constraints_snap_distance(snap_distance: c_uint) -> c_uint { + constraints::snap_distance(snap_distance) +} diff --git a/src/api.rs b/src/api/geom.rs similarity index 52% rename from src/api.rs rename to src/api/geom.rs index 4cbe511..3666968 100644 --- a/src/api.rs +++ b/src/api/geom.rs @@ -2,80 +2,6 @@ use crate::*; use std::os::raw::*; -use ctor::ctor; - -/************ - * Settings * - ************/ - -static mut SETTINGS: Option = None; - -#[ctor] -unsafe fn ctor() { - SETTINGS = Some(Default::default()); -} - -#[no_mangle] -unsafe extern "C" fn settings_get_bar_on_top_by_default() -> bool { - SETTINGS.unwrap().bar_on_top_by_default() -} - -#[no_mangle] -unsafe extern "C" fn settings_set_bar_on_top_by_default(value: bool) { - SETTINGS.unwrap().bar_on_top_by_default_set(value); -} - -/*************** - * Constraints * - ***************/ - -#[no_mangle] -extern "C" fn constraints_border_width(border_width: c_int) -> c_int { - constraints::border_width(border_width) -} - -#[no_mangle] -extern "C" fn constraints_default_clients_in_master( - default_clients_in_master: c_int, -) -> c_int { - constraints::default_clients_in_master(default_clients_in_master) -} - -#[no_mangle] -extern "C" fn constraints_default_master_area_factor( - default_master_area_factor: c_float, -) -> c_float { - constraints::default_master_area_factor(default_master_area_factor) -} - -#[no_mangle] -extern "C" fn constraints_gap_size(gap_size: c_int) -> c_int { - constraints::gap_size(gap_size) -} - -#[no_mangle] -extern "C" fn constraints_master_area_factor( - master_area_factor: c_float, -) -> c_float { - constraints::master_area_factor(master_area_factor) -} - -#[no_mangle] -extern "C" fn constraints_max_clients_in_master( - max_clients_in_master: c_int, -) -> c_int { - constraints::max_clients_in_master(max_clients_in_master) -} - -#[no_mangle] -extern "C" fn constraints_snap_distance(snap_distance: c_uint) -> c_uint { - constraints::snap_distance(snap_distance) -} - -/******** - * Geom * - ********/ - #[no_mangle] unsafe extern "C" fn position_init(position: *mut geom::Position) { *position = Default::default(); diff --git a/src/api/mod.rs b/src/api/mod.rs new file mode 100644 index 0000000..2bef5a4 --- /dev/null +++ b/src/api/mod.rs @@ -0,0 +1,3 @@ +mod constraints; +mod geom; +mod settings; diff --git a/src/api/settings.rs b/src/api/settings.rs new file mode 100644 index 0000000..29d3070 --- /dev/null +++ b/src/api/settings.rs @@ -0,0 +1,20 @@ +use crate::*; + +use ctor::ctor; + +static mut SETTINGS: Option = None; + +#[ctor] +unsafe fn ctor() { + SETTINGS = Some(Default::default()); +} + +#[no_mangle] +unsafe extern "C" fn settings_get_bar_on_top_by_default() -> bool { + SETTINGS.unwrap().bar_on_top_by_default() +} + +#[no_mangle] +unsafe extern "C" fn settings_set_bar_on_top_by_default(value: bool) { + SETTINGS.unwrap().bar_on_top_by_default_set(value); +}