diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-29 21:11:02 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-30 20:12:37 +0300 |
| commit | c5fffd6e2c48aa7fb8b45b8bdcd972bbd8ce900b (patch) | |
| tree | f4bf7c768d21cd72d81da6ca0d1b084631e71276 /src/layout/monitor.rs | |
| parent | 951f63b6fd48b47ca60e8ed6aa91b4a7b47534f9 (diff) | |
| download | niri-c5fffd6e2c48aa7fb8b45b8bdcd972bbd8ce900b.tar.gz niri-c5fffd6e2c48aa7fb8b45b8bdcd972bbd8ce900b.tar.bz2 niri-c5fffd6e2c48aa7fb8b45b8bdcd972bbd8ce900b.zip | |
Initial WIP floating window implementation
Diffstat (limited to 'src/layout/monitor.rs')
| -rw-r--r-- | src/layout/monitor.rs | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 67b09e20..7bfc1084 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -225,10 +225,11 @@ impl<W: LayoutElement> Monitor<W> { activate: bool, width: ColumnWidth, is_full_width: bool, + is_floating: bool, ) { let workspace = &mut self.workspaces[workspace_idx]; - workspace.add_window(window, activate, width, is_full_width); + workspace.add_window(window, activate, width, is_full_width, is_floating); // After adding a new window, workspace becomes this output's own. workspace.original_output = OutputId::new(&self.output); @@ -253,6 +254,7 @@ impl<W: LayoutElement> Monitor<W> { window: W, width: ColumnWidth, is_full_width: bool, + is_floating: bool, ) { let workspace_idx = self .workspaces @@ -261,7 +263,7 @@ impl<W: LayoutElement> Monitor<W> { .unwrap(); let workspace = &mut self.workspaces[workspace_idx]; - workspace.add_window_right_of(right_of, window, width, is_full_width); + workspace.add_window_right_of(right_of, window, width, is_full_width, is_floating); // After adding a new window, workspace becomes this output's own. workspace.original_output = OutputId::new(&self.output); @@ -322,6 +324,35 @@ impl<W: LayoutElement> Monitor<W> { } } + pub fn add_floating_tile( + &mut self, + mut workspace_idx: usize, + tile: Tile<W>, + pos: Option<Point<f64, Logical>>, + activate: bool, + ) { + let workspace = &mut self.workspaces[workspace_idx]; + + workspace.add_floating_tile(tile, pos, activate); + + // 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. + self.add_workspace_bottom(); + } + + if self.options.empty_workspace_above_first && workspace_idx == 0 { + self.add_workspace_top(); + workspace_idx += 1; + } + + if activate { + self.activate_workspace(workspace_idx); + } + } + pub fn add_tile_to_column( &mut self, workspace_idx: usize, @@ -505,6 +536,7 @@ impl<W: LayoutElement> Monitor<W> { true, removed.width, removed.is_full_width, + removed.is_floating, ); } @@ -527,6 +559,7 @@ impl<W: LayoutElement> Monitor<W> { true, removed.width, removed.is_full_width, + removed.is_floating, ); } @@ -565,6 +598,7 @@ impl<W: LayoutElement> Monitor<W> { activate, removed.width, removed.is_full_width, + removed.is_floating, ); if self.workspace_switch.is_none() { @@ -581,6 +615,11 @@ impl<W: LayoutElement> Monitor<W> { } let workspace = &mut self.workspaces[source_workspace_idx]; + if workspace.floating_is_active() { + self.move_to_workspace_up(); + return; + } + let Some(column) = workspace.remove_active_column() else { return; }; @@ -597,6 +636,11 @@ impl<W: LayoutElement> Monitor<W> { } let workspace = &mut self.workspaces[source_workspace_idx]; + if workspace.floating_is_active() { + self.move_to_workspace_down(); + return; + } + let Some(column) = workspace.remove_active_column() else { return; }; @@ -613,6 +657,11 @@ impl<W: LayoutElement> Monitor<W> { } let workspace = &mut self.workspaces[source_workspace_idx]; + if workspace.floating_is_active() { + self.move_to_workspace(None, idx); + return; + } + let Some(column) = workspace.remove_active_column() else { return; }; |
