aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-02-04 09:29:30 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-02-04 10:42:44 +0300
commit7d24ad23c2bc690b22b1f13ad4598dc8323d128b (patch)
treebd7a4e60d606c96338989bcc3a76ede214f82036
parent691bc064bbf59ea0ee663cec20b8e1ff54680194 (diff)
downloadniri-7d24ad23c2bc690b22b1f13ad4598dc8323d128b.tar.gz
niri-7d24ad23c2bc690b22b1f13ad4598dc8323d128b.tar.bz2
niri-7d24ad23c2bc690b22b1f13ad4598dc8323d128b.zip
layout/scrolling: Extract tiles_origin()
-rw-r--r--src/layout/scrolling.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs
index 9a99588d..d90150d8 100644
--- a/src/layout/scrolling.rs
+++ b/src/layout/scrolling.rs
@@ -3934,6 +3934,14 @@ impl<W: LayoutElement> Column<W> {
None
}
+ fn tiles_origin(&self) -> Point<f64, Logical> {
+ if self.is_fullscreen {
+ Point::from((0., 0.))
+ } else {
+ Point::from((0., self.working_area.loc.y + self.options.gaps))
+ }
+ }
+
// HACK: pass a self.data iterator in manually as a workaround for the lack of method partial
// borrowing. Note that this method's return value does not borrow the entire &Self!
fn tile_offsets_iter(
@@ -3950,11 +3958,7 @@ impl<W: LayoutElement> Column<W> {
} else {
self.width()
};
- let mut y = 0.;
-
- if !self.is_fullscreen {
- y = self.working_area.loc.y + self.options.gaps;
- }
+ let mut origin = self.tiles_origin();
// Chain with a dummy value to be able to get one past all tiles' Y.
let dummy = TileData {
@@ -3965,15 +3969,16 @@ impl<W: LayoutElement> Column<W> {
let data = data.chain(iter::once(dummy));
data.map(move |data| {
- let mut pos = Point::from((0., y));
+ let mut pos = origin;
if center {
- pos.x = (col_width - data.size.w) / 2.;
+ pos.x += (col_width - data.size.w) / 2.;
} else if data.interactively_resizing_by_left_edge {
- pos.x = col_width - data.size.w;
+ pos.x += col_width - data.size.w;
}
- y += data.size.h + gaps;
+ origin.y += data.size.h + gaps;
+
pos
})
}