aboutsummaryrefslogtreecommitdiff
path: root/src/layout/floating.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-12-15 10:30:32 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-12-30 20:12:37 +0300
commit56e249aee68cd03687dd87dc47e2d13d599e5b87 (patch)
tree8810b8ea8dfca4b5c9cc7f7eac62740beaa48ad8 /src/layout/floating.rs
parent6a7c8fcfd529ec31d274b347f4a591ad40366c09 (diff)
downloadniri-56e249aee68cd03687dd87dc47e2d13d599e5b87.tar.gz
niri-56e249aee68cd03687dd87dc47e2d13d599e5b87.tar.bz2
niri-56e249aee68cd03687dd87dc47e2d13d599e5b87.zip
floating: Implement center_window()
Diffstat (limited to 'src/layout/floating.rs')
-rw-r--r--src/layout/floating.rs15
1 files changed, 15 insertions, 0 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;