Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorZones::Layout Class Reference

Represents a collection of zones that form a layout. More...

#include <phosphor-zones/include/PhosphorZones/Layout.h>

Inheritance diagram for PhosphorZones::Layout:
[legend]

Public Types

using ScreenIdResolver = std::function< QString(const QString &)>
 Screen-id resolver.
 

Signals

void nameChanged ()
 
void descriptionChanged ()
 
void zonePaddingChanged ()
 
void outerGapChanged ()
 
void showZoneNumbersChanged ()
 
void overlayDisplayModeChanged ()
 
void sourcePathChanged ()
 
void shaderIdChanged ()
 
void shaderParamsChanged ()
 
void aspectRatioClassChanged ()
 
void hiddenFromSelectorChanged ()
 
void allowedScreensChanged ()
 
void allowedDesktopsChanged ()
 
void allowedActivitiesChanged ()
 
void appRulesChanged ()
 
void autoAssignChanged ()
 
void useFullScreenGeometryChanged ()
 
void zonesChanged ()
 
void zoneAdded (Zone *zone)
 
void zoneRemoved (Zone *zone)
 
void layoutModified ()
 

Public Member Functions

 Layout (QObject *parent=nullptr)
 
 Layout (const QString &name, QObject *parent=nullptr)
 
 Layout (const Layout &other)
 
 ~Layout () override
 
Layoutoperator= (const Layout &other)
 
QUuid id () const
 
QString name () const
 
void setName (const QString &name)
 
QString description () const
 
void setDescription (const QString &description)
 
int zonePadding () const
 
void setZonePadding (int padding)
 
bool hasZonePaddingOverride () const
 
void clearZonePaddingOverride ()
 
int outerGap () const
 
void setOuterGap (int gap)
 
bool hasOuterGapOverride () const
 
void clearOuterGapOverride ()
 
bool usePerSideOuterGap () const
 
void setUsePerSideOuterGap (bool enabled)
 
int outerGapTop () const
 
void setOuterGapTop (int gap)
 
int outerGapBottom () const
 
void setOuterGapBottom (int gap)
 
int outerGapLeft () const
 
void setOuterGapLeft (int gap)
 
int outerGapRight () const
 
void setOuterGapRight (int gap)
 
bool hasPerSideOuterGapOverride () const
 
::PhosphorLayout::EdgeGaps rawOuterGaps () const
 Raw per-side gap overrides.
 
bool showZoneNumbers () const
 
void setShowZoneNumbers (bool show)
 
int overlayDisplayMode () const
 
void setOverlayDisplayMode (int mode)
 
bool hasOverlayDisplayModeOverride () const
 
void clearOverlayDisplayModeOverride ()
 
QString sourcePath () const
 
void setSourcePath (const QString &path)
 
bool isSystemLayout () const
 
QString systemSourcePath () const
 
void setSystemSourcePath (const QString &path)
 
bool hasSystemOrigin () const
 
QString shaderId () const
 
void setShaderId (const QString &id)
 
QVariantMap shaderParams () const
 
void setShaderParams (const QVariantMap &params)
 
::PhosphorLayout::AspectRatioClass aspectRatioClass () const
 
void setAspectRatioClass (::PhosphorLayout::AspectRatioClass cls)
 
int aspectRatioClassInt () const
 
void setAspectRatioClassInt (int cls)
 
qreal minAspectRatio () const
 
void setMinAspectRatio (qreal ratio)
 
qreal maxAspectRatio () const
 
void setMaxAspectRatio (qreal ratio)
 
bool matchesAspectRatio (qreal screenAspectRatio) const
 Check if this layout is suitable for a screen with the given aspect ratio.
 
bool hiddenFromSelector () const
 
void setHiddenFromSelector (bool hidden)
 
QStringList allowedScreens () const
 
void setAllowedScreens (const QStringList &screens)
 
QList< int > allowedDesktops () const
 
void setAllowedDesktops (const QList< int > &desktops)
 
QStringList allowedActivities () const
 
