1
0
Fork 0
forked from wry/wry

all: split reusable components into workspace crates

This commit is contained in:
kossLAN 2026-05-29 09:14:53 -04:00
parent 2a079ed800
commit 657e7ce2f7
No known key found for this signature in database
225 changed files with 7422 additions and 17602 deletions

View file

@ -9,7 +9,6 @@ use {
pub mod action;
mod actions;
mod animations;
mod capabilities;
mod clean_logs_older_than;
mod client_match;
mod client_rule;

View file

@ -125,7 +125,6 @@ impl ActionParser<'_> {
"tile" => SetFloating(false),
"quit" => Quit,
"reload-config-toml" => ReloadConfigToml,
"reload-config-so" => ReloadConfigSo,
"none" => None,
"forward" => Forward(true),
"consume" => Forward(false),

View file

@ -1,70 +0,0 @@
use {
crate::{
config::parser::{DataType, ParseResult, Parser, UnexpectedDataType},
toml::{
toml_span::{Span, Spanned, SpannedExt},
toml_value::Value,
},
},
jay_config::client::{
CC_DATA_CONTROL, CC_DRM_LEASE, CC_FOREIGN_TOPLEVEL_GEOMETRY_TRACKING,
CC_FOREIGN_TOPLEVEL_LIST, CC_FOREIGN_TOPLEVEL_MANAGER, CC_GAMMA_CONTROL_MANAGER,
CC_HEAD_MANAGER, CC_IDLE_NOTIFIER, CC_INPUT_METHOD, CC_LAYER_SHELL, CC_SCREENCOPY,
CC_SEAT_MANAGER, CC_SESSION_LOCK, CC_VIRTUAL_KEYBOARD, CC_VIRTUAL_POINTER,
CC_WORKSPACE_MANAGER, ClientCapabilities,
},
thiserror::Error,
};
#[derive(Debug, Error)]
pub enum CapabilitiesParserError {
#[error(transparent)]
Expected(#[from] UnexpectedDataType),
#[error("Unknown capability `{}`", .0)]
UnknownCapability(String),
}
pub struct CapabilitiesParser;
impl Parser for CapabilitiesParser {
type Value = ClientCapabilities;
type Error = CapabilitiesParserError;
const EXPECTED: &'static [DataType] = &[DataType::Array, DataType::String];
fn parse_string(&mut self, span: Span, string: &str) -> ParseResult<Self> {
let ty = match string {
"none" => ClientCapabilities(0),
"all" => ClientCapabilities(!0),
"data-control" => CC_DATA_CONTROL,
"virtual-keyboard" => CC_VIRTUAL_KEYBOARD,
"foreign-toplevel-list" => CC_FOREIGN_TOPLEVEL_LIST,
"idle-notifier" => CC_IDLE_NOTIFIER,
"session-lock" => CC_SESSION_LOCK,
"layer-shell" => CC_LAYER_SHELL,
"screencopy" => CC_SCREENCOPY,
"seat-manager" => CC_SEAT_MANAGER,
"drm-lease" => CC_DRM_LEASE,
"input-method" => CC_INPUT_METHOD,
"workspace-manager" => CC_WORKSPACE_MANAGER,
"foreign-toplevel-manager" => CC_FOREIGN_TOPLEVEL_MANAGER,
"head-manager" => CC_HEAD_MANAGER,
"gamma-control-manager" => CC_GAMMA_CONTROL_MANAGER,
"virtual-pointer" => CC_VIRTUAL_POINTER,
"foreign-toplevel-geometry-tracking" => CC_FOREIGN_TOPLEVEL_GEOMETRY_TRACKING,
_ => {
return Err(
CapabilitiesParserError::UnknownCapability(string.to_owned()).spanned(span),
);
}
};
Ok(ty)
}
fn parse_array(&mut self, _span: Span, array: &[Spanned<Value>]) -> ParseResult<Self> {
let mut ty = ClientCapabilities(0);
for el in array {
ty |= el.parse(&mut CapabilitiesParser)?;
}
Ok(ty)
}
}

View file

@ -58,8 +58,6 @@ impl Parser for ClientMatchParser<'_> {
comm_regex,
exe,
exe_regex,
tag,
tag_regex,
),
(is_xwayland,),
) = ext.extract((
@ -84,8 +82,6 @@ impl Parser for ClientMatchParser<'_> {
opt(str("comm-regex")),
opt(str("exe")),
opt(str("exe-regex")),
opt(str("tag")),
opt(str("tag-regex")),
),
(opt(bol("is-xwayland")),),
))?;
@ -134,8 +130,6 @@ impl Parser for ClientMatchParser<'_> {
comm_regex: comm_regex.despan_into(),
exe: exe.despan_into(),
exe_regex: exe_regex.despan_into(),
tag: tag.despan_into(),
tag_regex: tag_regex.despan_into(),
})
}
}

