diff options
| author | Dennis Ranke <dennis.ranke@gmail.com> | 2024-02-03 20:25:08 +0100 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-02-05 14:09:47 +0400 |
| commit | 3a23417e980de908c3183749da9309e9dabc9ece (patch) | |
| tree | d7dcc59da493ecf5f79d730db76aa84514250c1b /src/layout/workspace.rs | |
| parent | 6bb83757ee907e5ce3be617251c441c02917388e (diff) | |
| download | niri-3a23417e980de908c3183749da9309e9dabc9ece.tar.gz niri-3a23417e980de908c3183749da9309e9dabc9ece.tar.bz2 niri-3a23417e980de908c3183749da9309e9dabc9ece.zip | |
Add consume-or-expel-window-left/right commands
Diffstat (limited to 'src/layout/workspace.rs')
| -rw-r--r-- | src/layout/workspace.rs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index fbae0064..4eb8c347 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -866,6 +866,70 @@ impl<W: LayoutElement> Workspace<W> { self.columns[self.active_column_idx].move_up(); } + pub fn consume_or_expel_window_left(&mut self) { + if self.columns.is_empty() { + return; + } + + let source_column = &self.columns[self.active_column_idx]; + if source_column.tiles.len() == 1 { + if self.active_column_idx == 0 { + return; + } + + // Move into adjacent column. + let target_column_idx = self.active_column_idx - 1; + let window = self.remove_window_by_idx(self.active_column_idx, 0); + self.enter_output_for_window(&window); + + let target_column = &mut self.columns[target_column_idx]; + target_column.add_window(window); + target_column.focus_last(); + self.activate_column(target_column_idx); + } else { + // Move out of column. + let width = source_column.width; + let is_full_width = source_column.is_full_width; + let window = + self.remove_window_by_idx(self.active_column_idx, source_column.active_tile_idx); + + self.add_window(window, true, width, is_full_width); + // Window was added to the right of current column, so move the new column left. + self.move_left(); + } + } + + pub fn consume_or_expel_window_right(&mut self) { + if self.columns.is_empty() { + return; + } + + let source_column = &self.columns[self.active_column_idx]; + if source_column.tiles.len() == 1 { + if self.active_column_idx + 1 == self.columns.len() { + return; + } + + // Move into adjacent column. + let target_column_idx = self.active_column_idx; + let window = self.remove_window_by_idx(self.active_column_idx, 0); + self.enter_output_for_window(&window); + + let target_column = &mut self.columns[target_column_idx]; + target_column.add_window(window); + target_column.focus_last(); + self.activate_column(target_column_idx); + } else { + // Move out of column. + let width = source_column.width; + let is_full_width = source_column.is_full_width; + let window = + self.remove_window_by_idx(self.active_column_idx, source_column.active_tile_idx); + + self.add_window(window, true, width, is_full_width); + } + } + pub fn consume_into_column(&mut self) { if self.columns.len() < 2 { return; @@ -1414,6 +1478,10 @@ impl<W: LayoutElement> Column<W> { self.active_tile_idx = min(self.active_tile_idx + 1, self.tiles.len() - 1); } + fn focus_last(&mut self) { + self.active_tile_idx = self.tiles.len() - 1; + } + fn move_up(&mut self) { let new_idx = self.active_tile_idx.saturating_sub(1); if self.active_tile_idx == new_idx { |