void setAllowedActivities (const QStringList &activities)
 
QVector< AppRuleappRules () const
 
void setAppRules (const QVector< AppRule > &rules)
 
QVariantList appRulesVariant () const
 
void setAppRulesVariant (const QVariantList &rules)
 
AppRuleMatch matchAppRule (const QString &windowClass) const
 
bool autoAssign () const
 
void setAutoAssign (bool enabled)
 
bool useFullScreenGeometry () const
 
void setUseFullScreenGeometry (bool enabled)
 
bool hasFixedGeometryZones () const
 Returns true if any zone uses fixed (pixel) geometry mode.
 
QRectF fixedZoneBoundingBox () const
 Bounding box of all fixed-geometry zones in pixel coordinates, anchored at (0, 0).
 
QRectF fixedZoneReferenceGeometry () const
 Reference geometry suitable for normalizing fixed-pixel zones to 0–1 relative coordinates.
 
int defaultOrder () const
 
void setDefaultOrder (int order)
 
int zoneCount () const
 
QVector< Zone * > zones () const
 
Zonezone (int index) const
 
ZonezoneById (const QUuid &id) const
 
ZonezoneByNumber (int number) const
 
void addZone (Zone *zone)
 
void removeZone (Zone *zone)
 
void removeZoneAt (int index)
 
void clearZones ()
 
void moveZone (int fromIndex, int toIndex)
 
ZonezoneAtPoint (const QPointF &point) const
 
ZonenearestZone (const QPointF &point, qreal maxDistance=-1) const
 
QVector< Zone * > zonesInRect (const QRectF &rect) const
 
QVector< Zone * > adjacentZones (const QPointF &point, qreal threshold=20) const
 
void renumberZones ()
 
QRectF lastRecalcGeometry () const
 
void setLastRecalcGeometry (const QRectF &geom)
 
QJsonObject toJson () const
 
bool isDirty () const
 
void markDirty ()
 
void clearDirty ()
 
void beginBatchModify ()
 
void endBatchModify ()
 
void recalculateZoneGeometries (const QRectF &screenGeometry)
 Recalculate every zone's absolute geometry against screenGeometry.
 

Static Public Member Functions

static LayoutfromJson (const QJsonObject &json, QObject *parent=nullptr)
 
static void setScreenIdResolver (ScreenIdResolver resolver)
 
static ScreenIdResolver screenIdResolver ()
 Returns a copy of the currently-installed resolver (empty if none).
 
static LayoutcreateColumnsLayout (int columns, QObject *parent=nullptr)
 
static LayoutcreateRowsLayout (int rows, QObject *parent=nullptr)
 
static LayoutcreateGridLayout (int columns, int rows, QObject *parent=nullptr)
 
static LayoutcreatePriorityGridLayout (QObject *parent=nullptr)
 
static LayoutcreateFocusLayout (QObject *parent=nullptr)
 

Detailed Description

Represents a collection of zones that form a layout.

Layouts can be assigned to specific monitors, virtual desktops, and activities. Supports both predefined templates and custom canvas-style layouts.

Member Typedef Documentation

◆ ScreenIdResolver

using PhosphorZones::Layout::ScreenIdResolver = std::function<QString(const QString&)>

Screen-id resolver.

Install a callback that maps a legacy connector name (e.g. "DP-2") to the application's stable screen identifier (EDID-based, "LG:Model:Serial"). The library calls it for every entry in allowedScreens during fromJson so in-memory layouts hold normalized IDs regardless of what the file stores.

The callback typically requires a live QGuiApplication (to enumerate connected QScreens). Install from the daemon / editor / settings processes only; leave unset for headless / test code, in which case strings are stored verbatim.

Passing a default-constructed function clears the resolver.

Constructor & Destructor Documentation

◆ Layout() [1/3]

PhosphorZones::Layout::Layout ( QObject *  parent = nullptr)
explicit

◆ Layout() [2/3]

