workspace: Add toggle_stacking/toggle_stacking_focused
This commit is contained in:
parent
677f686afd
commit
0147c328f9
2 changed files with 30 additions and 2 deletions
|
|
@ -1821,8 +1821,9 @@ impl State {
|
|||
Action::ToggleStacking => {
|
||||
let output = seat.active_output();
|
||||
let workspace = self.common.shell.active_space_mut(&output);
|
||||
let focus_stack = workspace.focus_stack.get_mut(seat);
|
||||
workspace.tiling_layer.toggle_stacking(seat, focus_stack);
|
||||
if let Some(new_focus) = workspace.toggle_stacking_focused(seat) {
|
||||
Common::set_focus(self, Some(&new_focus), seat, Some(serial));
|
||||
}
|
||||
}
|
||||
Action::ToggleTiling => {
|
||||
let output = seat.active_output();
|
||||
|
|
|
|||
|
|
@ -777,6 +777,33 @@ impl Workspace {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn toggle_stacking(&mut self, window: &CosmicMapped) -> Option<KeyboardFocusTarget> {
|
||||
if self.tiling_layer.mapped().any(|(_, m, _)| m == window) {
|
||||
self.tiling_layer.toggle_stacking(window)
|
||||
} else if self.floating_layer.mapped().any(|w| w == window) {
|
||||
self.floating_layer.toggle_stacking(window)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toggle_stacking_focused(&mut self, seat: &Seat<State>) -> Option<KeyboardFocusTarget> {
|
||||
let maybe_window = self.focus_stack.get(seat).iter().next().cloned();
|
||||
if let Some(window) = maybe_window {
|
||||
if self.tiling_layer.mapped().any(|(_, m, _)| m == &window) {
|
||||
self.tiling_layer
|
||||
.toggle_stacking_focused(seat, self.focus_stack.get_mut(seat))
|
||||
} else if self.floating_layer.mapped().any(|w| w == &window) {
|
||||
self.floating_layer
|
||||
.toggle_stacking_focused(seat, self.focus_stack.get_mut(seat))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mapped(&self) -> impl Iterator<Item = &CosmicMapped> {
|
||||
self.floating_layer
|
||||
.mapped()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue