|
| PHOSPHORGEOMETRY_EXPORT std::optional< Direction > | directionFromString (QStringView token) |
| | Parse a lower-case direction token ("left"/"right"/"up"/"down") into a Direction.
|
| |
| PHOSPHORGEOMETRY_EXPORT int | directionalNeighbor (const QRectF &focus, const QList< QRectF > &candidates, Direction direction, bool requireOverlap=false) |
| | Pick the spatial neighbour of focus among candidates in direction.
|
| |
| PHOSPHORGEOMETRY_EXPORT int | neighborDesktopInDirection (int currentDesktop, int desktopCount, int rows, Direction direction) |
| | The virtual desktop reached by stepping direction from currentDesktop on a rows-high desktop grid.
|
| |
| PHOSPHORGEOMETRY_EXPORT QRectF | availableAreaToOverlayCoordinates (const QRectF &geometry, const QRect &overlayGeometry) |
| |
| PHOSPHORGEOMETRY_EXPORT QRect | snapToRect (const QRectF &rf) |
| |
| PHOSPHORGEOMETRY_EXPORT void | enforceMinSizes (QVector< QRect > &zones, const QVector< QSize > &minSizes, int gapThreshold, int innerGap=0) |
| |
| PHOSPHORGEOMETRY_EXPORT void | clampZonesToScreen (QVector< QRect > &zones, const QVector< QSize > &minSizes, const QRect &screen) |
| |
| PHOSPHORGEOMETRY_EXPORT void | removeRectOverlaps (QVector< QRect > &zones, const QVector< QSize > &minSizes={}, int innerGap=0) |
| |
| PHOSPHORGEOMETRY_EXPORT QString | rectToJson (const QRect &rect) |
| |
| PHOSPHORGEOMETRY_EXPORT int PhosphorGeometry::directionalNeighbor |
( |
const QRectF & |
focus, |
|
|
const QList< QRectF > & |
candidates, |
|
|
Direction |
direction, |
|
|
bool |
requireOverlap = false |
|
) |
| |
Pick the spatial neighbour of focus among candidates in direction.
Selection, in priority order:
- In-direction filter — a candidate qualifies only if it lies on the
direction side of focus (its centre is past focus's centre on the travel axis).
- Perpendicular-overlap preference — qualifying candidates whose span on the axis orthogonal to travel overlaps
focus's span (genuinely side-by-side) beat any candidate that does not overlap. This is what makes "right" from a top-left tile pick the top-right tile, never the bottom-right one, regardless of insertion order.
- Nearest along the travel axis — within the preferred tier, the smallest edge gap toward
direction wins.
- Perpendicular-centre tie-break — equal gaps break by the smaller orthogonal centre distance. The result is deterministic for a given candidate list; two candidates identical on every tier (same overlap, gap within epsilon, equal perpendicular centre distance) resolve to the lower index.
Coordinate-system agnostic: focus and every entry of candidates must live in one shared space (absolute pixels, normalized [0,1], etc.).
- Parameters
-
| requireOverlap | when true, candidates that do not overlap focus on the perpendicular axis (i.e. purely diagonal ones) are rejected outright rather than used as a last-resort fallback. Window navigation wants this: a diagonal tile is not a real left/right/up/down neighbour, so the move should hit the layout boundary (and cross to the next output) instead of swapping with a window that's offset away. Zone-adjacency / cross-output callers leave it false (default) so an offset-but-present neighbour still resolves. |
- Returns
- index into
candidates, or -1 when no candidate lies in direction. Candidates sharing focus's centre are skipped.
| PHOSPHORGEOMETRY_EXPORT int PhosphorGeometry::neighborDesktopInDirection |
( |
int |
currentDesktop, |
|
|
int |
desktopCount, |
|
|
int |
rows, |
|
|
Direction |
direction |
|
) |
| |
The virtual desktop reached by stepping direction from currentDesktop on a rows-high desktop grid.
Desktops are 1-based and laid out row-major across ceil(desktopCount/rows) columns, matching KWin's DEFAULT (horizontal-fill) desktop-grid layout. KWin can also be configured to fill the grid column-first; that orientation is not expressible through rows alone and is not modelled here — under it the Up/Down vs Left/Right mapping would differ. A step that leaves the grid — past an edge, into a missing cell on a partial last row, or a horizontal move that would wrap onto another row — returns 0 (no neighbour) rather than wrapping, so callers can treat 0 as "no desktop that way; try another axis".
- Parameters
-
| rows | grid height; values < 1 are clamped to 1 (a single-row grid). |
- Returns
- the 1-based target desktop, or 0 when there is no neighbour in
direction (including for out-of-range inputs).