PhosphorZones::Layout::Layout ( const QString &  name,
QObject *  parent = nullptr 
)
explicit

◆ Layout() [3/3]

PhosphorZones::Layout::Layout ( const Layout other)

◆ ~Layout()

PhosphorZones::Layout::~Layout ( )
override

Member Function Documentation

◆ addZone()

void PhosphorZones::Layout::addZone ( Zone zone)

◆ adjacentZones()

QVector< Zone * > PhosphorZones::Layout::adjacentZones ( const QPointF &  point,
qreal  threshold = 20 
) const

◆ allowedActivities()

QStringList PhosphorZones::Layout::allowedActivities ( ) const
inline

◆ allowedActivitiesChanged

void PhosphorZones::Layout::allowedActivitiesChanged ( )
signal

◆ allowedDesktops()

QList< int > PhosphorZones::Layout::allowedDesktops ( ) const
inline

◆ allowedDesktopsChanged

void PhosphorZones::Layout::allowedDesktopsChanged ( )
signal

◆ allowedScreens()

QStringList PhosphorZones::Layout::allowedScreens ( ) const
inline

◆ allowedScreensChanged

void PhosphorZones::Layout::allowedScreensChanged ( )
signal

◆ appRules()

QVector< AppRule > PhosphorZones::Layout::appRules ( ) const
inline

◆ appRulesChanged

void PhosphorZones::Layout::appRulesChanged ( )
signal

◆ appRulesVariant()

QVariantList PhosphorZones::Layout::appRulesVariant ( ) const

◆ aspectRatioClass()

::PhosphorLayout::AspectRatioClass PhosphorZones::Layout::aspectRatioClass ( ) const
inline

◆ aspectRatioClassChanged

void PhosphorZones::Layout::aspectRatioClassChanged ( )
signal

◆ aspectRatioClassInt()

int PhosphorZones::Layout::aspectRatioClassInt ( ) const
inline

◆ autoAssign()

bool PhosphorZones::Layout::autoAssign ( ) const
inline

◆ autoAssignChanged

void PhosphorZones::Layout::autoAssignChanged ( )
signal

◆ beginBatchModify()

void PhosphorZones::Layout::beginBatchModify ( )

◆ clearDirty()

void PhosphorZones::Layout::clearDirty ( )
inline

◆ clearOuterGapOverride()

void PhosphorZones::Layout::clearOuterGapOverride ( )

◆ clearOverlayDisplayModeOverride()

void PhosphorZones::Layout::clearOverlayDisplayModeOverride ( )

◆ clearZonePaddingOverride()

void PhosphorZones::Layout::clearZonePaddingOverride ( )

◆ clearZones()

void PhosphorZones::Layout::clearZones ( )

◆ createColumnsLayout()

static Layout * PhosphorZones::Layout::createColumnsLayout ( int  columns,
QObject *  parent = nullptr 
)
static

◆ createFocusLayout()

static Layout * PhosphorZones::Layout::createFocusLayout ( QObject *  parent = nullptr)
static

◆ createGridLayout()

static Layout * PhosphorZones::Layout::createGridLayout ( int  columns,
int  rows,
QObject *  parent = nullptr 
)
static

◆ createPriorityGridLayout()

static Layout * PhosphorZones::Layout::createPriorityGridLayout ( QObject *  parent = nullptr)
static

◆ createRowsLayout()

static Layout * PhosphorZones::Layout::createRowsLayout ( int  rows,
QObject *  parent = nullptr 
)
static

◆ defaultOrder()

int PhosphorZones::Layout::defaultOrder ( ) const
inline

◆ description()

QString PhosphorZones::Layout::description ( ) const
inline

◆ descriptionChanged

void PhosphorZones::Layout::descriptionChanged ( )
signal

◆ endBatchModify()

void PhosphorZones::Layout::endBatchModify ( )

◆ fixedZoneBoundingBox()

QRectF PhosphorZones::Layout::fixedZoneBoundingBox ( ) const

Bounding box of all fixed-geometry zones in pixel coordinates, anchored at (0, 0).

