refactor(windows): resolve_placement_index uses should_act_window

BEHAVIOUR (Windows runtime, none expected): window.rs gets
should_act_window and should_act_window_individual, thin forms of
should_act and should_act_individual that take one class, and
resolve_placement_index has KDE's text (one let-else over the four
lookups, then those two calls). Same checks in the same order.

Windows e2e scenarios: initial_window_placement rules (target and
rules map, single and many matching rules).

Verified: Windows clippy --workspace --locked --all-targets -D warnings:
PASS. Not run: Windows tests, e2e.
This commit is contained in:
LGUG2Z committed 2026-10-31 12:31:37 -07:00
1 parent 259dbb6646
commit e4d97c87ed
2 files changed
+39 -14

No files matched your search

+24
View File
@@ -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<String, Regex>,
) -> Option<MatchingRule> {
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<String, Regex>,
) -> bool {
should_act_individual(title, exe_name, class, path, identifier, regex_identifiers)
}
pub fn should_act(
title: &str,
exe_name: &str,
+15 -14
View File
@@ -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, &regex_identifiers)
.is_some()
should_act_window(
&title,
&exe_name,
&class,
&path,
rules,
&regex_identifiers,
)
.is_some()
}
};