diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 0123b495..1332716f 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -732,45 +732,56 @@ impl WindowManager { for window in workspace.visible_windows().into_iter().flatten() { let mut already_moved_window_handles = self.already_moved_window_handles.lock(); - let exe_name = window.exe()?; - let title = window.title()?; - let class = window.class()?; - let path = window.path()?; - for rule in &*workspace_matching_rules { - let matched = match &rule.matching_rule { - MatchingRule::Simple(r) => should_act_individual( - &title, - &exe_name, - &class, - &path, - r, - ®ex_identifiers, - ), - MatchingRule::Composite(r) => { - let mut composite_results = vec![]; - for identifier in r { - composite_results.push(should_act_individual( - &title, - &exe_name, - &class, - &path, - identifier, - ®ex_identifiers, - )); + if let (Ok(exe_name), Ok(title), Ok(class), Ok(path)) = + (window.exe(), window.title(), window.class(), window.path()) + { + for rule in &*workspace_matching_rules { + let matched = match &rule.matching_rule { + MatchingRule::Simple(r) => should_act_individual( + &title, + &exe_name, + &class, + &path, + r, + ®ex_identifiers, + ), + MatchingRule::Composite(r) => { + let mut composite_results = vec![]; + for identifier in r { + composite_results.push(should_act_individual( + &title, + &exe_name, + &class, + &path, + identifier, + ®ex_identifiers, + )); + } + + composite_results.iter().all(|&x| x) } + }; - composite_results.iter().all(|&x| x) - } - }; + if matched { + let floating = workspace.floating_windows().contains(window); - if matched { - let floating = workspace.floating_windows().contains(window); - - if rule.initial_only { - if !already_moved_window_handles.contains(&window.hwnd) { - already_moved_window_handles.insert(window.hwnd); + if rule.initial_only { + if !already_moved_window_handles.contains(&window.hwnd) { + already_moved_window_handles.insert(window.hwnd); + self.add_window_handle_to_move_based_on_workspace_rule( + &window.title()?, + window.hwnd, + i, + j, + rule.monitor_index, + rule.workspace_index, + floating, + &mut to_move, + ); + } + } else { self.add_window_handle_to_move_based_on_workspace_rule( &window.title()?, window.hwnd, @@ -782,17 +793,6 @@ impl WindowManager { &mut to_move, ); } - } else { - self.add_window_handle_to_move_based_on_workspace_rule( - &window.title()?, - window.hwnd, - i, - j, - rule.monitor_index, - rule.workspace_index, - floating, - &mut to_move, - ); } } }