aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/layout/floating.rs15
-rw-r--r--src/layout/workspace.rs6
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) {