Empty rect if no fixed-geometry zones exist.

◆ fixedZoneReferenceGeometry()

QRectF PhosphorZones::Layout::fixedZoneReferenceGeometry ( ) const

Reference geometry suitable for normalizing fixed-pixel zones to 0–1 relative coordinates.

Returns lastRecalcGeometry() when it accommodates fixedZoneBoundingBox(); falls back to the bounding box itself when the recalc cache is stale (e.g. layout was recalced against a different screen's orientation, leaving normalized coords

‍1 or a square reference frame). Empty rect when the layout has

no fixed-geometry zones.

◆ fromJson()

static Layout * PhosphorZones::Layout::fromJson ( const QJsonObject &  json,
QObject *  parent = nullptr 
)
static

◆ hasFixedGeometryZones()

bool PhosphorZones::Layout::hasFixedGeometryZones ( ) const

Returns true if any zone uses fixed (pixel) geometry mode.

◆ hasOuterGapOverride()

bool PhosphorZones::Layout::hasOuterGapOverride ( ) const
inline

◆ hasOverlayDisplayModeOverride()

bool PhosphorZones::Layout::hasOverlayDisplayModeOverride ( ) const
inline

◆ hasPerSideOuterGapOverride()

bool PhosphorZones::Layout::hasPerSideOuterGapOverride ( ) const
inline

◆ hasSystemOrigin()

bool PhosphorZones::Layout::hasSystemOrigin ( ) const
inline

◆ hasZonePaddingOverride()

bool PhosphorZones::Layout::hasZonePaddingOverride ( ) const
inline

◆ hiddenFromSelector()

bool PhosphorZones::Layout::hiddenFromSelector ( ) const
inline

◆ hiddenFromSelectorChanged

void PhosphorZones::Layout::hiddenFromSelectorChanged ( )
signal

◆ id()

QUuid PhosphorZones::Layout::id ( ) const
inline

◆ isDirty()

bool PhosphorZones::Layout::isDirty ( ) const
inline

◆ isSystemLayout()

bool PhosphorZones::Layout::isSystemLayout ( ) const

◆ lastRecalcGeometry()

QRectF PhosphorZones::Layout::lastRecalcGeometry ( ) const
inline

◆ layoutModified

void PhosphorZones::Layout::layoutModified ( )
signal

◆ markDirty()

void PhosphorZones::Layout::markDirty ( )
inline

◆ matchAppRule()

AppRuleMatch PhosphorZones::Layout::matchAppRule ( const QString &  windowClass) const

◆ matchesAspectRatio()

bool PhosphorZones::Layout::matchesAspectRatio ( qreal  screenAspectRatio) const

Check if this layout is suitable for a screen with the given aspect ratio.

Uses explicit min/max bounds if set, otherwise falls back to class matching.

◆ maxAspectRatio()

qreal PhosphorZones::Layout::maxAspectRatio ( ) const
inline

◆ minAspectRatio()

qreal PhosphorZones::Layout::minAspectRatio ( ) const
inline

◆ moveZone()

void PhosphorZones::Layout::moveZone ( int  fromIndex,
int  toIndex 
)

◆ name()

QString PhosphorZones::Layout::name ( ) const
inline

◆ nameChanged

void PhosphorZones::Layout::nameChanged ( )
signal

◆ nearestZone()

Zone * PhosphorZones::Layout::nearestZone ( const QPointF &  point,
qreal  maxDistance = -1 
) const

◆ operator=()

Layout & PhosphorZones::Layout::operator= ( const Layout other)

◆ outerGap()

int PhosphorZones::Layout::outerGap ( ) const
inline

◆ outerGapBottom()

int PhosphorZones::Layout::outerGapBottom ( ) const
inline

◆ outerGapChanged

void PhosphorZones::Layout::outerGapChanged ( )
signal

◆ outerGapLeft()

int PhosphorZones::Layout::outerGapLeft ( ) const
inline

◆ outerGapRight()

