Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
Surface.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 <QObject>
10#include <QString>
11
12#include <memory>
13
14QT_BEGIN_NAMESPACE
15class QQuickWindow;
16QT_END_NAMESPACE
17
18namespace PhosphorLayer {
19
20class ILayerShellTransport;
21class IQmlEngineProvider;
22class IScreenProvider;
23class ISurfaceAnimator;
24class ITransportHandle;
25class SurfaceFactory;
26
42{
44 IQmlEngineProvider* engineProvider = nullptr; // Optional — nullptr = per-surface engine
62};
63
98class PHOSPHORLAYER_EXPORT Surface : public QObject
99{
100 Q_OBJECT
101 Q_PROPERTY(State state READ state NOTIFY stateChanged FINAL)
102
103public:
104 enum class State {
105 Constructed,
106 Warming,
107 Shown,
108 Hidden,
109 Failed,
110 };
116 Q_ENUM(State)
117
118 ~Surface() override;
119
120 State state() const noexcept;
121 const SurfaceConfig& config() const noexcept;
122
141 [[nodiscard]] bool isLogicallyShown() const noexcept;
142
155public Q_SLOTS:
156 void show();
157 void hide();
160 void warmUp();
162
163public:
169 QQuickWindow* window() const noexcept;
170 ITransportHandle* transport() const noexcept;
172
173Q_SIGNALS:
177 void stateChanged(State newState);
178
188 void failed(const QString& reason);
189
201 void screenLost();
202
203public:
222 {
223 friend class SurfaceFactory;
224 CtorToken() = default;
225 };
226
227protected:
231 Surface(CtorToken, SurfaceConfig cfg, SurfaceDeps deps, QObject* parent);
232
233private:
234 Q_DISABLE_COPY_MOVE(Surface)
235
236 friend class SurfaceFactory;
237
238 class Impl;
239 std::unique_ptr<Impl> m_impl;
240};
241
242} // namespace PhosphorLayer
Abstracts the layer-shell protocol binding.
Definition ILayerShellTransport.h:111
Hook point for consumer-controlled QQmlEngine ownership policy.
Definition IQmlEngineProvider.h:32
Source-of-truth interface for the available QScreen set.
Definition IScreenProvider.h:62
Hook point for show/hide transitions on Surfaces.
Definition ISurfaceAnimator.h:50
Handle returned by attach(); lets the caller mutate post-show properties that the wlr-layer-shell pro...
Definition ILayerShellTransport.h:53
Stateless constructor for Surfaces.
Definition SurfaceFactory.h:35
Opaque construction token — only SurfaceFactory can create instances of it.
Definition Surface.h:222
One layer-shell surface with a managed lifecycle.
Definition Surface.h:99
~Surface() override
Q_ENUM so QMetaEnum can stringify State values in log messages (State::Failed → "Failed") and so Q_PR...
State state() const noexcept
State
Definition Surface.h:104
Surface(CtorToken, SurfaceConfig cfg, SurfaceDeps deps, QObject *parent)
Protected so subclasses can forward a CtorToken through their own constructor.
Definition SurfaceAnimator.h:26
Immutable per-surface configuration passed to SurfaceFactory::create().
Definition SurfaceConfig.h:46
Bundle of dependencies the Surface inherits from the factory.
Definition Surface.h:42
QString loggingCategory
Definition Surface.h:61
ILayerShellTransport * transport
Definition Surface.h:43
ISurfaceAnimator * animator
Phase-5 hook for show/hide visual transitions.
Definition Surface.h:60
IQmlEngineProvider * engineProvider
Definition Surface.h:44
IScreenProvider * screenProvider
Screen provider the Surface subscribes to for hot-unplug detection.
Definition Surface.h:49