Move func "settings_(get|set)_snap_distance" to Rust

This commit is contained in:
Alex Kotov 2022-09-08 23:27:17 +04:00
parent 05513d3435
commit a21e309883
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
5 changed files with 20 additions and 17 deletions

View file

@ -8,8 +8,3 @@ extern "C" fn constraints_master_area_factor(
) -> c_float {
constraints::master_area_factor(master_area_factor)
}
#[no_mangle]
extern "C" fn constraints_snap_distance(snap_distance: c_uint) -> c_uint {
constraints::snap_distance(snap_distance)
}

View file

@ -122,3 +122,13 @@ unsafe extern "C" fn settings_get_show_bar_by_default() -> bool {
unsafe extern "C" fn settings_set_show_bar_by_default(value: bool) {
SETTINGS.unwrap().show_bar_by_default_set(value);
}
#[no_mangle]
unsafe extern "C" fn settings_get_snap_distance() -> c_uint {
SETTINGS.unwrap().snap_distance()
}
#[no_mangle]
unsafe extern "C" fn settings_set_snap_distance(value: c_uint) {
SETTINGS.unwrap().snap_distance_set(value);
}

View file

@ -2,6 +2,5 @@
#define _CONSTRAINTS_H
float constraints_master_area_factor(float master_area_factor);
unsigned int constraints_snap_distance(unsigned int snap_distance);
#endif // _CONSTRAINTS_H

View file

@ -6,7 +6,6 @@ static SettingsForSingleWindow border_for_single_window = SETTINGS_FOR_SINGLE_WI
static SettingsForSingleWindow gap_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
static UnitKind master_area_factor_per_unit = UNIT_MONITOR;
static UnitKind show_bar_per_unit = UNIT_MONITOR;
static unsigned int snap_distance = 32;
static bool swallow_floating = false;
SettingsForSingleWindow settings_get_border_for_single_window()
@ -53,16 +52,6 @@ void settings_set_show_bar_per_unit(const UnitKind new_show_bar_per_unit)
// TODO: notify WM to rearrange clients
}
unsigned int settings_get_snap_distance()
{
return snap_distance;
}
void settings_set_snap_distance(unsigned int new_snap_distance)
{
snap_distance = constraints_snap_distance(new_snap_distance);
}
bool settings_get_swallow_floating()
{
return swallow_floating;

View file

@ -14,6 +14,7 @@ pub struct Settings {
max_clients_in_master: Option<c_int>,
respect_resize_hints_in_floating_layout: bool,
show_bar_by_default: bool,
snap_distance: c_uint,
}
impl Default for Settings {
@ -29,6 +30,7 @@ impl Default for Settings {
max_clients_in_master: None,
respect_resize_hints_in_floating_layout: false,
show_bar_by_default: true,
snap_distance: 32,
}
}
}
@ -120,4 +122,12 @@ impl Settings {
pub fn show_bar_by_default_set(&mut self, value: bool) {
self.show_bar_by_default = value;
}
pub fn snap_distance(&self) -> c_uint {
self.snap_distance
}
pub fn snap_distance_set(&mut self, value: c_uint) {
self.snap_distance = constraints::snap_distance(value);
}
}