Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
fix: draw grid cells at exact-period positions
Renderer half of the world-true grid fix: cell k lands at
round(k * period_px_exact) instead of k * rounded-period, so the grid
no longer slides relative to windows when panning at fractional zooms.
Verified in the nested harness at zoom 0.8 (period 422.4): the gap
line's offset from a window edge is pixel-identical across 7 pan
positions spanning more than a full period.
Co-Authored-By: Claude Fable 5 <[email protected]>
src/server/output.rs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/server/output.rs b/src/server/output.rs
index 88b05bc..83bd62b 100644
--- a/src/server/output.rs
+++ b/src/server/output.rs
@@ -795,10 +795,15 @@ impl Output {
} else {
0
};
+ // Cell positions from the EXACT period, rounded per
+ // cell: a rounded-period spacing drifts from the
+ // world-anchored windows at fractional zooms (the
+ // grid visibly slides against window edges when
+ // panning).
for col in 0..=cells.cols {
- let rel_x = col * frame.period_px;
+ let rel_x = (col as f64 * frame.period_px_exact).round() as i32;
for row in 0..=cells.rows {
- let rel_y = row * frame.period_px;
+ let rel_y = (row as f64 * frame.period_px_exact).round() as i32;
get_rect(cells.cell_px, cells.cell_px, cells.color.0.as_ptr(), rel_x, rel_y, cells.corner_radius_px, inset_scaled);
}
}