gestures: Cycle through workspaces
This commit is contained in:
parent
1f2863fa18
commit
8624928052
4 changed files with 123 additions and 53 deletions
|
|
@ -1108,18 +1108,21 @@ fn to_next_workspace(
|
|||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
|
||||
let current_output = seat.active_output();
|
||||
let workspace = shell
|
||||
.workspaces
|
||||
.active_num(¤t_output)
|
||||
.1
|
||||
.checked_add(1)
|
||||
.ok_or(InvalidWorkspaceIndex)?;
|
||||
let active = shell.workspaces.active_num(¤t_output).1;
|
||||
let mut workspace = active.checked_add(1).ok_or(InvalidWorkspaceIndex)?;
|
||||
|
||||
if workspace >= shell.workspaces.len(¤t_output) {
|
||||
workspace = 0;
|
||||
}
|
||||
if workspace == active {
|
||||
return Err(InvalidWorkspaceIndex);
|
||||
}
|
||||
|
||||
shell.activate(
|
||||
¤t_output,
|
||||
workspace,
|
||||
if gesture {
|
||||
WorkspaceDelta::new_gesture()
|
||||
WorkspaceDelta::new_gesture(true)
|
||||
} else {
|
||||
WorkspaceDelta::new_shortcut()
|
||||
},
|
||||
|
|
@ -1134,18 +1137,24 @@ fn to_previous_workspace(
|
|||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
|
||||
let current_output = seat.active_output();
|
||||
let workspace = shell
|
||||
.workspaces
|
||||
.active_num(¤t_output)
|
||||
.1
|
||||
.checked_sub(1)
|
||||
.ok_or(InvalidWorkspaceIndex)?;
|
||||
let active = shell.workspaces.active_num(¤t_output).1;
|
||||
let workspace = active.checked_sub(1).unwrap_or(
|
||||
shell
|
||||
.workspaces
|
||||
.len(¤t_output)
|
||||
.checked_sub(1)
|
||||
.ok_or(InvalidWorkspaceIndex)?,
|
||||
);
|
||||
|
||||
if workspace == active {
|
||||
return Err(InvalidWorkspaceIndex);
|
||||
}
|
||||
|
||||
shell.activate(
|
||||
¤t_output,
|
||||
workspace,
|
||||
if gesture {
|
||||
WorkspaceDelta::new_gesture()
|
||||
WorkspaceDelta::new_gesture(false)
|
||||
} else {
|
||||
WorkspaceDelta::new_shortcut()
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1056,10 +1056,12 @@ impl State {
|
|||
}
|
||||
|
||||
match gesture_state.action {
|
||||
Some(SwipeAction::NextWorkspace) | Some(SwipeAction::PrevWorkspace) => {
|
||||
Some(x @ SwipeAction::NextWorkspace)
|
||||
| Some(x @ SwipeAction::PrevWorkspace) => {
|
||||
self.common.shell.write().update_workspace_delta(
|
||||
&seat.active_output(),
|
||||
gesture_state.delta,
|
||||
matches!(x, SwipeAction::NextWorkspace),
|
||||
)
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue