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 <QMetaObject>
27#include <QString>
28
29class QQuickWindow;
30class QScreen;
31
32namespace PhosphorLayer {
33class Surface;
34}
35
36namespace PhosphorOverlay {
37
38class ShellHost;
39
40class PHOSPHOROVERLAY_EXPORT ShellState
41{
42public:
43 ShellState() = default;
44 // Non-copyable, non-movable: ShellHost owns these objects as
45 // heap-allocated raw pointers and consumers cache borrowed
46 // references via `ShellHost::getOrCreateStateFor`. A copy (e.g.
47 // `auto copy = host.getOrCreateStateFor(id)` instead of `auto&`)
48 // would silently duplicate the mechanism pointers and slot map,
49 // leaving the caller's mutations invisible to the host. Block at
50 // compile time.
51 ShellState(const ShellState&) = delete;
53 ShellState& operator=(const ShellState&) = delete;
55
64 {
65 return m_shellSurface;
66 }
67
73 QQuickWindow* shellWindow() const
74 {
75 return m_shellWindow;
76 }
77
81 QScreen* physScreen() const
82 {
83 return m_physScreen;
84 }
85
95 QHash<QString, SlotEntry> slots;
96
97private:
98 friend class ShellHost;
104 PhosphorLayer::Surface* m_shellSurface = nullptr;
105 QQuickWindow* m_shellWindow = nullptr;
106 QScreen* m_physScreen = nullptr;
113 QMetaObject::Connection m_surfaceStateWatch;
114 QMetaObject::Connection m_firstFrameWatch;
115 bool m_awaitingFirstFrame = false;
116 bool m_keyboardGrabDeferred = false;
117};
118
119} // namespace PhosphorOverlay
One layer-shell surface with a managed lifecycle.
Definition Surface.h:105
Definition ShellHost.h:62
friend class ShellHost
Definition ShellState.h:98
ShellState & operator=(const ShellState &)=delete
ShellState(const ShellState &)=delete
QScreen * physScreen() const
The physical QScreen the shell was constructed against.
Definition ShellState.h:81
QQuickWindow * shellWindow() const
The QQuickWindow hosting the shell's QML scene tree.
Definition ShellState.h:73
PhosphorLayer::Surface * shellSurface() const
The layer-shell wl_surface backing this screen's overlay shell.
Definition ShellState.h:63
ShellState & operator=(ShellState &&)=delete
ShellState(ShellState &&)=delete
QHash< QString, SlotEntry > slots
Per-content slot entries keyed by slot name (e.g.
Definition ShellState.h:95
Definition SurfaceAnimator.h:26
Definition ShellHost.h:39