int PhosphorZones::Layout::outerGapRight ( ) const
inline

◆ outerGapTop()

int PhosphorZones::Layout::outerGapTop ( ) const
inline

◆ overlayDisplayMode()

int PhosphorZones::Layout::overlayDisplayMode ( ) const
inline

◆ overlayDisplayModeChanged

void PhosphorZones::Layout::overlayDisplayModeChanged ( )
signal

◆ rawOuterGaps()

::PhosphorLayout::EdgeGaps PhosphorZones::Layout::rawOuterGaps ( ) const
inline

Raw per-side gap overrides.

Values may be -1 (use global). Callers should use GeometryUtils::getEffectiveOuterGaps() instead for resolved pixel values.

◆ recalculateZoneGeometries()

void PhosphorZones::Layout::recalculateZoneGeometries ( const QRectF &  screenGeometry)

Recalculate every zone's absolute geometry against screenGeometry.

The PlasmaZones application enforces its own "only LayoutComputeService calls this" coalescing discipline via its type system — that restriction is an application-layer concern, not a library one, so the method is public here. Direct callers bypass the service's coalescing / threading contract and should only do so when they know they're running on the main thread with no pending compute requests.

◆ removeZone()

void PhosphorZones::Layout::removeZone ( Zone zone)

◆ removeZoneAt()

void PhosphorZones::Layout::removeZoneAt ( int  index)

◆ renumberZones()

void PhosphorZones::Layout::renumberZones ( )

◆ screenIdResolver()

static ScreenIdResolver PhosphorZones::Layout::screenIdResolver ( )
static

Returns a copy of the currently-installed resolver (empty if none).

Returning a copy rather than a reference keeps readers race-free against a concurrent setScreenIdResolver on another thread — the resolver itself is guarded internally, and the returned copy can be invoked without holding the lock.

◆ setAllowedActivities()

void PhosphorZones::Layout::setAllowedActivities ( const QStringList &  activities)

◆ setAllowedDesktops()

void PhosphorZones::Layout::setAllowedDesktops ( const QList< int > &  desktops)

◆ setAllowedScreens()

void PhosphorZones::Layout::setAllowedScreens ( const QStringList &  screens)

◆ setAppRules()

void PhosphorZones::Layout::setAppRules ( const QVector< AppRule > &  rules)

◆ setAppRulesVariant()

void PhosphorZones::Layout::setAppRulesVariant ( const QVariantList &  rules)

◆ setAspectRatioClass()

void PhosphorZones::Layout::setAspectRatioClass ( ::PhosphorLayout::AspectRatioClass  cls)

◆ setAspectRatioClassInt()

void PhosphorZones::Layout::setAspectRatioClassInt ( int  cls)

◆ setAutoAssign()

void PhosphorZones::Layout::setAutoAssign ( bool  enabled)

◆ setDefaultOrder()

void PhosphorZones::Layout::setDefaultOrder ( int  order)
inline

◆ setDescription()

void PhosphorZones::Layout::setDescription ( const QString &  description)

◆ setHiddenFromSelector()

void PhosphorZones::Layout::setHiddenFromSelector ( bool  hidden)

◆ setLastRecalcGeometry()

void PhosphorZones::Layout::setLastRecalcGeometry ( const QRectF &  geom)
inline

◆ setMaxAspectRatio()

void PhosphorZones::Layout::setMaxAspectRatio ( qreal  ratio)

◆ setMinAspectRatio()

void PhosphorZones::Layout::setMinAspectRatio ( qreal  ratio)

◆ setName()

void PhosphorZones::Layout::setName ( const QString &  name)

◆ setOuterGap()

void PhosphorZones::Layout::setOuterGap ( int  gap)

◆ setOuterGapBottom()

void PhosphorZones::Layout::setOuterGapBottom ( int  gap)

◆ setOuterGapLeft()

void PhosphorZones::Layout::setOuterGapLeft ( int  gap)

◆ setOuterGapRight()

void PhosphorZones::Layout::setOuterGapRight ( int  gap)

