Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
IZoneLayoutRegistry.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6// IZoneLayoutRegistry - enumeration + mutation of the catalog of
7// manual zone layouts.
8//
9// Split out of ILayoutManager so callers that need the layout set
10// (editor save path, layout-import flow, settings create-layout
11// button, read-only preview renderers) can depend on one contract
12// instead of the full manager. "Active layout" selection lives here
13// because it mutates the manager's active-layout slot.
14//
15// Inherits PhosphorLayout::ILayoutSourceRegistry so concrete registries
16// (LayoutManager) carry the unified `contentsChanged` signal that
17// ZonesLayoutSource subscribes to - matching the pattern every other
18// provider library (phosphor-tiles, future phosphor-scrolling, …)
19// follows. Inheriting QObject via the unified base rather than
20// directly keeps ILayoutManager's non-virtual multi-inheritance safe:
21// every path through ILayoutManager reaches QObject exactly once, so
22// LayoutManager has a single QObject subobject.
23
24#include <phosphorzones_export.h>
25
28
29#include <QString>
30#include <QUuid>
31#include <QVector>
32
33namespace PhosphorZones {
34
43{
44 Q_OBJECT
45
46 // Live in the interface so QML-bound consumers can target the contract
47 // without depending on the concrete @ref LayoutRegistry. moc's NOTIFY
48 // check resolves the signal in the same class scope it sees the READ
49 // method, so the property + the signal must travel together.
50 Q_PROPERTY(Layout* activeLayout READ activeLayout NOTIFY activeLayoutChanged)
51
52public:
53 explicit IZoneLayoutRegistry(QObject* parent = nullptr);
55
59 virtual QVector<Layout*> layouts() const = 0;
60
61 virtual int layoutCount() const = 0;
62 virtual Layout* layout(int index) const = 0;
63 virtual Layout* layoutByName(const QString& name) const = 0;
64
67 virtual Layout* layoutById(const QUuid& id) const = 0;
68
71 virtual void addLayout(Layout* layout) = 0;
77 virtual void removeLayout(Layout* layout) = 0;
78 virtual void removeLayoutById(const QUuid& id) = 0;
83 virtual Layout* duplicateLayout(Layout* source) = 0;
84
85 // Active layout (internal - used for resnap / geometry / overlay
86 // machinery). Borrowed pointer owned by the registry.
87 virtual Layout* activeLayout() const = 0;
88 virtual void setActiveLayout(Layout* layout) = 0;
89 virtual void setActiveLayoutById(const QUuid& id) = 0;
90
91 // ─── Per-screen layout resolution (cascade-aware) ─────────────────────
92 //
93 // These queries resolve a layout for a (screen, desktop, activity)
94 // context by walking the assignment cascade and falling back to the
95 // global default. Overlay/geometry/animation consumers depend on this
96 // shape, so it lives on the interface - callers can target the
97 // contract without depending on the concrete @c LayoutRegistry.
98
101 virtual Layout* layoutForScreen(const QString& screenId, int virtualDesktop = 0,
102 const QString& activity = QString()) const = 0;
103
106 virtual Layout* resolveLayoutForScreen(const QString& screenId) const = 0;
107
110 virtual QString assignmentIdForScreen(const QString& screenId, int virtualDesktop = 0,
111 const QString& activity = QString()) const = 0;
112
114 virtual Layout* defaultLayout() const = 0;
115
116 // ─── Session context (current desktop / activity) ─────────────────────
117 //
118 // The registry holds session-context state because per-context
119 // assignment resolution needs it. Consumers that drive context-aware
120 // queries (overlay re-layout on desktop switch, autotile re-run on
121 // activity change) read it through the interface.
122
123 virtual int currentVirtualDesktop() const = 0;
124 virtual QString currentActivity() const = 0;
125
126Q_SIGNALS:
127 // Catalog mutation. @c addLayout / @c duplicateLayout fire `layoutAdded`;
128 // @c removeLayout / @c removeLayoutById fire `layoutRemoved`.
129 void layoutAdded(Layout* layout);
130 void layoutRemoved(Layout* layout);
131
132 // Active-layout selection. Fires from @c setActiveLayout /
133 // @c setActiveLayoutById only when the active-layout pointer actually
134 // changes (concrete implementer guards with an equality check -
135 // matches the project rule "only emit signals when value actually
136 // changes").
138
139 // Assignment churn. Fires when a (screenId, virtualDesktop)
140 // assignment changes; activity context is intentionally omitted
141 // from the signal - consumers that care about activity-keyed
142 // assignments re-query via @c layoutForScreen with their current
143 // activity. Concrete impl emits only on actual change (matches the
144 // project "emit only when value changes" rule).
145 void layoutAssigned(const QString& screenId, int virtualDesktop, Layout* layout);
146};
147
148} // namespace PhosphorZones
Abstract notifier surface for every registry that feeds an ILayoutSource.
Definition ILayoutSourceRegistry.h:37
Enumeration + mutation surface for the in-memory zone-layout catalog.
Definition IZoneLayoutRegistry.h:43
virtual Layout * layout(int index) const =0
virtual Layout * layoutById(const QUuid &id) const =0
Resolve a layout by its stable UUID.
void layoutRemoved(Layout *layout)
virtual Layout * layoutForScreen(const QString &screenId, int virtualDesktop=0, const QString &activity=QString()) const =0
Cascade-resolve the manual layout for screenId.
virtual QString assignmentIdForScreen(const QString &screenId, int virtualDesktop=0, const QString &activity=QString()) const =0
Raw assignment id (manual-layout UUID or "autotile:<algorithmId>") for screenId, with cascade + level...
void layoutAdded(Layout *layout)
virtual Layout * activeLayout() const =0
virtual QVector< Layout * > layouts() const =0
Enumerate every known layout.
IZoneLayoutRegistry(QObject *parent=nullptr)
virtual Layout * layoutByName(const QString &name) const =0
virtual Layout * defaultLayout() const =0
Effective global default layout (snap-only fallback).
virtual QString currentActivity() const =0
virtual void addLayout(Layout *layout)=0
virtual void setActiveLayoutById(const QUuid &id)=0
void activeLayoutChanged(Layout *layout)
virtual void removeLayoutById(const QUuid &id)=0
virtual void setActiveLayout(Layout *layout)=0
void layoutAssigned(const QString &screenId, int virtualDesktop, Layout *layout)
virtual void removeLayout(Layout *layout)=0
virtual Layout * resolveLayoutForScreen(const QString &screenId) const =0
Convenience: resolve a layout using the registry's current (desktop, activity) context.
virtual int currentVirtualDesktop() const =0
virtual Layout * duplicateLayout(Layout *source)=0
virtual int layoutCount() const =0
Represents a collection of zones that form a layout.
Definition Layout.h:74
Definition IWindowTrackingService.h:22