diff --git a/src/lib.rs b/src/lib.rs index de8a83e..9b43eda 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ mod api; mod constraints; -mod settings; pub mod geom; +pub mod settings; pub use settings::Settings; diff --git a/src/settings.h b/src/settings.h index 0470675..0a08f51 100644 --- a/src/settings.h +++ b/src/settings.h @@ -5,12 +5,12 @@ #include -typedef enum { - SETTINGS_FOR_SINGLE_WINDOW_NEVER, - SETTINGS_FOR_SINGLE_WINDOW_ALWAYS, - SETTINGS_FOR_SINGLE_WINDOW_NOT_IN_FULLSCREEN, - SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN, -} SettingsForSingleWindow; +typedef unsigned char SettingsForSingleWindow; + +#define SETTINGS_FOR_SINGLE_WINDOW_NEVER 0 +#define SETTINGS_FOR_SINGLE_WINDOW_ALWAYS 1 +#define SETTINGS_FOR_SINGLE_WINDOW_NOT_IN_FULLSCREEN 2 +#define SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN 3 bool settings_get_bar_on_top_by_default(); void settings_set_bar_on_top_by_default(bool new_bar_on_top_by_default); diff --git a/src/settings.rs b/src/settings.rs index 1cc1b55..e8a8e29 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -18,6 +18,14 @@ pub struct Settings { swallow_floating: bool, } +#[derive(Clone, Copy, Debug)] +pub enum ForSingleWindow { + Never, + Always, + NotInFullscreen, + NobodyIsFullscreen, +} + impl Default for Settings { fn default() -> Self { Self { @@ -37,6 +45,35 @@ impl Default for Settings { } } +impl Default for ForSingleWindow { + fn default() -> Self { + Self::NobodyIsFullscreen + } +} + +impl Into for ForSingleWindow { + fn into(self) -> c_uchar { + match self { + Self::Never => 0, + Self::Always => 1, + Self::NotInFullscreen => 2, + Self::NobodyIsFullscreen => 3, + } + } +} + +impl From 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"), + } + } +} + impl Settings { pub fn bar_on_top_by_default(&self) -> bool { self.bar_on_top_by_default