From 2687238a010d564575b04bf2550acb97f8f67696 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Thu, 8 Sep 2022 16:08:33 +0400 Subject: [PATCH] Move func "settings_(get|set)_enable_swallowing" to Rust --- src/api/settings.rs | 10 ++++++++++ src/settings.c | 12 ------------ src/settings.rs | 10 ++++++++++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/api/settings.rs b/src/api/settings.rs index 46a2d0e..7c62fb3 100644 --- a/src/api/settings.rs +++ b/src/api/settings.rs @@ -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); +} diff --git a/src/settings.c b/src/settings.c index 8903509..40f90a3 100644 --- a/src/settings.c +++ b/src/settings.c @@ -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; diff --git a/src/settings.rs b/src/settings.rs index bc11154..04dc826 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -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; + } }