Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
SurfaceManager.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 <PhosphorSurfaces/phosphorsurfaces_export.h>
8
10
11#include <QObject>
12
13#include <memory>
14
15QT_BEGIN_NAMESPACE
16class QQmlEngine;
17QT_END_NAMESPACE
18
19namespace PhosphorLayer {
20class Surface;
21}
22
24
25class PHOSPHORSURFACES_EXPORT SurfaceManager : public QObject
26{
27 Q_OBJECT
28
29public:
30 explicit SurfaceManager(SurfaceManagerConfig config, QObject* parent = nullptr);
31 ~SurfaceManager() override;
32
33 QQmlEngine* engine() const;
34
35 // Create a layer-shell surface from the given config. The surface is
36 // warmed up (QML loaded, window created) before return. Returns nullptr
37 // on failure (logged internally). Rejects async QML load paths — callers
38 // must use qrc:/ or file:/ URLs that resolve synchronously.
39 //
40 // Ownership: the returned Surface* is parented to `surfaceParent` if
41 // non-null, otherwise to this SurfaceManager. The caller drives
42 // show/hide/destroy. If the caller does not destroy the surface
43 // explicitly, the QObject parent will — but engine teardown runs in
44 // ~SurfaceManager, so surfaces parented elsewhere must be destroyed
45 // before this SurfaceManager is destroyed.
46 PhosphorLayer::Surface* createSurface(PhosphorLayer::SurfaceConfig cfg, QObject* surfaceParent = nullptr);
47
49
50 bool keepAliveActive() const;
51
52 // Drain deferred-delete events posted by deleteLater() calls on surfaces.
53 // Call this from your destructor body BEFORE member destructors run, if
54 // surfaces are parented to your object rather than to this SurfaceManager.
55 // Without this, surface destructors may touch your already-destroyed members.
57
58Q_SIGNALS:
60
61private:
62 void createKeepAlive();
63 void configureWindow(PhosphorLayer::Surface* surface);
64
65 class Impl;
66 std::unique_ptr<Impl> m_impl;
67};
68
69} // namespace PhosphorSurfaces
One layer-shell surface with a managed lifecycle.
Definition Surface.h:99
Definition SurfaceManager.h:26
SurfaceManager(SurfaceManagerConfig config, QObject *parent=nullptr)
QQmlEngine * engine() const
PhosphorLayer::Surface * createSurface(PhosphorLayer::SurfaceConfig cfg, QObject *surfaceParent=nullptr)
Definition SurfaceAnimator.h:26
Definition SurfaceManager.h:23
constexpr const char * Surface
Definition LayerSurface.h:21
Immutable per-surface configuration passed to SurfaceFactory::create().
Definition SurfaceConfig.h:46
Definition SurfaceManagerConfig.h:25