diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-09-26 11:07:10 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-10-02 09:33:08 +0300 |
| commit | ea3bbea6bdbdbdd02a62e99ff51cd48d655ae84f (patch) | |
| tree | 84b089bdfbea96023bf976b606cd6a76ac02307d /src/layout/monitor.rs | |
| parent | 3b4cf1ec8f0eea992740a33e143917edb761eb7d (diff) | |
| download | niri-ea3bbea6bdbdbdd02a62e99ff51cd48d655ae84f.tar.gz niri-ea3bbea6bdbdbdd02a62e99ff51cd48d655ae84f.tar.bz2 niri-ea3bbea6bdbdbdd02a62e99ff51cd48d655ae84f.zip | |
layout: Extract Monitor::insert_workspace()
Diffstat (limited to 'src/layout/monitor.rs')
| -rw-r--r-- | src/layout/monitor.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 3c258d49..45118a22 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -629,6 +629,34 @@ impl<W: LayoutElement> Monitor<W> { ws } + pub fn insert_workspace(&mut self, mut ws: Workspace<W>, mut idx: usize, activate: bool) { + ws.set_output(Some(self.output.clone())); + + // Don't insert past the last empty workspace. + if idx == self.workspaces.len() { + idx -= 1; + } + if idx == 0 && self.options.layout.empty_workspace_above_first { + // Insert a new empty workspace on top to prepare for insertion of new workspace. + self.add_workspace_top(); + idx += 1; + } + + self.workspaces.insert(idx, ws); + + if idx <= self.active_workspace_idx { + self.active_workspace_idx += 1; + } + + if activate { + self.workspace_switch = None; + self.activate_workspace(idx); + } + + self.workspace_switch = None; + self.clean_up_workspaces(); + } + pub fn move_down_or_to_workspace_down(&mut self) { if !self.active_workspace().move_down() { self.move_to_workspace_down(true); |
