diff options
| author | Rasmus Eneman <rasmus@eneman.eu> | 2024-07-15 15:51:48 +0200 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-10-27 23:07:39 -0700 |
| commit | e887ee93a30390b641bf647d694a1424f7ce4592 (patch) | |
| tree | 94a76c90c2433ad3a0d92015d7ca6ba569ab2979 /src/layout/monitor.rs | |
| parent | d640e8515899e552b845cf8f901ebeb126bb12a5 (diff) | |
| download | niri-e887ee93a30390b641bf647d694a1424f7ce4592.tar.gz niri-e887ee93a30390b641bf647d694a1424f7ce4592.tar.bz2 niri-e887ee93a30390b641bf647d694a1424f7ce4592.zip | |
Implement interactive window move
Diffstat (limited to 'src/layout/monitor.rs')
| -rw-r--r-- | src/layout/monitor.rs | 53 |
1 files changed, 52 insertions, 1 deletions
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<W: LayoutElement> Monitor<W> { } } + pub fn add_tile( + &mut self, + workspace_idx: usize, + column_idx: Option<usize>, + tile: Tile<W>, + 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<usize>, + tile: Tile<W>, + 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<W: LayoutElement> Monitor<W> { } } - 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()) |
