mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-18 14:48:34 +01:00
refactor(windows): use the matching types of komorebi-config
komorebi depends on komorebi-config and core::config_generation re-exports MatchingRule, WorkspaceMatchingRule, IdWithIdentifier, MatchingStrategy and IdWithIdentifierAndComment from it, so no call site changes. The 84 duplicated lines (five types and the From impl) are removed; ApplicationOptions, ApplicationConfiguration and the generator stay. Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings: clean (tier 2, persistent target). Schema files untouched.
This commit is contained in:
1 parent
504290e5a8
commit
dc0b9751a5
3 files changed
+8
-84
No files matched your search
Generated
+1
@@ -3338,6 +3338,7 @@ dependencies = [
|
||||
"ed25519-dalek",
|
||||
"hotwatch",
|
||||
"komorebi-collections",
|
||||
"komorebi-config",
|
||||
"komorebi-layouts",
|
||||
"komorebi-protocol",
|
||||
"komorebi-scrolling",
|
||||
|
||||
@@ -9,6 +9,7 @@ edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
komorebi-collections = { path = "../crates/komorebi-collections" }
|
||||
komorebi-config = { path = "../crates/komorebi-config", default-features = false }
|
||||
komorebi-layouts = { path = "../komorebi-layouts", features = ["win32"] }
|
||||
komorebi-scrolling = { path = "../komorebi-scrolling" }
|
||||
komorebi-themes = { path = "../komorebi-themes" }
|
||||
@@ -70,6 +71,7 @@ deadlock_detection = ["parking_lot/deadlock_detection"]
|
||||
schemars = [
|
||||
"dep:schemars",
|
||||
"komorebi-collections/schemars",
|
||||
"komorebi-config/schemars",
|
||||
"komorebi-layouts/schemars",
|
||||
"komorebi-protocol/schemars",
|
||||
]
|
||||
@@ -50,90 +50,11 @@ impl ApplicationOptions {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[serde(untagged)]
|
||||
/// Rule for matching applications
|
||||
pub enum MatchingRule {
|
||||
/// Simple matching rule which must evaluate to true
|
||||
Simple(IdWithIdentifier),
|
||||
/// Composite matching rule where all conditions must evaluate to true
|
||||
Composite(Vec<IdWithIdentifier>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
/// Rule for assigning applications to a workspace
|
||||
pub struct WorkspaceMatchingRule {
|
||||
/// Target monitor index
|
||||
pub monitor_index: usize,
|
||||
/// Target workspace index
|
||||
pub workspace_index: usize,
|
||||
/// Matching rule for the application
|
||||
pub matching_rule: MatchingRule,
|
||||
/// Whether to apply the rule only when the application is initially launched
|
||||
pub initial_only: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
/// Rule for matching applications
|
||||
pub struct IdWithIdentifier {
|
||||
/// Kind of identifier to target
|
||||
pub kind: ApplicationIdentifier,
|
||||
/// Target identifier
|
||||
pub id: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// Matching strategy to use
|
||||
pub matching_strategy: Option<MatchingStrategy>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Display)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
/// Strategy for matching identifiers
|
||||
pub enum MatchingStrategy {
|
||||
/// Should not be used, only kept for backward compatibility
|
||||
Legacy,
|
||||
/// Equals
|
||||
Equals,
|
||||
/// Starts With
|
||||
StartsWith,
|
||||
/// Ends With
|
||||
EndsWith,
|
||||
/// Contains
|
||||
Contains,
|
||||
/// Regex
|
||||
Regex,
|
||||
/// Does not end with
|
||||
DoesNotEndWith,
|
||||
/// Does not start with
|
||||
DoesNotStartWith,
|
||||
/// Does not equal
|
||||
DoesNotEqual,
|
||||
/// Does not contain
|
||||
DoesNotContain,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub struct IdWithIdentifierAndComment {
|
||||
pub kind: ApplicationIdentifier,
|
||||
pub id: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub comment: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub matching_strategy: Option<MatchingStrategy>,
|
||||
}
|
||||
|
||||
impl From<IdWithIdentifierAndComment> for IdWithIdentifier {
|
||||
fn from(value: IdWithIdentifierAndComment) -> Self {
|
||||
Self {
|
||||
kind: value.kind,
|
||||
id: value.id.clone(),
|
||||
matching_strategy: value.matching_strategy,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub use komorebi_config::matching::IdWithIdentifier;
|
||||
pub use komorebi_config::matching::IdWithIdentifierAndComment;
|
||||
pub use komorebi_config::matching::MatchingRule;
|
||||
pub use komorebi_config::matching::MatchingStrategy;
|
||||
pub use komorebi_config::matching::WorkspaceMatchingRule;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
|
||||
Reference in new issue
Block a user