diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-15 10:30:32 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-30 20:12:37 +0300 |
| commit | 56e249aee68cd03687dd87dc47e2d13d599e5b87 (patch) | |
| tree | 8810b8ea8dfca4b5c9cc7f7eac62740beaa48ad8 /src | |
| parent | 6a7c8fcfd529ec31d274b347f4a591ad40366c09 (diff) | |
| download | niri-56e249aee68cd03687dd87dc47e2d13d599e5b87.tar.gz niri-56e249aee68cd03687dd87dc47e2d13d599e5b87.tar.bz2 niri-56e249aee68cd03687dd87dc47e2d13d599e5b87.zip | |
floating: Implement center_window()
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout/floating.rs | 15 | ||||
| -rw-r--r-- | src/layout/workspace.rs | 6 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/layout/floating.rs b/src/layout/floating.rs index c0a56165..271ab314 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -691,6 +691,21 @@ impl<W: LayoutElement> FloatingSpace<W> { } } + pub fn center_window(&mut self) { + let Some(active_id) = &self.active_window_id else { + return; + }; + let active_idx = self.idx_of(active_id).unwrap(); + + let tile = &mut self.tiles[active_idx]; + let data = &mut self.data[active_idx]; + + let prev_pos = data.logical_pos; + let new_pos = center_preferring_top_left_in_area(self.working_area, data.size); + data.set_logical_pos(new_pos); + tile.animate_move_from(prev_pos - new_pos); + } + pub fn descendants_added(&mut self, id: &W::Id) -> bool { let Some(idx) = self.idx_of(id) else { return false; diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index baae33c8..46ed669e 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -909,11 +909,11 @@ impl<W: LayoutElement> Workspace<W> { } pub fn center_column(&mut self) { - // TODO if self.floating_is_active { - return; + self.floating.center_window(); + } else { + self.scrolling.center_column(); } - self.scrolling.center_column(); } pub fn toggle_width(&mut self) { |
