Skip to main content

Module placement

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 moving touches none of others, 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 moving may rest at its place among others: 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 moving out 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 moving magnetically onto nearby lines of others: 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 within threshold; 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. None when nothing lies that way.