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

This commit is contained in:
Alex Kotov 2022-09-09 00:10:10 +04:00
parent 23c415dcde
commit 2f07381331
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 23 additions and 12 deletions

View File

@ -101,6 +101,18 @@ unsafe extern "C" fn settings_set_gap_size(value: c_int) {
SETTINGS.unwrap().gap_size_set(value);
}
#[no_mangle]
unsafe extern "C" fn settings_get_master_area_factor_per_unit() -> c_uchar {
SETTINGS.unwrap().master_area_factor_per_unit().into()
}
#[no_mangle]
unsafe extern "C" fn settings_set_master_area_factor_per_unit(value: c_uchar) {
SETTINGS
.unwrap()
.master_area_factor_per_unit_set(value.into());
}
#[no_mangle]
unsafe extern "C" fn settings_get_max_clients_in_master() -> c_int {
match SETTINGS.unwrap().max_clients_in_master() {

View File

@ -2,20 +2,8 @@
#include "constraints.h"
static UnitKind master_area_factor_per_unit = UNIT_MONITOR;
static UnitKind show_bar_per_unit = UNIT_MONITOR;
UnitKind settings_get_master_area_factor_per_unit()
{
return master_area_factor_per_unit;
}
void settings_set_master_area_factor_per_unit(const UnitKind new_master_area_factor_per_unit)
{
master_area_factor_per_unit = new_master_area_factor_per_unit;
// TODO: notify WM to rearrange clients
}
UnitKind settings_get_show_bar_per_unit()
{
return show_bar_per_unit;

View File

@ -1,4 +1,5 @@
use crate::constraints;
use crate::unit;
use std::os::raw::*;
@ -13,6 +14,7 @@ pub struct Settings {
focus_on_wheel: bool,
gap_for_single_window: ForSingleWindow,
gap_size: c_int,
master_area_factor_per_unit: unit::Kind,
max_clients_in_master: Option<c_int>,
respect_resize_hints_in_floating_layout: bool,
show_bar_by_default: bool,
@ -40,6 +42,7 @@ impl Default for Settings {
focus_on_wheel: true,
gap_for_single_window: Default::default(),
gap_size: 10,
master_area_factor_per_unit: unit::Kind::Monitor,
max_clients_in_master: None,
respect_resize_hints_in_floating_layout: false,
show_bar_by_default: true,
@ -157,6 +160,14 @@ impl Settings {
self.gap_size = constraints::gap_size(value);
}
pub fn master_area_factor_per_unit(&self) -> unit::Kind {
self.master_area_factor_per_unit
}
pub fn master_area_factor_per_unit_set(&mut self, value: unit::Kind) {
self.master_area_factor_per_unit = value;
}
pub fn max_clients_in_master(&self) -> Option<c_int> {
self.max_clients_in_master
}