shell: Make activate/end_workspace_swipe return Err if no set

It doesn't seem like there's really a need to have `Err(_)` and `Ok(None)`.

`Err(_)` means the set exists for the output, but doesn't have the
appropriate workspace index. It's a bit odd that the set not even
existing becomes `Ok(None)`.

Instead, just return `Err(InvalidWorkspaceIndex)` in either case.
This commit is contained in:
Ian Douglas Scott 2025-07-09 13:04:35 -07:00 committed by Victoria Brekenfeld
parent 6f5a14e95c
commit 8aa501c0e0
3 changed files with 17 additions and 22 deletions

View file

@ -539,7 +539,7 @@ impl State {
res
};
if let Ok(Some(new_pos)) = res {
if let Ok(new_pos) = res {
let workspace = shell.workspaces.active(&next_output).unwrap().1;
let new_target = workspace
.focus_stack
@ -1080,7 +1080,7 @@ fn to_next_workspace(
seat: &Seat<State>,
gesture: bool,
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
let current_output = seat.active_output();
let workspace = shell
.workspaces
@ -1106,7 +1106,7 @@ fn to_previous_workspace(
seat: &Seat<State>,
gesture: bool,
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
let current_output = seat.active_output();
let workspace = shell
.workspaces

View file

@ -1512,7 +1512,7 @@ impl Shell {
idx: usize,
workspace_delta: WorkspaceDelta,
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
match &mut self.workspaces.mode {
WorkspaceMode::OutputBound => {
if let Some(set) = self.workspaces.sets.get_mut(output) {
@ -1525,12 +1525,12 @@ impl Shell {
set.activate(idx, workspace_delta, workspace_state)?;
let output_geo = output.geometry();
Ok(Some(
Ok(
output_geo.loc
+ Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
))
)
} else {
Ok(None)
Err(InvalidWorkspaceIndex)
}
}
WorkspaceMode::Global => {
@ -1538,9 +1538,7 @@ impl Shell {
set.activate(idx, workspace_delta, workspace_state)?;
}
let output_geo = output.geometry();
Ok(Some(
output_geo.loc + Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
))
Ok(output_geo.loc + Point::from((output_geo.size.w / 2, output_geo.size.h / 2)))
}
}
}
@ -1565,7 +1563,7 @@ impl Shell {
output: &Output,
velocity: f64,
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
match &mut self.workspaces.mode {
WorkspaceMode::OutputBound => {
if let Some(set) = self.workspaces.sets.get_mut(output) {
@ -1605,12 +1603,12 @@ impl Shell {
}
let output_geo = output.geometry();
Ok(Some(
Ok(
output_geo.loc
+ Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
))
)
} else {
Ok(None)
Err(InvalidWorkspaceIndex)
}
}
WorkspaceMode::Global => {
@ -1644,7 +1642,7 @@ impl Shell {
}
}
}
Ok(None)
Err(InvalidWorkspaceIndex)
}
}
}
@ -2942,7 +2940,7 @@ impl Shell {
WorkspaceDelta::new_shortcut(),
workspace_state,
)
.unwrap()
.ok()
})
} else {
None
@ -3099,7 +3097,7 @@ impl Shell {
WorkspaceDelta::new_shortcut(),
workspace_state,
)
.unwrap()
.ok()
})
} else {
None
@ -3209,7 +3207,7 @@ impl Shell {
WorkspaceDelta::new_shortcut(),
workspace_state,
)
.unwrap()
.ok()
})
} else {
None

View file

@ -90,7 +90,7 @@ impl ToplevelManagementHandler for State {
if seat.active_output() != *output {
match res {
Ok(Some(new_pos)) => {
Ok(new_pos) => {
seat.set_active_output(&output);
if let Some(ptr) = seat.get_pointer() {
let serial = SERIAL_COUNTER.next_serial();
@ -106,9 +106,6 @@ impl ToplevelManagementHandler for State {
ptr.frame(self);
}
}
Ok(None) => {
seat.set_active_output(&output);
}
_ => {}
}
}