tree: allow floats to be pinned
This commit is contained in:
parent
3e6640f0ca
commit
65a66c2e26
28 changed files with 528 additions and 36 deletions
|
|
@ -16,6 +16,7 @@ mod drm_device;
|
|||
mod drm_device_match;
|
||||
mod env;
|
||||
pub mod exec;
|
||||
pub mod float;
|
||||
mod format;
|
||||
mod gfx_api;
|
||||
mod idle;
|
||||
|
|
|
|||
|
|
@ -116,6 +116,9 @@ impl ActionParser<'_> {
|
|||
"enable-float-above-fullscreen" => SetFloatAboveFullscreen(true),
|
||||
"disable-float-above-fullscreen" => SetFloatAboveFullscreen(false),
|
||||
"toggle-float-above-fullscreen" => ToggleFloatAboveFullscreen,
|
||||
"pin-float" => SetFloatPinned(true),
|
||||
"unpin-float" => SetFloatPinned(false),
|
||||
"toggle-float-pinned" => ToggleFloatPinned,
|
||||
_ => {
|
||||
return Err(
|
||||
ActionParserError::UnknownSimpleAction(string.to_string()).spanned(span)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use {
|
|||
drm_device::DrmDevicesParser,
|
||||
drm_device_match::DrmDeviceMatchParser,
|
||||
env::EnvParser,
|
||||
float::FloatParser,
|
||||
gfx_api::GfxApiParser,
|
||||
idle::IdleParser,
|
||||
input::InputsParser,
|
||||
|
|
@ -118,7 +119,7 @@ impl Parser for ConfigParser<'_> {
|
|||
ui_drag_val,
|
||||
xwayland_val,
|
||||
),
|
||||
(color_management_val,),
|
||||
(color_management_val, float_val),
|
||||
) = ext.extract((
|
||||
(
|
||||
opt(val("keymap")),
|
||||
|
|
@ -156,7 +157,7 @@ impl Parser for ConfigParser<'_> {
|
|||
opt(val("ui-drag")),
|
||||
opt(val("xwayland")),
|
||||
),
|
||||
(opt(val("color-management")),),
|
||||
(opt(val("color-management")), opt(val("float"))),
|
||||
))?;
|
||||
let mut keymap = None;
|
||||
if let Some(value) = keymap_val {
|
||||
|
|
@ -381,6 +382,15 @@ impl Parser for ConfigParser<'_> {
|
|||
}
|
||||
}
|
||||
}
|
||||
let mut float = None;
|
||||
if let Some(value) = float_val {
|
||||
match value.parse(&mut FloatParser(self.0)) {
|
||||
Ok(v) => float = Some(v),
|
||||
Err(e) => {
|
||||
log::warn!("Could not parse the float settings: {}", self.0.error(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Config {
|
||||
keymap,
|
||||
repeat_rate,
|
||||
|
|
@ -412,6 +422,7 @@ impl Parser for ConfigParser<'_> {
|
|||
ui_drag,
|
||||
xwayland,
|
||||
color_management,
|
||||
float,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
48
toml-config/src/config/parsers/float.rs
Normal file
48
toml-config/src/config/parsers/float.rs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
use {
|
||||
crate::{
|
||||
config::{
|
||||
context::Context,
|
||||
extractor::{Extractor, ExtractorError, bol, opt, recover},
|
||||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
},
|
||||
toml::{
|
||||
toml_span::{DespanExt, Span, Spanned},
|
||||
toml_value::Value,
|
||||
},
|
||||
},
|
||||
indexmap::IndexMap,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum FloatParserError {
|
||||
#[error(transparent)]
|
||||
Expected(#[from] UnexpectedDataType),
|
||||
#[error(transparent)]
|
||||
Extract(#[from] ExtractorError),
|
||||
}
|
||||
|
||||
pub struct FloatParser<'a>(pub &'a Context<'a>);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Float {
|
||||
pub show_pin_icon: Option<bool>,
|
||||
}
|
||||
|
||||
impl Parser for FloatParser<'_> {
|
||||
type Value = Float;
|
||||
type Error = FloatParserError;
|
||||
const EXPECTED: &'static [DataType] = &[DataType::Table];
|
||||
|
||||
fn parse_table(
|
||||
&mut self,
|
||||
span: Span,
|
||||
table: &IndexMap<Spanned<String>, Spanned<Value>>,
|
||||
) -> ParseResult<Self> {
|
||||
let mut ext = Extractor::new(self.0, span, table);
|
||||
let (show_pin_icon,) = ext.extract((recover(opt(bol("show-pin-icon"))),))?;
|
||||
Ok(Float {
|
||||
show_pin_icon: show_pin_icon.despan(),
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue