From 4bf24f81e0bc0fe3bec23e1fd9924f0a2d690072 Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:50:04 +0000 Subject: [PATCH] fix(wm): avoid workspace load on cross monitor moves This commit replaces the `window_manager.focus_workspace` call with a `monitor.focus_workspace` which doesn't load the workspace. There is no need to load the workspace when moving windows across monitors since those workspaces will already be loaded, we simply need to update them. Loading the workspace would cause some issues as well, like when moving a window to a floating workspace which already contained a window that matched some `floating_windows` rules was always putting the "floating_window" on top of the window we just moved with a bunch of focus flickering. This is fixed with this commit. --- komorebi/src/process_event.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 20f9e962..46fa40c3 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -585,11 +585,19 @@ impl WindowManager { // so that we don't have ghost tiles until we force an interaction on // the origin monitor's focused workspace self.focus_monitor(origin_monitor_idx)?; - self.focus_workspace(origin_workspace_idx)?; + let origin_monitor = self + .monitors_mut() + .get_mut(origin_monitor_idx) + .ok_or_else(|| anyhow!("there is no monitor at this idx"))?; + origin_monitor.focus_workspace(origin_workspace_idx)?; self.update_focused_workspace(false, false)?; self.focus_monitor(target_monitor_idx)?; - self.focus_workspace(target_workspace_idx)?; + let target_monitor = self + .monitors_mut() + .get_mut(target_monitor_idx) + .ok_or_else(|| anyhow!("there is no monitor at this idx"))?; + target_monitor.focus_workspace(target_workspace_idx)?; self.update_focused_workspace(false, false)?; // Make sure to give focus to the moved window again