mirror of
https://gitlab.com/hyask/swaysome.git
synced 2025-12-10 07:44:43 +01:00
Fix focus next/prev group
This commit is contained in:
parent
b6f81aa7bb
commit
72c34cb5e5
1 changed files with 10 additions and 27 deletions
37
src/main.rs
37
src/main.rs
|
|
@ -515,39 +515,22 @@ fn move_container_to_next_or_prev_output(stream: &UnixStream, go_to_prev: bool)
|
||||||
send_command(stream, &cmd);
|
send_command(stream, &cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_container_to_next_group(stream: &UnixStream) {
|
fn focus_container_to_next_group(stream: &UnixStream) {
|
||||||
move_container_to_next_or_prev_group(stream, false);
|
focus_container_to_next_or_prev_group(stream, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_container_to_prev_group(stream: &UnixStream) {
|
fn focus_container_to_prev_group(stream: &UnixStream) {
|
||||||
move_container_to_next_or_prev_group(stream, true);
|
focus_container_to_next_or_prev_group(stream, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_container_to_next_or_prev_group(stream: &UnixStream, go_to_prev: bool) {
|
fn focus_container_to_next_or_prev_group(stream: &UnixStream, go_to_prev: bool) {
|
||||||
let current_workspace_index: usize = get_current_workspace(stream).num;
|
let current_workspace_index: usize = get_current_workspace(stream).num;
|
||||||
let focused_group_index = current_workspace_index / 10;
|
let focused_group_index = current_workspace_index / 10;
|
||||||
|
|
||||||
let outputs = get_outputs(stream);
|
if go_to_prev {
|
||||||
if focused_group_index < outputs.len() {
|
focus_to_group(stream, focused_group_index - 1);
|
||||||
let target_output = if go_to_prev {
|
|
||||||
&outputs[(focused_group_index - 1) - 1]
|
|
||||||
} else {
|
|
||||||
&outputs[(focused_group_index + 1) - 1]
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut cmd: String = "focus output ".to_string();
|
|
||||||
cmd.push_str(&target_output.name);
|
|
||||||
send_command(stream, &cmd);
|
|
||||||
} else {
|
} else {
|
||||||
let target_workspace = if go_to_prev {
|
focus_to_group(stream, focused_group_index + 1);
|
||||||
current_workspace_index - 10
|
|
||||||
} else {
|
|
||||||
current_workspace_index + 10
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut cmd: String = "workspace number ".to_string();
|
|
||||||
cmd.push_str(&target_workspace.to_string());
|
|
||||||
send_command(stream, &cmd);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -617,10 +600,10 @@ fn main() {
|
||||||
move_container_to_prev_output(&stream);
|
move_container_to_prev_output(&stream);
|
||||||
}
|
}
|
||||||
Command::NextGroup => {
|
Command::NextGroup => {
|
||||||
move_container_to_next_group(&stream);
|
focus_container_to_next_group(&stream);
|
||||||
}
|
}
|
||||||
Command::PrevGroup => {
|
Command::PrevGroup => {
|
||||||
move_container_to_prev_group(&stream);
|
focus_container_to_prev_group(&stream);
|
||||||
}
|
}
|
||||||
Command::RearrangeWorkspaces => {
|
Command::RearrangeWorkspaces => {
|
||||||
rearrange_workspaces(&stream);
|
rearrange_workspaces(&stream);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue