Module placement
Expand description
Pure geometry for arranging displays by dragging: edge snapping, overlap
resolution and keeping the desktop one connected area. Everything is in
desktop coordinates (the units OutputConfig::x/y are stored in), so
the rules are testable without a canvas.
Structs§
- Guide
- A line a dragged display lines up with: where it runs and how far, in desktop units. The canvas draws it as an alignment guide.
- Placement
- One display’s rectangle on the shared desktop plane.
- Snapped
- Where a dragged display stands under the pointer, and what it lines up with there.
Enums§
- Step
- A way an arrow key moves a display on the arrangement canvas.
Functions§
- attach
- If
movingtouches none ofothers, slide it to the nearest one until their edges meet: a display floating apart would leave a stretch of desktop the pointer cannot reach. - is_
valid - Whether
movingmay rest at its place amongothers: it covers none of them and shares an edge with at least one, so the pointer can reach it. Alone, any place is valid. - resolve_
collisions - Move
movingout of every display it overlaps, each time along the shortest way out that does not land on another display. - settle
- Where a dropped display settles: snapped to nearby lines, clear of every
other display, and touching at least one of them. Always a valid place
(
is_valid): when the shortest way out of one display runs into another, it rests at the nearest place flush against a side of one. - snap
- Pull
movingmagnetically onto nearby lines ofothers: its left or right edge onto either of their edges, its centre onto their centre, and likewise top, middle and bottom. Each axis snaps on its own to the closest line withinthreshold; beyond it the display stays exactly where it was put. - snap_
with_ guides snap, with the guides along every line the snapped display now shares with another.- step
- Where an arrow key moves
moving: the next valid place that way among the places flush against a side of another display and aligned with its start, centre or end. Of those, the one that stays most in line across the step, then the nearest.Nonewhen nothing lies that way.