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

This commit is contained in:
Alex Kotov 2022-09-08 16:08:33 +04:00
parent 817fb2ee1b
commit 2687238a01
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 20 additions and 12 deletions

View file

@ -50,3 +50,13 @@ unsafe extern "C" fn settings_get_default_master_area_factor() -> c_float {
unsafe extern "C" fn settings_set_default_master_area_factor(value: c_float) {
SETTINGS.unwrap().default_master_area_factor_set(value);
}
#[no_mangle]
unsafe extern "C" fn settings_get_enable_swallowing() -> bool {
SETTINGS.unwrap().enable_swallowing()
}
#[no_mangle]
unsafe extern "C" fn settings_set_enable_swallowing(value: bool) {
SETTINGS.unwrap().enable_swallowing_set(value);
}

View file

@ -4,7 +4,6 @@
static SettingsForSingleWindow border_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
static SettingsForSingleWindow gap_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
static bool enable_swallowing = true;
static bool focus_on_wheel = true;
static int gap_size = 10;
static UnitKind master_area_factor_per_unit = UNIT_MONITOR;
@ -37,17 +36,6 @@ void settings_set_gap_for_single_window(const SettingsForSingleWindow new_gap_fo
// TODO: notify WM to rearrange clients
}
bool settings_get_enable_swallowing()
{
return enable_swallowing;
}
void settings_set_enable_swallowing(const bool new_enable_swallowing)
{
enable_swallowing = new_enable_swallowing;
}
bool settings_get_focus_on_wheel()
{
return focus_on_wheel;

View file

@ -8,6 +8,7 @@ pub struct Settings {
border_width: c_int,
default_clients_in_master: c_int,
default_master_area_factor: c_float,
enable_swallowing: bool,
}
impl Default for Settings {
@ -17,6 +18,7 @@ impl Default for Settings {
border_width: 2,
default_clients_in_master: 1,
default_master_area_factor: 0.6,
enable_swallowing: true,
}
}
}
@ -56,4 +58,12 @@ impl Settings {
self.default_master_area_factor =
constraints::default_master_area_factor(value);
}
pub fn enable_swallowing(&self) -> bool {
self.enable_swallowing
}
pub fn enable_swallowing_set(&mut self, value: bool) {
self.enable_swallowing = value;
}
}