Zone/layout primitive utilities — pure Layout / Zone operations. More...
Functions | |
| PHOSPHORZONES_EXPORT void | serializeAllowLists (QJsonObject &json, const QStringList &screens, const QList< int > &desktops, const QStringList &activities) |
| Serialize visibility allow-lists to JSON (only writes non-empty lists). | |
| PHOSPHORZONES_EXPORT void | deserializeAllowLists (const QJsonObject &json, QStringList &screens, QList< int > &desktops, QStringList &activities) |
| Deserialize visibility allow-lists from JSON (clears output params first). | |
| PHOSPHORZONES_EXPORT QVariantList | zonesToVariantList (Layout *layout, ZoneFields fields=ZoneField::Minimal, const QRectF &referenceGeometry=QRectF(), qreal screenScale=0.0) |
| Convert all zones in a layout to QVariantList. | |
| PHOSPHORZONES_EXPORT QVariantMap | layoutToVariantMap (Layout *layout, ZoneFields zoneFields=ZoneField::Minimal) |
| Convert a layout to a QVariantMap (metadata + zones). | |
| PHOSPHORZONES_EXPORT void | sortZonesByNumber (QVector< Zone * > &zones) |
| PHOSPHORZONES_EXPORT QHash< QString, int > | buildZonePositionMap (Layout *layout) |
| PHOSPHORZONES_EXPORT QHash< QString, int > | buildGlobalZonePositionMap (const QList< Layout * > &layouts) |
Build a global zoneId → position map merged across every layout in layouts. | |
| PHOSPHORZONES_EXPORT bool | layoutHoldsZones (const Layout *layout, const QStringList &zoneIds) |
Does layout hold EVERY zone in zoneIds? | |
| PHOSPHORZONES_EXPORT bool | contextLayoutHoldsZones (const IZoneLayoutRegistry *registry, const QString &screenId, int virtualDesktop, const QString &activity, const QStringList &zoneIds) |
layoutHoldsZones() against the layout registry resolves for the (screenId, virtualDesktop, activity) context. | |
| PHOSPHORZONES_EXPORT QStringList | sameNumberedZones (const QStringList &zoneIds, const Layout *target, const QHash< QString, int > &positions) |
The slot remembered zoneIds take in target, the layout a context runs now: the zones themselves when target holds them all (a span stays a span), else target's zone at the position the first one has in its own layout (positions, buildGlobalZonePositionMap over the registry's layouts), else empty when target has fewer zones or none. | |
| PHOSPHORZONES_EXPORT int | reissueTakenZoneIds (QJsonObject &layoutJson, const QList< Layout * > &loaded) |
| Give a layout document's zones ids no other layout holds (F552), and a zone with no id one of its own. | |
Zone/layout primitive utilities — pure Layout / Zone operations.
This header carries only code that operates on Layout and Zone types and has no dependency on autotile, settings services, or higher-layer composition (the picker-UI aggregation that stitches manual layouts together with autotile algorithms lives in unifiedlayoutlist.h). Keeping that split lets these primitives eventually live in a standalone phosphor-zones library without dragging autotile or settings services into the dependency graph.
| PHOSPHORZONES_EXPORT QHash< QString, int > PhosphorZones::LayoutUtils::buildGlobalZonePositionMap | ( | const QList< Layout * > & | layouts | ) |
Build a global zoneId → position map merged across every layout in layouts.
Zone UUIDs are unique across all layouts in the registry (its directory load and import re-mint a copied one, reissueTakenZoneIds), so the merge is unambiguous. Used by the resnap path (lifecycle.cpp + resnap.cpp) when a window's stored zoneId may have come from any layout — for example, after a promote edit shifts the cascade winner from a per-context layout to the screen-level slot.
| PHOSPHORZONES_EXPORT QHash< QString, int > PhosphorZones::LayoutUtils::buildZonePositionMap | ( | Layout * | layout | ) |
| PHOSPHORZONES_EXPORT bool PhosphorZones::LayoutUtils::contextLayoutHoldsZones | ( | const IZoneLayoutRegistry * | registry, |
| const QString & | screenId, | ||
| int | virtualDesktop, | ||
| const QString & | activity, | ||
| const QStringList & | zoneIds ) |
layoutHoldsZones() against the layout registry resolves for the (screenId, virtualDesktop, activity) context.
Permissive (true) with a null registry, matching the unit-test path where an engine runs without one; a context that resolves no layout answers false.
| PHOSPHORZONES_EXPORT void PhosphorZones::LayoutUtils::deserializeAllowLists | ( | const QJsonObject & | json, |
| QStringList & | screens, | ||
| QList< int > & | desktops, | ||
| QStringList & | activities ) |
Deserialize visibility allow-lists from JSON (clears output params first).
| PHOSPHORZONES_EXPORT bool PhosphorZones::LayoutUtils::layoutHoldsZones | ( | const Layout * | layout, |
| const QStringList & | zoneIds ) |
Does layout hold EVERY zone in zoneIds?
Zone UUIDs are unique across all layouts, so a remembered zone id names one layout for good: a zone remembered under the layout a context USED to run resolves geometry just fine against the layout it belongs to, which is how a window came back into a "ghost" layout on a desktop that had since been given another one (discussion #1104). Every path that re-applies a remembered zone into a (screen, desktop, activity) context asks this of the layout the registry resolves for THAT context before trusting the id.
A null layout or an empty list answers false: there is nothing to snap into.
| PHOSPHORZONES_EXPORT QVariantMap PhosphorZones::LayoutUtils::layoutToVariantMap | ( | Layout * | layout, |
| ZoneFields | zoneFields = ZoneField::Minimal ) |
Convert a layout to a QVariantMap (metadata + zones).
Used by LayoutAdaptor for D-Bus and other consumers that want the whole layout as a single map without going through LayoutPreview.
| PHOSPHORZONES_EXPORT int PhosphorZones::LayoutUtils::reissueTakenZoneIds | ( | QJsonObject & | layoutJson, |
| const QList< Layout * > & | loaded ) |
Give a layout document's zones ids no other layout holds (F552), and a zone with no id one of its own.
Every zone id in layoutJson's zones array that a layout in loaded already holds, or that repeats within the document, is replaced, and a zone with no id is given one. A layout with the document's own id is not another layout: a user copy overriding a system layout shares its zone ids. The new id is a name-based UUID of the layout id, the old zone id (or a fixed stand-in for a missing one) and its index, so the same document gets the same ids on every load, in every process, even before the caller writes it back, re-derived with a counter while the result is taken or already in the document. A document whose id is not a UUID derives from a random namespace instead, as Layout::fromJson mints it a random id. Returns the number of ids replaced or given.
The registry's directory load, its import and its restore of a system layout run every document through this before Layout::fromJson, which is what makes the uniqueness the position map and layoutHoldsZones rely on hold.
| PHOSPHORZONES_EXPORT QStringList PhosphorZones::LayoutUtils::sameNumberedZones | ( | const QStringList & | zoneIds, |
| const Layout * | target, | ||
| const QHash< QString, int > & | positions ) |
The slot remembered zoneIds take in target, the layout a context runs now: the zones themselves when target holds them all (a span stays a span), else target's zone at the position the first one has in its own layout (positions, buildGlobalZonePositionMap over the registry's layouts), else empty when target has fewer zones or none.
The one same-numbered re-slot of a layout change: the snap engine's desktop carry (a window moved to a desktop running another layout) and the layout-switch populate (a minimized window's pre-float zones) share it.
| PHOSPHORZONES_EXPORT void PhosphorZones::LayoutUtils::serializeAllowLists | ( | QJsonObject & | json, |
| const QStringList & | screens, | ||
| const QList< int > & | desktops, | ||
| const QStringList & | activities ) |
Serialize visibility allow-lists to JSON (only writes non-empty lists).
| PHOSPHORZONES_EXPORT void PhosphorZones::LayoutUtils::sortZonesByNumber | ( | QVector< Zone * > & | zones | ) |
| PHOSPHORZONES_EXPORT QVariantList PhosphorZones::LayoutUtils::zonesToVariantList | ( | Layout * | layout, |
| ZoneFields | fields = ZoneField::Minimal, | ||
| const QRectF & | referenceGeometry = QRectF(), | ||
| qreal | screenScale = 0.0 ) |
Convert all zones in a layout to QVariantList.
| layout | The layout containing zones (returns empty list if null) |
| fields | Which fields to include for each zone |
| referenceGeometry | Screen geometry for normalizing fixed zones. Empty takes the layout's lastRecalcGeometry(), the rect of the output it was last recalculated for. |
| screenScale | Logical scale of the output referenceGeometry belongs to, which a layout counting fixed geometry in device pixels divides by (Zone::normalizedGeometry). Zero, the default, takes the layout's lastRecalcScale(). Honoured only alongside a non-empty referenceGeometry: with an empty one the cached rect and its own scale are used together, so the two never describe different outputs. |