View file

@ -7,7 +7,6 @@ use {
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
parsers::{
action::{ActionParser, ActionParserError},
capabilities::CapabilitiesParser,
client_match::{ClientMatchParser, ClientMatchParserError},
},
spanned::SpannedErrorExt,
@ -48,15 +47,12 @@ impl Parser for ClientRuleParser<'_> {
table: &IndexMap<Spanned<String>, Spanned<Value>>,
) -> ParseResult<Self> {
let mut ext = Extractor::new(self.0, span, table);
let (name, match_val, action_val, latch_val, capabilities_val, bounding_capabilities_val) =
ext.extract((
opt(str("name")),
opt(val("match")),
opt(val("action")),
opt(val("latch")),
opt(val("capabilities")),
opt(val("sandbox-bounding-capabilities")),
))?;
let (name, match_val, action_val, latch_val) = ext.extract((
opt(str("name")),
opt(val("match")),
opt(val("action")),
opt(val("latch")),
))?;
let mut action = None;
if let Some(value) = action_val {
action = Some(
@ -77,34 +73,11 @@ impl Parser for ClientRuleParser<'_> {
None => ClientMatch::default(),
Some(m) => m.parse_map(&mut ClientMatchParser(self.0))?,
};
let mut capabilities = None;
if let Some(value) = capabilities_val {
match value.parse(&mut CapabilitiesParser) {
Ok(v) => capabilities = Some(v),
Err(e) => {
log::warn!("Could not parse the capabilities: {}", self.0.error(e));
}
}
}
let mut bounding_capabilities = None;
if let Some(value) = bounding_capabilities_val {
match value.parse(&mut CapabilitiesParser) {
Ok(v) => bounding_capabilities = Some(v),
Err(e) => {
log::warn!(
"Could not parse the bounding capabilities: {}",
self.0.error(e)
);
}
}
}
Ok(ClientRule {
name: name.despan_into(),
match_,
action,
latch,
capabilities,
bounding_capabilities,
})
}
}

View file

@ -3,7 +3,7 @@ use {
config::{
Exec,
context::Context,
extractor::{Extractor, ExtractorError, arr, bol, opt, recover, str, val},
extractor::{Extractor, ExtractorError, arr, opt, str, val},
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
parsers::{
StringParser, StringParserError,
@ -11,7 +11,7 @@ use {
},
},
toml::{
toml_span::{DespanExt, Span, Spanned, SpannedExt},
toml_span::{Span, Spanned, SpannedExt},
toml_value::Value,
},
},
@ -52,8 +52,6 @@ impl Parser for ExecParser<'_> {
prog: string.to_string(),
args: vec![],
envs: vec![],
privileged: false,
tag: None,
})
}
@ -70,8 +68,6 @@ impl Parser for ExecParser<'_> {
prog,
args,
envs: vec![],
privileged: false,
tag: None,
})
}
@ -81,13 +77,11 @@ impl Parser for ExecParser<'_> {
table: &IndexMap<Spanned<String>, Spanned<Value>>,
) -> ParseResult<Self> {
let mut ext = Extractor::new(self.0, span, table);
let (prog_opt, shell_opt, args_val, envs_val, privileged, tag) = ext.extract((
let (prog_opt, shell_opt, args_val, envs_val) = ext.extract((
opt(str("prog")),
opt(str("shell")),
opt(arr("args")),
opt(val("env")),
recover(opt(bol("privileged"))),
opt(str("tag")),
))?;
let prog;
let mut args = vec![];
@ -115,21 +109,10 @@ impl Parser for ExecParser<'_> {
None => vec![],
Some(e) => e.parse_map(&mut EnvParser)?,
};
if let Some(privileged) = privileged
&& privileged.value
&& tag.is_some()
{
log::warn!(
"Exec is privileged and tagged but tagged execs are always unprivileged: {}",
self.0.error3(privileged.span),
);
}
Ok(Exec {
prog,
args,
envs,
privileged: privileged.despan().unwrap_or(false),
tag: tag.despan_into(),
})
}
}