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 19:56:09 +00:00
|
|
|
border_for_single_window: ForSingleWindow,
|
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 19:59:22 +00:00
|
|
|
gap_for_single_window: ForSingleWindow,
|
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 19:15:19 +00:00
|
|
|
respect_resize_hints_in_floating_layout: bool,
|
2022-09-08 19:22:22 +00:00
|
|
|
show_bar_by_default: bool,
|
2022-09-08 19:27:17 +00:00
|
|
|
snap_distance: c_uint,
|
2022-09-08 19:31:12 +00:00
|
|
|
swallow_floating: bool,
|
2022-09-08 11:41:21 +00:00
|
|
|
}
|
|
|
|
|
2022-09-08 19:49:41 +00:00
|
|
|
#[derive(Clone, Copy, Debug)]
|
|
|
|
pub enum ForSingleWindow {
|
|
|
|
Never,
|
|
|
|
Always,
|
|
|
|
NotInFullscreen,
|
|
|
|
NobodyIsFullscreen,
|
|
|
|
}
|
|
|
|
|
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 19:56:09 +00:00
|
|
|
border_for_single_window: Default::default(),
|
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 19:59:22 +00:00
|
|
|
gap_for_single_window: Default::default(),
|
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 19:15:19 +00:00
|
|
|
respect_resize_hints_in_floating_layout: false,
|
2022-09-08 19:22:22 +00:00
|
|
|
show_bar_by_default: true,
|
2022-09-08 19:27:17 +00:00
|
|
|
snap_distance: 32,
|
2022-09-08 19:31:12 +00:00
|
|
|
swallow_floating: false,
|
2022-09-08 11:41:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-08 19:49:41 +00:00
|
|
|
impl Default for ForSingleWindow {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::NobodyIsFullscreen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<c_uchar> for ForSingleWindow {
|
|
|
|
fn into(self) -> c_uchar {
|
|
|
|
match self {
|
|
|
|
Self::Never => 0,
|
|
|
|
Self::Always => 1,
|
|
|
|
Self::NotInFullscreen => 2,
|
|
|
|
Self::NobodyIsFullscreen => 3,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<c_uchar> for ForSingleWindow {
|
|
|
|
fn from(value: c_uchar) -> Self {
|
|
|
|
match value {
|
|
|
|
0 => Self::Never,
|
|
|
|
1 => Self::Always,
|
|
|
|
2 => Self::NotInFullscreen,
|
|
|
|
3 => Self::NobodyIsFullscreen,
|
|
|
|
_ => panic!("invalid value for type ForSingleWindow"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-09-08 19:56:09 +00:00
|
|
|
pub fn border_for_single_window(&self) -> ForSingleWindow {
|
|
|
|
self.border_for_single_window
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: notify WM to rearrange clients
|
|
|
|
pub fn border_for_single_window_set(&mut self, value: ForSingleWindow) {
|
|
|
|
self.border_for_single_window = value;
|
|
|
|
}
|
|
|
|
|
2022-09-08 11:50:44 +00:00
|
|
|
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
|
|
|
|
2022-09-08 19:59:22 +00:00
|
|
|
pub fn gap_for_single_window(&self) -> ForSingleWindow {
|
|
|
|
self.gap_for_single_window
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: notify WM to rearrange clients
|
|
|
|
pub fn gap_for_single_window_set(&mut self, value: ForSingleWindow) {
|
|
|
|
self.gap_for_single_window = 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 19:15:19 +00:00
|
|
|
|
|
|
|
pub fn respect_resize_hints_in_floating_layout(&self) -> bool {
|
|
|
|
self.respect_resize_hints_in_floating_layout
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: notify WM to rearrange clients
|
|
|
|
pub fn respect_resize_hints_in_floating_layout_set(&mut self, value: bool) {
|
|
|
|
self.respect_resize_hints_in_floating_layout = value;
|
|
|
|
}
|
2022-09-08 19:22:22 +00:00
|
|
|
|
|
|
|
pub fn show_bar_by_default(&self) -> bool {
|
|
|
|
self.show_bar_by_default
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn show_bar_by_default_set(&mut self, value: bool) {
|
|
|
|
self.show_bar_by_default = value;
|
|
|
|
}
|
2022-09-08 19:27:17 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2022-09-08 19:31:12 +00:00
|
|
|
|
|
|
|
pub fn swallow_floating(&self) -> bool {
|
|
|
|
self.swallow_floating
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn swallow_floating_set(&mut self, value: bool) {
|
|
|
|
self.swallow_floating = value;
|
|
|
|
}
|
2022-09-08 11:41:21 +00:00
|
|
|
}
|