From fe652566591b5cc70da25ffcdfe48aa720199e39 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 20:14:00 -0700 Subject: [PATCH] refactor(kde): the ignore and manage rules use the shared push_simple_rule The KDE copy of push_simple_rule and its test moved to komorebi_config::matching (the config revision of this stack); the daemon imports it. No behaviour change: the function is the same text. Verified: KDE cargo check --all-targets and lib tests (fast-check) PASS; native cargo test -p komorebi-config has the moved test; tools/format-all --apply --tree kde ran. --- .../komorebi/src/process_command.rs | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/komorebi-for-kde/komorebi/src/process_command.rs b/komorebi-for-kde/komorebi/src/process_command.rs index 9a9e4dc6..fc38bd9e 100644 --- a/komorebi-for-kde/komorebi/src/process_command.rs +++ b/komorebi-for-kde/komorebi/src/process_command.rs @@ -270,6 +270,7 @@ use crate::workspace::WorkspaceWindowLocation; use color_eyre::eyre; use color_eyre::eyre::Context; use color_eyre::eyre::OptionExt; +use komorebi_config::matching::push_simple_rule; use komorebi_themes::colour::Rgb; use komorebi_transport::CommandTarget; use komorebi_transport::NoPolicy; @@ -1993,22 +1994,6 @@ pub fn read_commands_uds(wm: &Arc>, stream: UnixStream) -> komorebi_transport::read_commands::(wm, stream, &NoPolicy) } -/// Add a simple socket-created rule unless one with the same kind and id is already present; -/// a rule of another kind with the same id is a different rule -fn push_simple_rule(rules: &mut Vec, kind: ApplicationIdentifier, id: &str) { - let exists = rules - .iter() - .any(|r| matches!(r, MatchingRule::Simple(r) if r.kind == kind && r.id.eq(id))); - - if !exists { - rules.push(MatchingRule::Simple(IdWithIdentifier { - kind, - id: id.to_string(), - matching_strategy: Option::from(MatchingStrategy::Legacy), - })); - } -} - /// The window manager as the shared commands of `komorebi_core::command` see it impl komorebi_core::CommandHost for WindowManager { type P = crate::workspace::KdePlatform; @@ -2394,26 +2379,4 @@ mod tests { std::fs::remove_file(socket_path).unwrap(); } - - #[test] - fn push_simple_rule_keeps_rules_of_another_kind_with_the_same_id() { - let mut rules = vec![]; - - push_simple_rule(&mut rules, ApplicationIdentifier::Class, "foo"); - push_simple_rule(&mut rules, ApplicationIdentifier::Exe, "foo"); - assert_eq!(rules.len(), 2); - - push_simple_rule(&mut rules, ApplicationIdentifier::Exe, "foo"); - push_simple_rule(&mut rules, ApplicationIdentifier::Class, "foo"); - assert_eq!(rules.len(), 2); - - rules.clear(); - rules.push(MatchingRule::Composite(vec![IdWithIdentifier { - kind: ApplicationIdentifier::Exe, - id: "foo".to_string(), - matching_strategy: None, - }])); - push_simple_rule(&mut rules, ApplicationIdentifier::Exe, "foo"); - assert_eq!(rules.len(), 2); - } }