Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
ShellState.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// Per-screen state owned by ShellHost.
7//
8// Holds the shell-side bookkeeping for one screen: the layer-shell
9// wl_surface, its QQuickWindow, the QScreen pointer the shell was
10// constructed against, and the slot-Item map keyed by slot name.
11//
12// Consumer-specific per-screen state (e.g. content geometry,
13// per-content sentinels) lives in the consumer's parallel per-screen
14// map; ShellState only owns what the library mechanism owns.
15//
16// Mechanism pointers (shellSurface / shellWindow / physScreen) are
17// readable via accessors but not writable from outside the library -
18// only ShellHost (friended) writes them at create / destroy time.
19// The slot map stays public because PostCreateCallback consumers
20// populate it with their slot vocabulary at shell-attach time.
21
23#include <PhosphorOverlay/phosphoroverlay_export.h>
24
25#include <QHash>
26#include <QString>
27
28class QQuickWindow;
29class QScreen;
30
31namespace PhosphorLayer {
32class Surface;
33}
34
35namespace PhosphorOverlay {
36
37class ShellHost;
38
39class PHOSPHOROVERLAY_EXPORT ShellState
40{
41public:
42 ShellState() = default;
43 // Non-copyable, non-movable: ShellHost owns these objects as
44 // heap-allocated raw pointers and consumers cache borrowed
45 // references via `ShellHost::getOrCreateStateFor`. A copy (e.g.
46 // `auto copy = host.getOrCreateStateFor(id)` instead of `auto&`)
47 // would silently duplicate the mechanism pointers and slot map,
48 // leaving the caller's mutations invisible to the host. Block at
49 // compile time.
50 ShellState(const ShellState&) = delete;
52 ShellState& operator=(const ShellState&) = delete;
54
63 {
64 return m_shellSurface;
65 }
66
70 QQuickWindow* shellWindow() const
71 {
72 return m_shellWindow;
73 }
74
78 QScreen* physScreen() const
79 {
80 return m_physScreen;
81 }
82
91 QHash<QString, SlotEntry> slots;
92
93private:
94 friend class ShellHost;
95 PhosphorLayer::Surface* m_shellSurface = nullptr;
96 QQuickWindow* m_shellWindow = nullptr;
97 QScreen* m_physScreen = nullptr;
98};
99
100} // namespace PhosphorOverlay
One layer-shell surface with a managed lifecycle.
Definition Surface.h:99
Definition ShellHost.h:62
Definition ShellState.h:40
ShellState & operator=(const ShellState &)=delete
ShellState(const ShellState &)=delete
QScreen * physScreen() const
The physical QScreen the shell was constructed against.
Definition ShellState.h:78
QQuickWindow * shellWindow() const
The QQuickWindow hosting the shell's QML scene tree.
Definition ShellState.h:70
PhosphorLayer::Surface * shellSurface() const
The layer-shell wl_surface backing this screen's overlay shell.
Definition ShellState.h:62
ShellState & operator=(ShellState &&)=delete
ShellState(ShellState &&)=delete
QHash< QString, SlotEntry > slots
Per-content slot entries keyed by slot name (e.g.
Definition ShellState.h:91
Definition SurfaceAnimator.h:26
Definition ShellHost.h:39
constexpr const char * Surface
Definition LayerSurface.h:21