Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorGeometry Namespace Reference

Namespaces

namespace  GeometryDefaults
 
namespace  JsonKeys
 

Enumerations

enum class  Direction { Left , Right , Up , Down }
 Cardinal navigation direction in screen space (y grows downward). More...
 

Functions

PHOSPHORGEOMETRY_EXPORT std::optional< DirectiondirectionFromString (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)
 

Enumeration Type Documentation

◆ Direction

enum class PhosphorGeometry::Direction
strong

Cardinal navigation direction in screen space (y grows downward).

Enumerator
Left 
Right 
Up 
Down 

Function Documentation

◆ availableAreaToOverlayCoordinates()

PHOSPHORGEOMETRY_EXPORT QRectF PhosphorGeometry::availableAreaToOverlayCoordinates ( const QRectF &  geometry,
const QRect &  overlayGeometry 
)

◆ clampZonesToScreen()

PHOSPHORGEOMETRY_EXPORT void PhosphorGeometry::clampZonesToScreen ( QVector< QRect > &  zones,
const QVector< QSize > &  minSizes,
const QRect &  screen 
)

◆ directionalNeighbor()

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:

  1. 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).
  2. 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.
  3. Nearest along the travel axis — within the preferred tier, the smallest edge gap toward direction wins.
  4. 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
requireOverlapwhen 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.

◆ directionFromString()

PHOSPHORGEOMETRY_EXPORT std::optional< Direction > PhosphorGeometry::directionFromString ( QStringView  token)

Parse a lower-case direction token ("left"/"right"/"up"/"down") into a Direction.

Returns std::nullopt for any other token so callers reject unknown input rather than silently defaulting to a cardinal direction.

◆ enforceMinSizes()

PHOSPHORGEOMETRY_EXPORT void PhosphorGeometry::enforceMinSizes ( QVector< QRect > &  zones,
const QVector< QSize > &  minSizes,
int  gapThreshold,
int  innerGap = 0 
)

◆ neighborDesktopInDirection()

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
rowsgrid 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).

◆ rectToJson()

PHOSPHORGEOMETRY_EXPORT QString PhosphorGeometry::rectToJson ( const QRect &  rect)

◆ removeRectOverlaps()

PHOSPHORGEOMETRY_EXPORT void PhosphorGeometry::removeRectOverlaps ( QVector< QRect > &  zones,
const QVector< QSize > &  minSizes = {},
int  innerGap = 0 
)

◆ snapToRect()

PHOSPHORGEOMETRY_EXPORT QRect PhosphorGeometry::snapToRect ( const QRectF &  rf)