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:
parent
6f5a14e95c
commit
8aa501c0e0
3 changed files with 17 additions and 22 deletions
|
|
@ -539,7 +539,7 @@ impl State {
|
||||||
res
|
res
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(Some(new_pos)) = res {
|
if let Ok(new_pos) = res {
|
||||||
let workspace = shell.workspaces.active(&next_output).unwrap().1;
|
let workspace = shell.workspaces.active(&next_output).unwrap().1;
|
||||||
let new_target = workspace
|
let new_target = workspace
|
||||||
.focus_stack
|
.focus_stack
|
||||||
|
|
@ -1080,7 +1080,7 @@ fn to_next_workspace(
|
||||||
seat: &Seat<State>,
|
seat: &Seat<State>,
|
||||||
gesture: bool,
|
gesture: bool,
|
||||||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
|
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
|
||||||
let current_output = seat.active_output();
|
let current_output = seat.active_output();
|
||||||
let workspace = shell
|
let workspace = shell
|
||||||
.workspaces
|
.workspaces
|
||||||
|
|
@ -1106,7 +1106,7 @@ fn to_previous_workspace(
|
||||||
seat: &Seat<State>,
|
seat: &Seat<State>,
|
||||||
gesture: bool,
|
gesture: bool,
|
||||||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
|
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
|
||||||
let current_output = seat.active_output();
|
let current_output = seat.active_output();
|
||||||
let workspace = shell
|
let workspace = shell
|
||||||
.workspaces
|
.workspaces
|
||||||
|
|
|
||||||
|
|
@ -1512,7 +1512,7 @@ impl Shell {
|
||||||
idx: usize,
|
idx: usize,
|
||||||
workspace_delta: WorkspaceDelta,
|
workspace_delta: WorkspaceDelta,
|
||||||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
|
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
|
||||||
match &mut self.workspaces.mode {
|
match &mut self.workspaces.mode {
|
||||||
WorkspaceMode::OutputBound => {
|
WorkspaceMode::OutputBound => {
|
||||||
if let Some(set) = self.workspaces.sets.get_mut(output) {
|
if let Some(set) = self.workspaces.sets.get_mut(output) {
|
||||||
|
|
@ -1525,12 +1525,12 @@ impl Shell {
|
||||||
set.activate(idx, workspace_delta, workspace_state)?;
|
set.activate(idx, workspace_delta, workspace_state)?;
|
||||||
|
|
||||||
let output_geo = output.geometry();
|
let output_geo = output.geometry();
|
||||||
Ok(Some(
|
Ok(
|
||||||
output_geo.loc
|
output_geo.loc
|
||||||
+ Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
|
+ Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
|
||||||
))
|
)
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Err(InvalidWorkspaceIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WorkspaceMode::Global => {
|
WorkspaceMode::Global => {
|
||||||
|
|
@ -1538,9 +1538,7 @@ impl Shell {
|
||||||
set.activate(idx, workspace_delta, workspace_state)?;
|
set.activate(idx, workspace_delta, workspace_state)?;
|
||||||
}
|
}
|
||||||
let output_geo = output.geometry();
|
let output_geo = output.geometry();
|
||||||
Ok(Some(
|
Ok(output_geo.loc + Point::from((output_geo.size.w / 2, output_geo.size.h / 2)))
|
||||||
output_geo.loc + Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1565,7 +1563,7 @@ impl Shell {
|
||||||
output: &Output,
|
output: &Output,
|
||||||
velocity: f64,
|
velocity: f64,
|
||||||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
|
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
|
||||||
match &mut self.workspaces.mode {
|
match &mut self.workspaces.mode {
|
||||||
WorkspaceMode::OutputBound => {
|
WorkspaceMode::OutputBound => {
|
||||||
if let Some(set) = self.workspaces.sets.get_mut(output) {
|
if let Some(set) = self.workspaces.sets.get_mut(output) {
|
||||||
|
|
@ -1605,12 +1603,12 @@ impl Shell {
|
||||||
}
|
}
|
||||||
|
|
||||||
let output_geo = output.geometry();
|
let output_geo = output.geometry();
|
||||||
Ok(Some(
|
Ok(
|
||||||
output_geo.loc
|
output_geo.loc
|
||||||
+ Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
|
+ Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
|
||||||
))
|
)
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Err(InvalidWorkspaceIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WorkspaceMode::Global => {
|
WorkspaceMode::Global => {
|
||||||
|
|
@ -1644,7 +1642,7 @@ impl Shell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(None)
|
Err(InvalidWorkspaceIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2942,7 +2940,7 @@ impl Shell {
|
||||||
WorkspaceDelta::new_shortcut(),
|
WorkspaceDelta::new_shortcut(),
|
||||||
workspace_state,
|
workspace_state,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.ok()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
@ -3099,7 +3097,7 @@ impl Shell {
|
||||||
WorkspaceDelta::new_shortcut(),
|
WorkspaceDelta::new_shortcut(),
|
||||||
workspace_state,
|
workspace_state,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.ok()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
@ -3209,7 +3207,7 @@ impl Shell {
|
||||||
WorkspaceDelta::new_shortcut(),
|
WorkspaceDelta::new_shortcut(),
|
||||||
workspace_state,
|
workspace_state,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.ok()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ impl ToplevelManagementHandler for State {
|
||||||
|
|
||||||
if seat.active_output() != *output {
|
if seat.active_output() != *output {
|
||||||
match res {
|
match res {
|
||||||
Ok(Some(new_pos)) => {
|
Ok(new_pos) => {
|
||||||
seat.set_active_output(&output);
|
seat.set_active_output(&output);
|
||||||
if let Some(ptr) = seat.get_pointer() {
|
if let Some(ptr) = seat.get_pointer() {
|
||||||
let serial = SERIAL_COUNTER.next_serial();
|
let serial = SERIAL_COUNTER.next_serial();
|
||||||
|
|
@ -106,9 +106,6 @@ impl ToplevelManagementHandler for State {
|
||||||
ptr.frame(self);
|
ptr.frame(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(None) => {
|
|
||||||
seat.set_active_output(&output);
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue