Fix 'move_container_to_next_or_prev_output' and 'current_output_index'

This commit is contained in:
Skia 2023-01-15 11:11:03 +01:00
parent 1c8ab4246a
commit 5380131ee9

View file

@ -204,7 +204,7 @@ fn get_current_output_index(stream: &UnixStream) -> usize {
let outputs = get_outputs(stream); let outputs = get_outputs(stream);
match outputs.iter().position(|x| x.focused) { match outputs.iter().position(|x| x.focused) {
Some(i) => i + 1, Some(i) => i,
None => panic!("WTF! No focused output???"), None => panic!("WTF! No focused output???"),
} }
} }
@ -494,9 +494,9 @@ fn move_container_to_next_or_prev_output(stream: &UnixStream, go_to_prev: bool)
let focused_output_index = get_current_output_index(stream); let focused_output_index = get_current_output_index(stream);
let target_output = if go_to_prev { let target_output = if go_to_prev {
&outputs[(focused_output_index + outputs.len() - 1) % outputs.len() - 1] &outputs[(focused_output_index + outputs.len() - 1) % outputs.len()]
} else { } else {
&outputs[(focused_output_index + 1) % outputs.len() - 1] &outputs[(focused_output_index + 1) % outputs.len()]
}; };
let workspaces = get_workspaces(stream); let workspaces = get_workspaces(stream);
@ -546,9 +546,13 @@ fn init_workspaces(stream: &UnixStream, workspace_index: usize) {
send_command(stream, &cmd); send_command(stream, &cmd);
let mut cmd: String = "workspace number ".to_string(); let mut cmd: String = "workspace number ".to_string();
let full_ws_name = format!("{}{}", get_current_output_index(stream), &workspace_index) let full_ws_name = format!(
.parse::<i32>() "{}{}",
.unwrap(); get_current_output_index(stream) + 1,
&workspace_index
)
.parse::<i32>()
.unwrap();
cmd.push_str(&full_ws_name.to_string()); cmd.push_str(&full_ws_name.to_string());
send_command(stream, &cmd); send_command(stream, &cmd);
} }