diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-10-17 08:27:49 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-10-17 08:59:06 +0300 |
| commit | 8555f37dbf525d86e4aa5689e6b969baf26af5d9 (patch) | |
| tree | 760c046a781d0fd2318ee359d02eec009c642069 /src/layout | |
| parent | 4b837f429c525d37785b17a29fec7d137cd7a1fe (diff) | |
| download | niri-8555f37dbf525d86e4aa5689e6b969baf26af5d9.tar.gz niri-8555f37dbf525d86e4aa5689e6b969baf26af5d9.tar.bz2 niri-8555f37dbf525d86e4aa5689e6b969baf26af5d9.zip | |
layout: Use remove_column_by_idx in remove_tile_by_idx
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/workspace.rs | 84 |
1 files changed, 13 insertions, 71 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 9cd2b0d3..9a7c56f5 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -1128,7 +1128,15 @@ impl<W: LayoutElement> Workspace<W> { transaction: Transaction, anim_config: Option<niri_config::Animation>, ) -> RemovedTile<W> { - let offset = self.column_x(column_idx + 1) - self.column_x(column_idx); + // If this is the only tile in the column, remove the whole column. + if self.columns[column_idx].tiles.len() == 1 { + let mut column = self.remove_column_by_idx(column_idx, anim_config); + return RemovedTile { + tile: column.tiles.remove(tile_idx), + width: column.width, + is_full_width: column.is_full_width, + }; + } let column = &mut self.columns[column_idx]; let prev_width = self.data[column_idx].width; @@ -1168,16 +1176,10 @@ impl<W: LayoutElement> Workspace<W> { is_full_width: column.is_full_width, }; - let became_empty = column.tiles.is_empty(); - let offset = if became_empty { - offset - } else { - column.active_tile_idx = min(column.active_tile_idx, column.tiles.len() - 1); - column.update_tile_sizes_with_transaction(true, transaction); - self.data[column_idx].update(column); - - prev_width - column.width() - }; + column.active_tile_idx = min(column.active_tile_idx, column.tiles.len() - 1); + column.update_tile_sizes_with_transaction(true, transaction); + self.data[column_idx].update(column); + let offset = prev_width - column.width(); // Animate movement of the other columns. let movement_config = anim_config.unwrap_or(self.options.animations.window_movement.0); @@ -1191,66 +1193,6 @@ impl<W: LayoutElement> Workspace<W> { } } - if became_empty { - if column_idx + 1 == self.active_column_idx { - // The previous column, that we were going to activate upon removal of the active - // column, has just been itself removed. - self.activate_prev_column_on_removal = None; - } - - if column_idx == self.active_column_idx { - self.view_offset_before_fullscreen = None; - } - - self.columns.remove(column_idx); - self.data.remove(column_idx); - if self.columns.is_empty() { - return tile; - } - - let view_config = - anim_config.unwrap_or(self.options.animations.horizontal_view_movement.0); - - if column_idx < self.active_column_idx { - // A column to the left was removed; preserve the current position. - // FIXME: preserve activate_prev_column_on_removal. - self.active_column_idx -= 1; - self.activate_prev_column_on_removal = None; - } else if column_idx == self.active_column_idx - && self.activate_prev_column_on_removal.is_some() - { - // The active column was removed, and we needed to activate the previous column. - if 0 < column_idx { - let prev_offset = self.activate_prev_column_on_removal.unwrap(); - - self.activate_column_with_anim_config(self.active_column_idx - 1, view_config); - - // Restore the view offset but make sure to scroll the view in case the - // previous window had resized. - let current_x = self.view_pos(); - self.animate_view_offset_with_config( - current_x, - self.active_column_idx, - prev_offset, - view_config, - ); - self.animate_view_offset_to_column_with_config( - current_x, - self.active_column_idx, - None, - view_config, - ); - } - } else { - self.activate_column_with_anim_config( - min(self.active_column_idx, self.columns.len() - 1), - view_config, - ); - } - - return tile; - } - tile } |
