Skip to content

Commit

Permalink
adding a method for moving focused client to a given screen
Browse files Browse the repository at this point in the history
  • Loading branch information
sminez committed Nov 13, 2023
1 parent 3dc62b8 commit 2ac0794
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/pure/stack_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,29 @@ where
self.insert_as_focus_for(tag, c)
}

/// Move the focused client of the current [Workspace] to the focused position
/// of the workspace on [Screen] `screen`.
pub fn move_focused_to_screen(&mut self, screen: usize) {
if self.screens.focus.index == screen {
return;
}

let c = match self.screens.focus.workspace.remove_focused() {
None => return,
Some(c) => c,
};

if let Some(s) = self.screens.iter_mut().find(|s| s.index == screen) {
s.workspace.stack = Some(match take(&mut s.workspace.stack) {
None => stack!(c),
Some(mut s) => {
s.insert_at(Position::Focus, c);
s
}
});
}
}

/// Move the given client to the focused position of the [Workspace] matching
/// the provided `tag`. If the client is already on the target workspace it is
/// moved to the focused position.
Expand Down

0 comments on commit 2ac0794

Please sign in to comment.