aboutsummaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorMartino Ferrari <manda.mgf@gmail.com>2025-03-01 18:46:27 +0100
committerGitHub <noreply@github.com>2025-03-01 17:46:27 +0000
commit36b28d9b96107441e3f8502a61f598fb666ec492 (patch)
tree237da44be4a0b4ab10a752b3585789cbebf251c5 /src/layout
parent66113d7d76f6cf7d06e2ccde9281ff9bafab126c (diff)
downloadniri-36b28d9b96107441e3f8502a61f598fb666ec492.tar.gz
niri-36b28d9b96107441e3f8502a61f598fb666ec492.tar.bz2
niri-36b28d9b96107441e3f8502a61f598fb666ec492.zip
Added top, left, bottom and right floating windows alignement (#1169)
* feat: added top, left, bottom, right alignement options * feat: implemented extra alignement * feat: added example * doc: updated documentation with extra alignements * doc: moved example in wiki and typo correction * fix: relative position should be positive and not negative * fixes --------- Co-authored-by: Martino Ferrari <martinogiordano.ferrari@iter.org> Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/floating.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/layout/floating.rs b/src/layout/floating.rs
index 2a4054bd..4fd7c7ee 100644
--- a/src/layout/floating.rs
+++ b/src/layout/floating.rs
@@ -1206,12 +1206,24 @@ impl<W: LayoutElement> FloatingSpace<W> {
let area = self.working_area;
let mut pos = Point::from((pos.x.0, pos.y.0));
- if relative_to == RelativeTo::TopRight || relative_to == RelativeTo::BottomRight {
+ if relative_to == RelativeTo::TopRight
+ || relative_to == RelativeTo::BottomRight
+ || relative_to == RelativeTo::Right
+ {
pos.x = area.size.w - size.w - pos.x;
}
- if relative_to == RelativeTo::BottomLeft || relative_to == RelativeTo::BottomRight {
+ if relative_to == RelativeTo::BottomLeft
+ || relative_to == RelativeTo::BottomRight
+ || relative_to == RelativeTo::Bottom
+ {
pos.y = area.size.h - size.h - pos.y;
}
+ if relative_to == RelativeTo::Top || relative_to == RelativeTo::Bottom {
+ pos.x += area.size.w / 2.0 - size.w / 2.0
+ }
+ if relative_to == RelativeTo::Left || relative_to == RelativeTo::Right {
+ pos.y += area.size.h / 2.0 - size.h / 2.0
+ }
pos + self.working_area.loc
})