◆ setOuterGapTop()

void PhosphorZones::Layout::setOuterGapTop ( int  gap)

◆ setOverlayDisplayMode()

void PhosphorZones::Layout::setOverlayDisplayMode ( int  mode)

◆ setScreenIdResolver()

static void PhosphorZones::Layout::setScreenIdResolver ( ScreenIdResolver  resolver)
static

◆ setShaderId()

void PhosphorZones::Layout::setShaderId ( const QString &  id)

◆ setShaderParams()

void PhosphorZones::Layout::setShaderParams ( const QVariantMap &  params)

◆ setShowZoneNumbers()

void PhosphorZones::Layout::setShowZoneNumbers ( bool  show)

◆ setSourcePath()

void PhosphorZones::Layout::setSourcePath ( const QString &  path)

◆ setSystemSourcePath()

void PhosphorZones::Layout::setSystemSourcePath ( const QString &  path)
inline

◆ setUseFullScreenGeometry()

void PhosphorZones::Layout::setUseFullScreenGeometry ( bool  enabled)

◆ setUsePerSideOuterGap()

void PhosphorZones::Layout::setUsePerSideOuterGap ( bool  enabled)

◆ setZonePadding()

void PhosphorZones::Layout::setZonePadding ( int  padding)

◆ shaderId()

QString PhosphorZones::Layout::shaderId ( ) const
inline

◆ shaderIdChanged

void PhosphorZones::Layout::shaderIdChanged ( )
signal

◆ shaderParams()

QVariantMap PhosphorZones::Layout::shaderParams ( ) const
inline

◆ shaderParamsChanged

void PhosphorZones::Layout::shaderParamsChanged ( )
signal

◆ showZoneNumbers()

bool PhosphorZones::Layout::showZoneNumbers ( ) const
inline

◆ showZoneNumbersChanged

void PhosphorZones::Layout::showZoneNumbersChanged ( )
signal

◆ sourcePath()

QString PhosphorZones::Layout::sourcePath ( ) const
inline

◆ sourcePathChanged

void PhosphorZones::Layout::sourcePathChanged ( )
signal

◆ systemSourcePath()

QString PhosphorZones::Layout::systemSourcePath ( ) const
inline

◆ toJson()

QJsonObject PhosphorZones::Layout::toJson ( ) const

◆ useFullScreenGeometry()

bool PhosphorZones::Layout::useFullScreenGeometry ( ) const
inline

◆ useFullScreenGeometryChanged

void PhosphorZones::Layout::useFullScreenGeometryChanged ( )
signal

◆ usePerSideOuterGap()

bool PhosphorZones::Layout::usePerSideOuterGap ( ) const
inline

◆ zone()

Zone * PhosphorZones::Layout::zone ( int  index) const

◆ zoneAdded

void PhosphorZones::Layout::zoneAdded ( Zone zone)
signal

◆ zoneAtPoint()

Zone * PhosphorZones::Layout::zoneAtPoint ( const QPointF &  point) const

◆ zoneById()

Zone * PhosphorZones::Layout::zoneById ( const QUuid &  id) const

◆ zoneByNumber()

Zone * PhosphorZones::Layout::zoneByNumber ( int  number) const

◆ zoneCount()

int PhosphorZones::Layout::zoneCount ( ) const
inline

◆ zonePadding()

int PhosphorZones::Layout::zonePadding ( ) const
inline

◆ zonePaddingChanged

void PhosphorZones::Layout::zonePaddingChanged ( )
signal

◆ zoneRemoved

void PhosphorZones::Layout::zoneRemoved ( Zone zone)
signal

◆ zones()

QVector< Zone * > PhosphorZones::Layout::zones ( ) const
inline

◆ zonesChanged

void PhosphorZones::Layout::zonesChanged ( )
signal

◆ zonesInRect()

QVector< Zone * > PhosphorZones::Layout::zonesInRect ( const QRectF &  rect) const

The documentation for this class was generated from the following file: