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::stateFor`. A copy (e.g. `auto copy =
46 // host.stateFor(id)` instead of `auto&`) would silently duplicate
47 // the mechanism pointers and slot map, leaving the caller's
48 // mutations invisible to the host. Block at compile time.
49 ShellState(const ShellState&) = delete;
51 ShellState& operator=(const ShellState&) = delete;
53
62 {
63 return m_shellSurface;
64 }
65
69 QQuickWindow* shellWindow() const
70 {
71 return m_shellWindow;
72 }
73
77 QScreen* physScreen() const
78 {
79 return m_physScreen;
80 }
81
90 QHash<QString, SlotEntry> slots;
91
92private:
93 friend class ShellHost;
94 PhosphorLayer::Surface* m_shellSurface = nullptr;
95 QQuickWindow* m_shellWindow = nullptr;
96 QScreen* m_physScreen = nullptr;
97};
98
99} // 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:77
QQuickWindow * shellWindow() const
The QQuickWindow hosting the shell's QML scene tree.
Definition ShellState.h:69
PhosphorLayer::Surface * shellSurface() const
The layer-shell wl_surface backing this screen's overlay shell.
Definition ShellState.h:61
ShellState & operator=(ShellState &&)=delete
ShellState(ShellState &&)=delete
QHash< QString, SlotEntry > slots
Per-content slot entries keyed by slot name (e.g.
Definition ShellState.h:90
Definition SurfaceAnimator.h:26
Definition ShellHost.h:39
constexpr const char * Surface
Definition LayerSurface.h:21