Layout description interfaces. The ILayoutSource seam plus the value types (algorithm metadata, edge gaps, aspect-ratio classes, layout IDs, previews) that cross library boundaries.
Both the zones library and the autotiling library produce "a layout for this screen at this moment". Zones come from a user-drawn JSON description, and autotiling from a dynamic algorithm over the current window set. Downstream consumers (snap engine, overlay, settings-UI preview) shouldn't care which source a layout came from.
phosphor-layout-api is the shared vocabulary both sides agree on:
| Type | Purpose |
|---|---|
| PhosphorLayout::ILayoutSource | Abstract layout producer |
| PhosphorLayout::ILayoutSourceFactory | Builds an ILayoutSource for a given layout-ID |
| PhosphorLayout::ILayoutSourceRegistry | Provider-side enumeration that emits contentsChanged |
| PhosphorLayout::LayoutSourceProviderRegistry | Process-wide "which providers exist" registrar |
| PhosphorLayout::LayoutSourceBundle | Per-process bundle of resolved provider instances |
| PhosphorLayout::LayoutId | Stable string identifier, value-semantic |
| PhosphorLayout::AlgorithmMetadata | Tiling algorithm self-description |
| PhosphorLayout::AspectRatioClass | Screen aspect bucket (Narrow / Normal / Wide) |
| PhosphorLayout::EdgeGaps | Inner/outer spacing value type |
| PhosphorLayout::GapKeys | JSON key constants for roundtrip |
| PhosphorLayout::CompositeLayoutSource | Multiplexes several ILayoutSources |
| PhosphorLayout::LayoutPreview | Paint-a-thumbnail helper for pickers |
Implement a custom layout source:
#include <PhosphorLayoutApi/ILayoutSource.h>
class MyLayoutSource : public PhosphorLayout::ILayoutSource {
public:
QVector<PhosphorLayout::LayoutPreview> availableLayouts() const override
{
QVector<PhosphorLayout::LayoutPreview> previews;
// Populate one LayoutPreview per layout this source can render…
return previews;
}
PhosphorLayout::LayoutPreview previewAt(
const QString &id, int windowCount, const QSize &canvas) override
{
PhosphorLayout::LayoutPreview preview;
// Populate zones for the requested entry…
return preview;
}
};Chain two sources for screens with different preferences:
CompositeLayoutSource composite;
composite.addSource(zonesSource); // user-drawn
composite.addSource(autotileSource);
ILayoutSource *combined = &composite; // consumers don't know the difference