From e887ee93a30390b641bf647d694a1424f7ce4592 Mon Sep 17 00:00:00 2001 From: Rasmus Eneman Date: Mon, 15 Jul 2024 15:51:48 +0200 Subject: Implement interactive window move --- src/layout/monitor.rs | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'src/layout/monitor.rs') diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 78216dc5..d95b1bac 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -9,6 +9,7 @@ use smithay::backend::renderer::element::utils::{ use smithay::output::Output; use smithay::utils::{Logical, Point, Rectangle}; +use super::tile::Tile; use super::workspace::{ compute_working_area, Column, ColumnWidth, OutputId, Workspace, WorkspaceId, WorkspaceRenderElement, @@ -241,6 +242,56 @@ impl Monitor { } } + pub fn add_tile( + &mut self, + workspace_idx: usize, + column_idx: Option, + tile: Tile, + activate: bool, + width: ColumnWidth, + is_full_width: bool, + ) { + let workspace = &mut self.workspaces[workspace_idx]; + + workspace.add_tile(column_idx, tile, activate, width, is_full_width, None); + + // After adding a new window, workspace becomes this output's own. + workspace.original_output = OutputId::new(&self.output); + + if workspace_idx == self.workspaces.len() - 1 { + // Insert a new empty workspace. + let ws = Workspace::new(self.output.clone(), self.options.clone()); + self.workspaces.push(ws); + } + + if activate { + self.activate_workspace(workspace_idx); + } + } + + pub fn add_tile_to_column( + &mut self, + workspace_idx: usize, + column_idx: usize, + tile_idx: Option, + tile: Tile, + activate: bool, + ) { + let workspace = &mut self.workspaces[workspace_idx]; + + workspace.add_tile_to_column(column_idx, tile_idx, tile, activate); + + // After adding a new window, workspace becomes this output's own. + workspace.original_output = OutputId::new(&self.output); + + // Since we're adding window to an existing column, the workspace isn't empty, and + // therefore cannot be the last one, so we never need to insert a new empty workspace. + + if activate { + self.activate_workspace(workspace_idx); + } + } + pub fn clean_up_workspaces(&mut self) { assert!(self.workspace_switch.is_none()); @@ -682,7 +733,7 @@ impl Monitor { } } - pub fn are_animations_ongoing(&self) -> bool { + pub(super) fn are_animations_ongoing(&self) -> bool { self.workspace_switch .as_ref() .is_some_and(|s| s.is_animation()) -- cgit