Skip to content

Commit

Permalink
fix: focus on old before renaming
Browse files Browse the repository at this point in the history
Fixes issue with multi-monitor dragging would cause the workspace to
switch unexpectedly, possible fix for #34, but the reported issue is a
bit different than what I was able to reproduce.

Focus on the workspace about to be renamed before dispatching rename
commands ensures that the rename operation has a clear, unambiguous
target.

refs: #34 i3/i3#5924
  • Loading branch information
roosta committed Dec 15, 2024
1 parent 49e3bf5 commit 299fc77
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,21 @@ pub fn update_tree(

// Only send command if name changed
if old != &new {
// Use focused workspace criteria to ensure we're targeting the correct workspace
let command = format!("rename workspace \"{}\" to \"{}\"", old, new);
if VERBOSE.load(Ordering::Relaxed) {
println!("{} {}", "[COMMAND]".blue(), command);
if let Some(output) = &workspace.output {
println!("{} Workspace on output: {}", "[INFO]".cyan(), output);
}
}
conn.run_command(command)?;

// First focus the workspace to ensure we're renaming the correct one
let focus_cmd = format!("workspace \"{}\"", old);
conn.run_command(&focus_cmd)?;

// Then rename it
conn.run_command(&command)?;
}
}
Ok(())
Expand Down

0 comments on commit 299fc77

Please sign in to comment.