From 2ac0794a63583bf705ebd92e1fb76144bba9d574 Mon Sep 17 00:00:00 2001 From: Innes Anderson-Morrison Date: Mon, 13 Nov 2023 10:35:10 +0000 Subject: [PATCH] adding a method for moving focused client to a given screen --- src/pure/stack_set.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/pure/stack_set.rs b/src/pure/stack_set.rs index 23e134bd..c566168e 100644 --- a/src/pure/stack_set.rs +++ b/src/pure/stack_set.rs @@ -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.