Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
SurfaceConfig.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
7#include <PhosphorLayer/phosphorlayer_export.h>
8
9#include <QMargins>
10#include <QSize>
11#include <QString>
12#include <QUrl>
13#include <QVariantMap>
14
15#include <memory>
16#include <optional>
17
18QT_BEGIN_NAMESPACE
19class QQmlEngine;
20class QQuickItem;
21class QScreen;
22QT_END_NAMESPACE
23
24namespace PhosphorLayer {
25
45struct PHOSPHORLAYER_EXPORT SurfaceConfig
46{
49
53
58 std::unique_ptr<QQuickItem> contentItem;
59
63 QScreen* screen = nullptr;
64
67 QVariantMap contextProperties;
68
75 QVariantMap windowProperties;
76
80 QQmlEngine* sharedEngine = nullptr;
81
82 // ── Per-instance overrides ──────────────────────────────────────────
83 // nullopt = use the role's default. All are applied at surface-creation
84 // time; post-show mutation of these fields has no effect (SurfaceConfig
85 // is stored const on the Surface).
86
87 std::optional<Layer> layerOverride;
88 std::optional<Anchors> anchorsOverride;
89 std::optional<int> exclusiveZoneOverride;
90 std::optional<KeyboardInteractivity> keyboardOverride;
91 std::optional<QMargins> marginsOverride;
92
93 // ── Lifecycle policy ────────────────────────────────────────────────
110 bool keepMappedOnHide = false;
111
133 QSize initialSize = {};
134
136 QString debugName;
137
138 // ── Resolution helpers ──────────────────────────────────────────────
139
140 [[nodiscard]] Layer effectiveLayer() const noexcept
141 {
142 return layerOverride.value_or(role.layer);
143 }
144 [[nodiscard]] Anchors effectiveAnchors() const noexcept
145 {
146 return anchorsOverride.value_or(role.anchors);
147 }
148 [[nodiscard]] int effectiveExclusiveZone() const noexcept
149 {
150 return exclusiveZoneOverride.value_or(role.exclusiveZone);
151 }
152 [[nodiscard]] KeyboardInteractivity effectiveKeyboard() const noexcept
153 {
154 return keyboardOverride.value_or(role.keyboard);
155 }
156 [[nodiscard]] QMargins effectiveMargins() const noexcept
157 {
158 return marginsOverride.value_or(role.defaultMargins);
159 }
160 [[nodiscard]] QString effectiveDebugName() const
161 {
162 return debugName.isEmpty() ? role.scopePrefix : debugName;
163 }
164
165 // Special members defined out-of-line (in surface.cpp) so QQuickItem
166 // need only be forward-declared here — the concrete ~unique_ptr<QQuickItem>
167 // call sites live where QQuickItem is complete.
170 SurfaceConfig(const SurfaceConfig&) = delete;
173 SurfaceConfig& operator=(SurfaceConfig&&) noexcept;
174};
175
176} // namespace PhosphorLayer
Definition SurfaceAnimator.h:26
KeyboardInteractivity
Keyboard focus policy (wlr-layer-shell v4 adds OnDemand).
Definition Role.h:51
Layer
Meta-object context for namespace-level enums so QML and QMetaEnum can stringify them.
Definition Role.h:24
Value type describing a surface's protocol-level configuration.
Definition Role.h:77
Layer layer
Definition Role.h:78
int exclusiveZone
-1 = ignore other surfaces' zones
Definition Role.h:80
QMargins defaultMargins
Definition Role.h:82
QString scopePrefix
Namespace for this role's surfaces (wl_surface scope)
Definition Role.h:83
Anchors anchors
Definition Role.h:79
KeyboardInteractivity keyboard
Definition Role.h:81
Immutable per-surface configuration passed to SurfaceFactory::create().
Definition SurfaceConfig.h:46
Layer effectiveLayer() const noexcept
Definition SurfaceConfig.h:140
QUrl contentUrl
QML root component URL (qrc:/… or file://…).
Definition SurfaceConfig.h:52
SurfaceConfig & operator=(const SurfaceConfig &)=delete
std::optional< int > exclusiveZoneOverride
Definition SurfaceConfig.h:89
SurfaceConfig(SurfaceConfig &&) noexcept
SurfaceConfig(const SurfaceConfig &)=delete
std::optional< QMargins > marginsOverride
Definition SurfaceConfig.h:91
QVariantMap windowProperties
Applied to the QQuickWindow as dynamic properties (via QObject:: setProperty) BEFORE the QML content ...
Definition SurfaceConfig.h:75
QMargins effectiveMargins() const noexcept
Definition SurfaceConfig.h:156
std::optional< KeyboardInteractivity > keyboardOverride
Definition SurfaceConfig.h:90
std::optional< Anchors > anchorsOverride
Definition SurfaceConfig.h:88
QString effectiveDebugName() const
Definition SurfaceConfig.h:160
KeyboardInteractivity effectiveKeyboard() const noexcept
Definition SurfaceConfig.h:152
QVariantMap contextProperties
Injected into the surface's QML root context.
Definition SurfaceConfig.h:67
int effectiveExclusiveZone() const noexcept
Definition SurfaceConfig.h:148
std::unique_ptr< QQuickItem > contentItem
Pre-built QQuickItem.
Definition SurfaceConfig.h:58
QString debugName
Logged in state transitions. Defaults to Role::scopePrefix when empty.
Definition SurfaceConfig.h:136
Role role
Protocol-level defaults. Required.
Definition SurfaceConfig.h:48
Anchors effectiveAnchors() const noexcept
Definition SurfaceConfig.h:144
std::optional< Layer > layerOverride
Definition SurfaceConfig.h:87