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

@ -24,7 +24,6 @@ use {
ahash::AHashMap,
jay_config::{
Direction, Workspace,
client::ClientCapabilities,
input::{
FallbackOutputMode, LayerDirection, SwitchEvent, Timeline, acceleration::AccelProfile,
clickmethod::ClickMethod,
@ -49,6 +48,8 @@ use {
toml::toml_parser,
};
pub use jay_config_schema::{AnimationCurveConfig, Animations};
#[derive(Debug, Copy, Clone)]
pub enum SimpleCommand {
Close,
@ -58,7 +59,6 @@ pub enum SimpleCommand {
Move(Direction),
None,
Quit,
ReloadConfigSo,
ReloadConfigToml,
ToggleFloating,
SetFloating(bool),
@ -266,20 +266,6 @@ pub struct UiDrag {
pub threshold: Option<i32>,
}
#[derive(Debug, Clone, Default)]
pub struct Animations {
pub enabled: Option<bool>,
pub duration_ms: Option<u32>,
pub style: Option<String>,
pub curve: Option<AnimationCurveConfig>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum AnimationCurveConfig {
Preset(String),
CubicBezier([f32; 4]),
}
#[derive(Debug, Clone)]
pub enum OutputMatch {
Any(Vec<OutputMatch>),
@ -313,8 +299,6 @@ pub struct ClientRule {
pub match_: ClientMatch,
pub action: Option<Action>,
pub latch: Option<Action>,
pub capabilities: Option<ClientCapabilities>,
pub bounding_capabilities: Option<ClientCapabilities>,
}
#[derive(Default, Debug, Clone)]
@ -334,8 +318,6 @@ pub struct ClientMatch {
pub comm_regex: Option<String>,
pub exe: Option<String>,
pub exe_regex: Option<String>,
pub tag: Option<String>,
pub tag_regex: Option<String>,
}
#[derive(Debug, Clone)]
@ -476,8 +458,6 @@ pub struct Exec {
pub prog: String,
pub args: Vec<String>,
pub envs: Vec<(String, String)>,
pub privileged: bool,
pub tag: Option<String>,
}
#[derive(Debug, Clone)]

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(),
})
}
}

View file

@ -25,7 +25,7 @@ use {
jay_config::{
AnimationCurve, AnimationStyle, Axis,
client::Client,
config, config_dir,
config_dir,
exec::{Command, set_env, unset_env},
get_workspace,
input::{
@ -37,7 +37,7 @@ use {
is_reload,
keyboard::Keymap,
logging::{clean_logs_older_than, set_log_level},
on_devices_enumerated, on_idle, on_unload, quit, reload, set_animation_cubic_bezier,
on_devices_enumerated, on_idle, on_unload, quit, set_animation_cubic_bezier,
set_animation_curve, set_animation_duration_ms, set_animation_style,
set_animations_enabled, set_autotile, set_color_management_enabled, set_corner_radius,
set_default_workspace_capture,
@ -186,7 +186,6 @@ impl Action {
let persistent = state.persistent.clone();
b.new(move || load_config(false, false, &persistent))
}
SimpleCommand::ReloadConfigSo => b.new(reload),
SimpleCommand::None => b.new(|| ()),
SimpleCommand::Forward(bool) => b.new(move || s.set_forward(bool)),
SimpleCommand::EnableWindowManagement(bool) => {
@ -1759,12 +1758,6 @@ fn create_command(exec: &Exec) -> Command {
for (k, v) in &exec.envs {
command.env(k, v);
}
if exec.privileged {
command.privileged();
}
if let Some(tag) = &exec.tag {
command.tag(tag);
}
command
}
@ -1798,5 +1791,3 @@ pub fn configure() {
}
load_config(true, false, &persistent);
}
config!(configure);

View file

@ -127,8 +127,6 @@ impl Rule for ClientRule {
value_ref!(CommRegex, comm_regex);
value_ref!(Exe, exe);
value_ref!(ExeRegex, exe_regex);
value_ref!(Tag, tag);
value_ref!(TagRegex, tag_regex);
value!(Uid, uid);
value!(Pid, pid);
bool!(Sandboxed, sandboxed);
@ -177,12 +175,6 @@ impl Rule for ClientRule {
});
}
}
if let Some(caps) = self.capabilities {
matcher.set_capabilities(caps);
}
if let Some(caps) = self.bounding_capabilities {
matcher.set_sandbox_bounding_capabilities(caps);
}
}
fn gen_matcher(m: Self::Matcher) -> Self::Criterion<'static> {