Represents a collection of zones that form a layout. More...
#include <PhosphorZones/Layout.h>
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 | aspectRatioClassChanged () |
| void | hiddenFromSelectorChanged () |
| void | allowedScreensChanged () |
| void | allowedDesktopsChanged () |
| void | allowedActivitiesChanged () |
| void | autoAssignChanged () |
| void | useFullScreenGeometryChanged () |
| void | zonesChanged () |
| void | zoneAdded (Zone *zone) |
| void | zoneRemoved (Zone *zone) |
| void | layoutModified () |
| void | fixedGeometryInDevicePixelsChanged () |
Public Member Functions | |
| Layout (QObject *parent=nullptr) | |
| Layout (const QString &name, QObject *parent=nullptr) | |
| ~Layout () override | |
| Layout (const Layout &)=delete | |
| Layout & | operator= (const Layout &)=delete |
| Layout * | clone (QObject *parent=nullptr) const |
| Deep-copy this layout into a new, independently owned Layout. | |
| 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 |
| ::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) |
| bool | autoAssign () const |
| void | setAutoAssign (bool enabled) |
| bool | useFullScreenGeometry () const |
| void | setUseFullScreenGeometry (bool enabled) |
| bool | fixedGeometryInDevicePixels () const |
| Whether this layout's fixed-geometry zones count DEVICE pixels. | |
| void | setFixedGeometryInDevicePixels (bool enabled) |
| qreal | fixedGeometryDivisor (qreal screenScale) const |
What a fixed geometry is divided by on an output whose logical scale is screenScale: that scale when fixedGeometryInDevicePixels() is on and the scale is usable, 1.0 otherwise. | |
| bool | hasFixedGeometryZones () const |
| Returns true if any zone uses fixed (pixel) geometry mode. | |
| QRectF | fixedZoneBoundingBox () const |
| Bounding box of all fixed-geometry zones, anchored at (0, 0), in the LOGICAL units of the last recalculation: device-pixel geometry is divided by lastRecalcScale() so the box compares with lastRecalcGeometry(). | |
| 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 |
| Zone * | zone (int index) const |
| Zone * | zoneById (const QUuid &id) const |
| Zone * | zoneByNumber (int number) const |
| Zone * | zoneByName (const QString &name) const |
First zone (in zone-number order) whose name equals name after trimming, compared case-insensitively. | |
| void | addZone (Zone *zone) |
| void | removeZone (Zone *zone) |
| void | removeZoneAt (int index) |
| void | clearZones () |
| void | moveZone (int fromIndex, int toIndex) |
| Zone * | zoneAtPoint (const QPointF &point) const |
| Zone * | nearestZone (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, qreal screenScale=0.0) |
Stamps the rect, and a positive screenScale as the scale with it. | |
| bool | needsRecalc (const QRectF &screenGeometry, qreal screenScale=0.0) const |
| The complete staleness predicate recalculateZoneGeometries() gates on: the screen rect changed OR the zone geometry inputs changed since the last pass (m_zoneGeometryDirty: a zone-set edit or a flip of the fixed-geometry unit). | |
| qreal | lastRecalcScale () const |
| The newest output scale a recalculation was asked for (1.0 until a scale is known). | |
| quint64 | zoneGeometryEpoch () const |
| Bumped when the zone set changes (a zone added, removed or replaced) or the fixed-geometry unit flips, each of which also sets the dirty bit needsRecalc() reads. | |
| quint64 | syncRecalcEpoch () const |
| Bumped by every recalculateZoneGeometries() call, including one that finds nothing to recompute, because each call records the frame its caller wants now. | |
| void | markRecalculated (const QRectF &geom, qreal screenScale=0.0) |
| Full-recalc bookkeeping for external appliers (the async worker path): stamps the rect AND clears the dirty bit, exactly as recalculateZoneGeometries() does internally. | |
| QJsonObject | toJson () const |
| bool | isDirty () const |
| void | markDirty () |
| void | clearDirty () |
| void | beginBatchModify () |
| void | endBatchModify () |
| void | recalculateZoneGeometries (const QRectF &screenGeometry, qreal screenScale=0.0) |
Recalculate every zone's absolute geometry against screenGeometry. | |
Static Public Member Functions | |
| static Layout * | fromJson (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 Layout * | createColumnsLayout (int columns, QObject *parent=nullptr) |
| static Layout * | createRowsLayout (int rows, QObject *parent=nullptr) |
| static Layout * | createGridLayout (int columns, int rows, QObject *parent=nullptr) |
| static Layout * | createPriorityGridLayout (QObject *parent=nullptr) |
| static Layout * | createFocusLayout (QObject *parent=nullptr) |
Static Public Attributes | |
| static constexpr int | DefaultOrderUnset = 999 |
Sentinel for "no explicit default order set" on defaultOrder. | |
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.
| 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.
|
explicit |
|
explicit |
|
override |
|
delete |
| void PhosphorZones::Layout::addZone | ( | Zone * | zone | ) |
| QVector< Zone * > PhosphorZones::Layout::adjacentZones | ( | const QPointF & | point, |
| qreal | threshold = 20 ) const |
|
inline |
|
signal |
|
inline |
|
signal |
|
inline |
|
signal |
|
inline |
|
signal |
|
inline |
|
inline |
|
signal |
| void PhosphorZones::Layout::beginBatchModify | ( | ) |
|
inline |
| void PhosphorZones::Layout::clearOuterGapOverride | ( | ) |
| void PhosphorZones::Layout::clearOverlayDisplayModeOverride | ( | ) |
| void PhosphorZones::Layout::clearZonePaddingOverride | ( | ) |
| void PhosphorZones::Layout::clearZones | ( | ) |
| Layout * PhosphorZones::Layout::clone | ( | QObject * | parent = nullptr | ) | const |
Deep-copy this layout into a new, independently owned Layout.
The clone represents a distinct USER-owned layout: it gets a fresh id, and it deliberately carries over neither sourcePath nor systemSourcePath, so a clone of a system layout is a plain user layout and the "restore system original" path cannot mistake it for a user override of the same entry. Its zones are deep-copied (Zone::clone).
parent is the clone's QObject owner and defaults to none. Pass the registry that will hold it, or leave it unparented and let the registry's addLayout() take ownership — do NOT pass the SOURCE's parent by reflex: the clone would appear as a child of a registry that never inserted it into its own layout list.
|
static |
|
static |
|
static |
|
static |
|
static |
|
inline |
|
inline |
|
signal |
| void PhosphorZones::Layout::endBatchModify | ( | ) |
|
inline |
What a fixed geometry is divided by on an output whose logical scale is screenScale: that scale when fixedGeometryInDevicePixels() is on and the scale is usable, 1.0 otherwise.
The single definition every resolver shares, so a fixed zone cannot be read in two units, and Zone::fixedGeometryToLogical() applies it.
The scale is taken as given: a non-positive one is "no scale" and answers 1.0. Zone::fixedGeometryDivisor() differs on purpose, because it reads a zero scale as "the scale of the last recalculation" and asks this function with that one instead.
|
inline |
Whether this layout's fixed-geometry zones count DEVICE pixels.
Off (the default, and every layout written before the option existed), a fixed zone's numbers are logical pixels like every other size in the desktop, so the zone scales with the display. On, they are the output's own pixels and are divided by its scale when resolved, so a zone keeps its size on the panel whatever scaling the display runs at.
|
signal |
| QRectF PhosphorZones::Layout::fixedZoneBoundingBox | ( | ) | const |
Bounding box of all fixed-geometry zones, anchored at (0, 0), in the LOGICAL units of the last recalculation: device-pixel geometry is divided by lastRecalcScale() so the box compares with lastRecalcGeometry().
Empty rect if no fixed-geometry zones exist.
| QRectF PhosphorZones::Layout::fixedZoneReferenceGeometry | ( | ) | const |
Reference geometry suitable for normalizing fixed-pixel zones to 0–1 relative coordinates.
Returns lastRecalcGeometry() when it accommodates fixedZoneBoundingBox(), with less than one logical pixel of slack so a device-pixel box that exactly fills the screen still fits after the division by a fractional scale. Falls back to the bounding box in exactly two cases: the fixed zones overflow the last recalculation rect, or no rect is known yet. It does not detect a stale rect that still happens to hold the box. Empty rect when the layout has no fixed-geometry zones.
|
static |
| bool PhosphorZones::Layout::hasFixedGeometryZones | ( | ) | const |
Returns true if any zone uses fixed (pixel) geometry mode.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
signal |
|
inline |
|
inline |
| bool PhosphorZones::Layout::isSystemLayout | ( | ) | const |
|
inline |
|
inline |
The newest output scale a recalculation was asked for (1.0 until a scale is known).
A recalculation asked with a positive scale stamps it, the ones that find nothing to recompute included, so a reader that divides by it (the bounding box, the serialized relative hint, the variant lists) holds the output's current scale even on a layout the scale cannot move. A call with scale zero keeps the last one, and an async result a later sync recalculation superseded stamps nothing.
|
signal |
|
inline |
|
inline |
Full-recalc bookkeeping for external appliers (the async worker path): stamps the rect AND clears the dirty bit, exactly as recalculateZoneGeometries() does internally.
Use only when the applied geometries were computed from the layout's current inputs, that is at the current zoneGeometryEpoch(). A positive screenScale is stamped as the scale too; zero keeps the last one.
| 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.
|
inline |
|
inline |
| void PhosphorZones::Layout::moveZone | ( | int | fromIndex, |
| int | toIndex ) |
|
inline |
|
signal |
| Zone * PhosphorZones::Layout::nearestZone | ( | const QPointF & | point, |
| qreal | maxDistance = -1 ) const |
|
inline |
The complete staleness predicate recalculateZoneGeometries() gates on: the screen rect changed OR the zone geometry inputs changed since the last pass (m_zoneGeometryDirty: a zone-set edit or a flip of the fixed-geometry unit).
Callers that skip work when a recalc "already happened" MUST use this, not a bare lastRecalcGeometry() comparison — the rect alone reads as fresh after a zone add/remove at unchanged screen geometry, leaving the new zones with no absolute geometry.
The output's logical scale screenScale is an input too, because a device-pixel layout resolves its fixed zones differently at the same logical rect once the scale moves (and the scale settles only after an output's sensor maps, with the rect unchanged). A layout whose fixed geometry is logical, or that has no fixed zone at all, ignores the scale, since it cannot change anything for it. Zero (the default) asks about the rect and the inputs alone.
|
inline |
|
inline |
|
signal |
|
inline |
|
inline |
|
inline |
|
inline |
|
signal |
|
inline |
Raw per-side gap overrides.
Values may be -1 (use global). Callers should use GeometryUtils::getEffectiveOuterGaps() instead for resolved pixel values.
| void PhosphorZones::Layout::recalculateZoneGeometries | ( | const QRectF & | screenGeometry, |
| qreal | screenScale = 0.0 ) |
Recalculate every zone's absolute geometry against screenGeometry.
Public, and nothing restricts who calls it. Daemon code goes through LayoutComputeService::recalculateSync by convention, and the editor calls it directly on a temporary layout it owns. A direct call on a layout the compute service also tracks is safe: it bumps syncRecalcEpoch(), and the service will not let an async result asked for before the call overwrite the frame it stamps. Call it on the GUI thread only, as with every other Layout member.
screenScale is the logical scale of the output screenGeometry belongs to, which a device-pixel layout divides its fixed geometries by. Zero (the default) keeps the scale of the last recalculation.
| void PhosphorZones::Layout::removeZone | ( | Zone * | zone | ) |
| void PhosphorZones::Layout::removeZoneAt | ( | int | index | ) |
| void PhosphorZones::Layout::renumberZones | ( | ) |
|
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.
| void PhosphorZones::Layout::setAllowedActivities | ( | const QStringList & | activities | ) |
| void PhosphorZones::Layout::setAllowedDesktops | ( | const QList< int > & | desktops | ) |
| void PhosphorZones::Layout::setAllowedScreens | ( | const QStringList & | screens | ) |
| void PhosphorZones::Layout::setAspectRatioClass | ( | ::PhosphorLayout::AspectRatioClass | cls | ) |
| void PhosphorZones::Layout::setAspectRatioClassInt | ( | int | cls | ) |
| void PhosphorZones::Layout::setAutoAssign | ( | bool | enabled | ) |
|
inline |
| void PhosphorZones::Layout::setDescription | ( | const QString & | description | ) |
| void PhosphorZones::Layout::setFixedGeometryInDevicePixels | ( | bool | enabled | ) |
| void PhosphorZones::Layout::setHiddenFromSelector | ( | bool | hidden | ) |
|
inline |
Stamps the rect, and a positive screenScale as the scale with it.
| void PhosphorZones::Layout::setMaxAspectRatio | ( | qreal | ratio | ) |
| void PhosphorZones::Layout::setMinAspectRatio | ( | qreal | ratio | ) |
| void PhosphorZones::Layout::setName | ( | const QString & | name | ) |
| void PhosphorZones::Layout::setOuterGap | ( | int | gap | ) |
| void PhosphorZones::Layout::setOuterGapBottom | ( | int | gap | ) |
| void PhosphorZones::Layout::setOuterGapLeft | ( | int | gap | ) |
| void PhosphorZones::Layout::setOuterGapRight | ( | int | gap | ) |
| void PhosphorZones::Layout::setOuterGapTop | ( | int | gap | ) |
| void PhosphorZones::Layout::setOverlayDisplayMode | ( | int | mode | ) |
|
static |
| void PhosphorZones::Layout::setShowZoneNumbers | ( | bool | show | ) |
| void PhosphorZones::Layout::setSourcePath | ( | const QString & | path | ) |
|
inline |
| void PhosphorZones::Layout::setUseFullScreenGeometry | ( | bool | enabled | ) |
| void PhosphorZones::Layout::setUsePerSideOuterGap | ( | bool | enabled | ) |
| void PhosphorZones::Layout::setZonePadding | ( | int | padding | ) |
|
inline |
|
signal |
|
inline |
|
signal |
|
inline |
Bumped by every recalculateZoneGeometries() call, including one that finds nothing to recompute, because each call records the frame its caller wants now.
An async result whose snapshot was taken before the bump was asked for earlier, so it must not overwrite that frame.
|
inline |
| QJsonObject PhosphorZones::Layout::toJson | ( | ) | const |
|
inline |
|
signal |
|
inline |
| Zone * PhosphorZones::Layout::zone | ( | int | index | ) | const |
|
signal |
| Zone * PhosphorZones::Layout::zoneAtPoint | ( | const QPointF & | point | ) | const |
| Zone * PhosphorZones::Layout::zoneById | ( | const QUuid & | id | ) | const |
| Zone * PhosphorZones::Layout::zoneByName | ( | const QString & | name | ) | const |
First zone (in zone-number order) whose name equals name after trimming, compared case-insensitively.
Zone names are not unique, so a duplicate name resolves to the lowest-numbered zone. Returns nullptr for a blank name or no match.
| Zone * PhosphorZones::Layout::zoneByNumber | ( | int | number | ) | const |
|
inline |
|
inline |
Bumped when the zone set changes (a zone added, removed or replaced) or the fixed-geometry unit flips, each of which also sets the dirty bit needsRecalc() reads.
A per-zone setter on an existing zone does not bump it. The async compute path carries it through the worker, so a result computed from an older zone set is never mistaken for one that covers the current zones, even when the zone ids match.
|
inline |
|
signal |
|
signal |
|
inline |
|
signal |
| QVector< Zone * > PhosphorZones::Layout::zonesInRect | ( | const QRectF & | rect | ) | const |
|
staticconstexpr |
Sentinel for "no explicit default order set" on defaultOrder.
Ordering is ascending (lower sorts first), so an unset layout has to sort after every ordered one. This is a large value rather than a negative one for that reason. Unset layouts are also omitted from toJson, so the key is absent rather than written out as a magic number.