2022-09-08 11:50:44 +00:00
|
|
|
use crate::constraints;
|
|
|
|
|
|
|
|
use std::os::raw::*;
|
|
|
|
|
2022-09-08 11:41:21 +00:00
|
|
|
#[derive(Clone, Copy, Debug)]
|
|
|
|
pub struct Settings {
|
|
|
|
bar_on_top_by_default: bool,
|
2022-09-08 11:50:44 +00:00
|
|
|
border_width: c_int,
|
2022-09-08 11:58:08 +00:00
|
|
|
default_clients_in_master: c_int,
|
2022-09-08 12:03:50 +00:00
|
|
|
default_master_area_factor: c_float,
|
2022-09-08 12:08:33 +00:00
|
|
|
enable_swallowing: bool,
|
2022-09-08 12:11:50 +00:00
|
|
|
focus_on_wheel: bool,
|
2022-09-08 12:16:01 +00:00
|
|
|
gap_size: c_int,
|
2022-09-08 12:24:53 +00:00
|
|
|
max_clients_in_master: Option<c_int>,
|
2022-09-08 11:41:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Settings {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
bar_on_top_by_default: true,
|
2022-09-08 11:50:44 +00:00
|
|
|
border_width: 2,
|
2022-09-08 11:58:08 +00:00
|
|
|
default_clients_in_master: 1,
|
2022-09-08 12:03:50 +00:00
|
|
|
default_master_area_factor: 0.6,
|
2022-09-08 12:08:33 +00:00
|
|
|
enable_swallowing: true,
|
2022-09-08 12:11:50 +00:00
|
|
|
focus_on_wheel: true,
|
2022-09-08 12:16:01 +00:00
|
|
|
gap_size: 10,
|
2022-09-08 12:24:53 +00:00
|
|
|
max_clients_in_master: None,
|
2022-09-08 11:41:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Settings {
|
|
|
|
pub fn bar_on_top_by_default(&self) -> bool {
|
|
|
|
self.bar_on_top_by_default
|
|
|
|
}
|
|
|
|
|
2022-09-08 11:50:44 +00:00
|
|
|
pub fn bar_on_top_by_default_set(&mut self, value: bool) {
|
|
|
|
self.bar_on_top_by_default = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn border_width(&self) -> c_int {
|
|
|
|
self.border_width
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: notify WM to rearrange clients
|
|
|
|
pub fn border_width_set(&mut self, value: c_int) {
|
|
|
|
self.border_width = constraints::border_width(value);
|
2022-09-08 11:41:21 +00:00
|
|
|
}
|
2022-09-08 11:58:08 +00:00
|
|
|
|
|
|
|
pub fn default_clients_in_master(&self) -> c_int {
|
|
|
|
self.default_clients_in_master
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn default_clients_in_master_set(&mut self, value: c_int) {
|
|
|
|
self.default_clients_in_master =
|
|
|
|
constraints::default_clients_in_master(value);
|
|
|
|
}
|
2022-09-08 12:03:50 +00:00
|
|
|
|
|
|
|
pub fn default_master_area_factor(&self) -> c_float {
|
|
|
|
self.default_master_area_factor
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn default_master_area_factor_set(&mut self, value: c_float) {
|
|
|
|
self.default_master_area_factor =
|
|
|
|
constraints::default_master_area_factor(value);
|
|
|
|
}
|
2022-09-08 12:08:33 +00:00
|
|
|
|
|
|
|
pub fn enable_swallowing(&self) -> bool {
|
|
|
|
self.enable_swallowing
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn enable_swallowing_set(&mut self, value: bool) {
|
|
|
|
self.enable_swallowing = value;
|
|
|
|
}
|
2022-09-08 12:11:50 +00:00
|
|
|
|
|
|
|
pub fn focus_on_wheel(&self) -> bool {
|
|
|
|
self.focus_on_wheel
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn focus_on_wheel_set(&mut self, value: bool) {
|
|
|
|
self.focus_on_wheel = value;
|
|
|
|
}
|
2022-09-08 12:16:01 +00:00
|
|
|
|
|
|
|
pub fn gap_size(&self) -> c_int {
|
|
|
|
self.gap_size
|
|
|
|
}
|
|
|
|
|
2022-09-08 12:17:41 +00:00
|
|
|
// TODO: notify WM to rearrange clients
|
2022-09-08 12:16:01 +00:00
|
|
|
pub fn gap_size_set(&mut self, value: c_int) {
|
|
|
|
self.gap_size = constraints::gap_size(value);
|
|
|
|
}
|
2022-09-08 12:24:53 +00:00
|
|
|
|
|
|
|
pub fn max_clients_in_master(&self) -> Option<c_int> {
|
|
|
|
self.max_clients_in_master
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: notify WM to rearrange clients
|
|
|
|
pub fn max_clients_in_master_set(&mut self, value: Option<c_int>) {
|
|
|
|
self.max_clients_in_master =
|
|
|
|
value.map(|value| constraints::max_clients_in_master(value));
|
|
|
|
}
|
2022-09-08 11:41:21 +00:00
|
|
|
}
|