Skip to content

Commit 8aa501c

Browse files
ids1024Drakulix
authored andcommitted
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.
1 parent 6f5a14e commit 8aa501c

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

src/input/actions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ impl State {
539539
res
540540
};
541541

542-
if let Ok(Some(new_pos)) = res {
542+
if let Ok(new_pos) = res {
543543
let workspace = shell.workspaces.active(&next_output).unwrap().1;
544544
let new_target = workspace
545545
.focus_stack
@@ -1080,7 +1080,7 @@ fn to_next_workspace(
10801080
seat: &Seat<State>,
10811081
gesture: bool,
10821082
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
1083-
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
1083+
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
10841084
let current_output = seat.active_output();
10851085
let workspace = shell
10861086
.workspaces
@@ -1106,7 +1106,7 @@ fn to_previous_workspace(
11061106
seat: &Seat<State>,
11071107
gesture: bool,
11081108
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
1109-
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
1109+
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
11101110
let current_output = seat.active_output();
11111111
let workspace = shell
11121112
.workspaces

src/shell/mod.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ impl Shell {
15121512
idx: usize,
15131513
workspace_delta: WorkspaceDelta,
15141514
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
1515-
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
1515+
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
15161516
match &mut self.workspaces.mode {
15171517
WorkspaceMode::OutputBound => {
15181518
if let Some(set) = self.workspaces.sets.get_mut(output) {
@@ -1525,22 +1525,20 @@ impl Shell {
15251525
set.activate(idx, workspace_delta, workspace_state)?;
15261526

15271527
let output_geo = output.geometry();
1528-
Ok(Some(
1528+
Ok(
15291529
output_geo.loc
15301530
+ Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
1531-
))
1531+
)
15321532
} else {
1533-
Ok(None)
1533+
Err(InvalidWorkspaceIndex)
15341534
}
15351535
}
15361536
WorkspaceMode::Global => {
15371537
for set in self.workspaces.sets.values_mut() {
15381538
set.activate(idx, workspace_delta, workspace_state)?;
15391539
}
15401540
let output_geo = output.geometry();
1541-
Ok(Some(
1542-
output_geo.loc + Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
1543-
))
1541+
Ok(output_geo.loc + Point::from((output_geo.size.w / 2, output_geo.size.h / 2)))
15441542
}
15451543
}
15461544
}
@@ -1565,7 +1563,7 @@ impl Shell {
15651563
output: &Output,
15661564
velocity: f64,
15671565
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
1568-
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
1566+
) -> Result<Point<i32, Global>, InvalidWorkspaceIndex> {
15691567
match &mut self.workspaces.mode {
15701568
WorkspaceMode::OutputBound => {
15711569
if let Some(set) = self.workspaces.sets.get_mut(output) {
@@ -1605,12 +1603,12 @@ impl Shell {
16051603
}
16061604

16071605
let output_geo = output.geometry();
1608-
Ok(Some(
1606+
Ok(
16091607
output_geo.loc
16101608
+ Point::from((output_geo.size.w / 2, output_geo.size.h / 2)),
1611-
))
1609+
)
16121610
} else {
1613-
Ok(None)
1611+
Err(InvalidWorkspaceIndex)
16141612
}
16151613
}
16161614
WorkspaceMode::Global => {
@@ -1644,7 +1642,7 @@ impl Shell {
16441642
}
16451643
}
16461644
}
1647-
Ok(None)
1645+
Err(InvalidWorkspaceIndex)
16481646
}
16491647
}
16501648
}
@@ -2942,7 +2940,7 @@ impl Shell {
29422940
WorkspaceDelta::new_shortcut(),
29432941
workspace_state,
29442942
)
2945-
.unwrap()
2943+
.ok()
29462944
})
29472945
} else {
29482946
None
@@ -3099,7 +3097,7 @@ impl Shell {
30993097
WorkspaceDelta::new_shortcut(),
31003098
workspace_state,
31013099
)
3102-
.unwrap()
3100+
.ok()
31033101
})
31043102
} else {
31053103
None
@@ -3209,7 +3207,7 @@ impl Shell {
32093207
WorkspaceDelta::new_shortcut(),
32103208
workspace_state,
32113209
)
3212-
.unwrap()
3210+
.ok()
32133211
})
32143212
} else {
32153213
None

src/wayland/handlers/toplevel_management.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl ToplevelManagementHandler for State {
9090

9191
if seat.active_output() != *output {
9292
match res {
93-
Ok(Some(new_pos)) => {
93+
Ok(new_pos) => {
9494
seat.set_active_output(&output);
9595
if let Some(ptr) = seat.get_pointer() {
9696
let serial = SERIAL_COUNTER.next_serial();
@@ -106,9 +106,6 @@ impl ToplevelManagementHandler for State {
106106
ptr.frame(self);
107107
}
108108
}
109-
Ok(None) => {
110-
seat.set_active_output(&output);
111-
}
112109
_ => {}
113110
}
114111
}

0 commit comments

Comments
 (0)