diff --git a/src/lib.rs b/src/lib.rs index 746a20c..e933094 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -298,6 +298,7 @@ pub fn update_tree( conn: &mut Connection, config: &Config, res: ®ex::Compiled, + focus: bool, ) -> Result<(), Box> { let tree = conn.get_tree()?; let separator = config.get_general("separator").unwrap_or_else(|| " | ".to_string()); @@ -334,9 +335,11 @@ pub fn update_tree( } } - // First focus the workspace to ensure we're renaming the correct one - // let focus_cmd = format!("workspace \"{}\"", old); - // conn.run_command(&focus_cmd)?; + // Focus on flag, fix for moving floating windows across multiple monitors + if focus { + let focus_cmd = format!("workspace \"{}\"", old); + conn.run_command(&focus_cmd)?; + } // Then rename it conn.run_command(&command)?; @@ -358,7 +361,7 @@ pub fn handle_window_event( } match e.change { WindowChange::New | WindowChange::Close | WindowChange::Move | WindowChange::Title => { - update_tree(conn, config, res) + update_tree(conn, config, res, false) .map_err(|e| AppError::Event(format!("Tree update failed: {}", e)))?; } _ => (), @@ -380,7 +383,7 @@ pub fn handle_ws_event( } match e.change { WorkspaceChange::Empty | WorkspaceChange::Focus => { - update_tree(conn, config, res) + update_tree(conn, config, res, e.change == WorkspaceChange::Focus) .map_err(|e| AppError::Event(format!("Tree update failed: {}", e)))?; } _ => (), diff --git a/src/main.rs b/src/main.rs index adabac2..2a5d3bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -295,7 +295,7 @@ fn run() -> Result<(), AppError> { let mut conn = Connection::new()?; let subscriptions = [EventType::Window, EventType::Workspace]; - i3wsr_core::update_tree(&mut conn, &config, &res) + i3wsr_core::update_tree(&mut conn, &config, &res, false) .map_err(|e| AppError::Event(format!("Initial tree update failed: {}", e)))?; let event_connection = Connection::new()?;