aboutsummaryrefslogtreecommitdiff
path: root/src/layout/floating.rs
diff options
context:
space:
mode:
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;