template<typename SurfaceT = Surface>
class PhosphorLayer::ScreenSurfaceRegistry< SurfaceT >
Per-screen bookkeeping for surfaces with AllScreens affinity.
Template parameter lets consumers subclass Surface and keep their type through the API:
class PzOverlaySurface :
public Surface { ... };
auto* s = reg.surfaceForScreen(myScreen);
Per-screen bookkeeping for surfaces with AllScreens affinity.
Definition ScreenSurfaceRegistry.h:55
SurfaceFactory * factory() const noexcept
Definition ScreenSurfaceRegistry.h:118
One layer-shell surface with a managed lifecycle.
Definition Surface.h:99
The registry does NOT listen to screensChanged itself — that is the TopologyCoordinator's job. Consumers that want topology response wire a coordinator to one or more registries.
Header-only: the template instantiation is trivially small and keeping it inline lets consumer subclasses bind their type without generating library exports for every combination.
- Note
- Status (v0.1): not yet used by the reference consumer (PlasmaZones OverlayService, which tracks per-screen state in its own QHash keyed by virtual-screen id). The registry is a public primitive for consumers whose per-screen state maps cleanly to physical QScreen*. Its API is covered by unit tests but has no production integration yet; treat behavioural details (QHash iteration order, pointer identity across createForAllScreens calls) as subject to change until the first real consumer lands.
template<typename SurfaceT >
Register an externally-created Surface under screen.
Useful when a consumer subclasses Surface and constructs it itself.
Ownership: the registry becomes the owner-of-record for the adopted surface. clear() / syncToScreens will schedule deleteLater() on the stored pointer. QPointer's auto-nulling + Qt's DeferredDelete coalescing make this safe even when the surface is ALSO reachable through a parent QObject that's about to destroy it — the second delete-event becomes a no-op.
If screen already has a registered surface, the prior surface is scheduled for deletion unless it is the same object as surface (re-adopt is an idempotent no-op).
template<typename SurfaceT >
Create one Surface per screen reported by the provider.
Takes a Builder because SurfaceConfig is move-only (contentItem) and per-screen context often differs (screen name, geometry, etc.). Passing a builder is strictly more flexible than cloning a single config, and gives the consumer a natural place to inject per-screen context properties.
Idempotent: re-running with the same screen set is a no-op. Screens that already have an entry keep their existing surface; new screens get a freshly-built one.