diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index b8b15e56..c89ed7dd 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -1107,6 +1107,30 @@ fn window_is_eligible( } #[allow(clippy::cognitive_complexity, clippy::too_many_lines)] +/// [`should_act`] for a window, which has one class here +pub fn should_act_window( + title: &str, + exe_name: &str, + class: &str, + path: &str, + identifiers: &[MatchingRule], + regex_identifiers: &HashMap, +) -> Option { + should_act(title, exe_name, class, path, identifiers, regex_identifiers) +} + +/// [`should_act_individual`] for a window, which has one class here +pub fn should_act_window_individual( + title: &str, + exe_name: &str, + class: &str, + path: &str, + identifier: &IdWithIdentifier, + regex_identifiers: &HashMap, +) -> bool { + should_act_individual(title, exe_name, class, path, identifier, regex_identifiers) +} + pub fn should_act( title: &str, exe_name: &str, diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 669dd6ee..cbaba58e 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -40,7 +40,8 @@ use crate::core::WindowPlacement; use crate::lockable_sequence::LockableSequence; use crate::ring::Ring; use crate::should_act; -use crate::should_act_individual; +use crate::should_act_window; +use crate::should_act_window_individual; use crate::stackbar_manager; use crate::stackbar_manager::STACKBAR_TAB_HEIGHT; use crate::static_config::WorkspaceConfig; @@ -1392,16 +1393,9 @@ impl Workspace { self.resolve_placement_target(target, fallback_idx) } InitialWindowPlacementRules::Rules(rules_map) => { - let Some(title) = window.title() else { - return fallback_idx; - }; - let Some(exe_name) = window.exe() else { - return fallback_idx; - }; - let Some(class) = window.class() else { - return fallback_idx; - }; - let Some(path) = window.path() else { + let (Some(title), Some(exe_name), Some(class), Some(path)) = + (window.title(), window.exe(), window.class(), window.path()) + else { return fallback_idx; }; @@ -1410,7 +1404,7 @@ impl Workspace { // BTreeMap iterates in key order for (target, placement_rules) in rules_map { let matched = match placement_rules { - PlacementMatchingRules::Single(id) => should_act_individual( + PlacementMatchingRules::Single(id) => should_act_window_individual( &title, &exe_name, &class, @@ -1422,8 +1416,15 @@ impl Workspace { // OR logic: any matching rule triggers placement at this target. // Each MatchingRule handles its own Simple/Composite (AND) logic // internally via should_act. - should_act(&title, &exe_name, &class, &path, rules, ®ex_identifiers) - .is_some() + should_act_window( + &title, + &exe_name, + &class, + &path, + rules, + ®ex_identifiers, + ) + .is_some() } };