Wrap workspace scrolling at start and end
Matches the behavior of scrolling over the applet. Seems reasonable.
This commit is contained in:
parent
03840b7f9e
commit
bd9e031912
1 changed files with 15 additions and 10 deletions
25
src/main.rs
25
src/main.rs
|
|
@ -719,17 +719,22 @@ impl Application for App {
|
||||||
// TODO assumes only one active workspace per output
|
// TODO assumes only one active workspace per output
|
||||||
let workspaces = self.workspaces.for_output(&output).collect::<Vec<_>>();
|
let workspaces = self.workspaces.for_output(&output).collect::<Vec<_>>();
|
||||||
if let Some(workspace_idx) = workspaces.iter().position(|i| i.is_active()) {
|
if let Some(workspace_idx) = workspaces.iter().position(|i| i.is_active()) {
|
||||||
let workspace = match direction {
|
let new_workspace_idx = match direction {
|
||||||
// Next workspace on output
|
// Next workspace on output, wrapping to start
|
||||||
ScrollDirection::Next => workspaces[workspace_idx + 1..].iter().next(),
|
ScrollDirection::Next => (workspace_idx + 1) % workspaces.len(),
|
||||||
// Previous workspace on output
|
// Previous workspace on output, wrapping to end
|
||||||
ScrollDirection::Prev => workspaces[..workspace_idx].iter().last(),
|
ScrollDirection::Prev => {
|
||||||
|
if workspace_idx == 0 {
|
||||||
|
workspaces.len() - 1
|
||||||
|
} else {
|
||||||
|
workspace_idx - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if let Some(workspace) = workspace {
|
let workspace = workspaces[new_workspace_idx];
|
||||||
self.send_wayland_cmd(backend::Cmd::ActivateWorkspace(
|
self.send_wayland_cmd(backend::Cmd::ActivateWorkspace(
|
||||||
workspace.handle().clone(),
|
workspace.handle().clone(),
|
||||||
));
|
));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Msg::DndWorkspaceDrag => {}
|
Msg::DndWorkspaceDrag => {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue