Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
DecorationManager.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#include <phosphorcompositor_export.h>
7
9
10#include <QHash>
11#include <QObject>
12#include <QString>
13#include <QVector>
14
15#include <optional>
16
17namespace PhosphorCompositor {
18
43class PHOSPHORCOMPOSITOR_EXPORT DecorationManager : public QObject
44{
45 Q_OBJECT
46
47public:
48 enum class OwnerKind {
49 Rule
50 };
51
54 struct Owner
55 {
57 QString screenId;
58 bool operator==(const Owner&) const = default;
59 };
60 static Owner rule()
61 {
62 return {OwnerKind::Rule, QString()};
63 }
64
66 enum class Placement {
69 CallerWillPlace,
73 AlreadyPlaced,
74 };
75
79 explicit DecorationManager(ICompositorBridge& bridge, QObject* parent = nullptr);
80
81 // ── Ownership ──────────────────────────────────────────────────────
90 void acquire(const QString& windowId, const Owner& owner, Placement placement = Placement::AlreadyPlaced);
91
92 // ── Bulk operations ────────────────────────────────────────────────
95 void restoreAll();
98 void forgetWindow(const QString& windowId);
99
100 // ── Window-rule layer (tri-state) ──────────────────────────────────
105 void setRuleOverride(const QString& windowId, std::optional<bool> ruleValue);
109
110 // ── External-reset resync ──────────────────────────────────────────
114 void resyncWindow(const QString& windowId);
115
116 // ── Queries ────────────────────────────────────────────────────────
117 // The state-observation surface: production code expresses everything
118 // through the ownership calls above, so these exist for the behavioral
119 // test spec (and future render-layer integration) to assert manager
120 // state without reaching into internals.
122 bool isBorderless(const QString& windowId) const;
123 bool isOwned(const QString& windowId) const;
124 bool isOwnedBy(const QString& windowId, const Owner& owner) const;
125 bool isVetoed(const QString& windowId) const;
126
127Q_SIGNALS:
132 void windowDecorationRestored(const QString& windowId);
133
134private:
135 struct Entry
136 {
137 QVector<Owner> owners; // small-N linear scan
138 bool vetoed = false;
139 bool evaluated = false;
140 bool eligible = false;
141 bool priorNoBorder = false;
142 bool physicallyHidden = false;
143 };
144
147 void reconcile(const QString& windowId, Entry& entry, Placement placement);
150 void finishRelease(const QString& windowId, Entry& entry);
155 WindowHandle resolveExact(const QString& windowId) const;
156 void hideNow(WindowHandle w, Placement placement);
160 bool restoreNow(const QString& windowId, Entry& entry, bool reassertGeometry);
162 void pruneIfEmpty(const QString& windowId);
163
164 QHash<QString, Entry> m_windows;
165 ICompositorBridge& m_bridge;
166};
167
168} // namespace PhosphorCompositor
The single owner of server-side decoration (title-bar) state.
Definition DecorationManager.h:44
void resyncWindow(const QString &windowId)
The compositor can silently reset noBorder (KWin does on desktop switches).
void clearAllRuleOverrides()
Rules went away wholesale (rule set emptied / teardown): clear every Rule owner and veto,...
void forgetWindow(const QString &windowId)
Window destroyed: drop all state for it.
bool isOwned(const QString &windowId) const
void windowDecorationRestored(const QString &windowId)
Emitted after a physical decoration restore (the effect refreshes border overlays for the window).
bool isOwnedBy(const QString &windowId, const Owner &owner) const
void acquire(const QString &windowId, const Owner &owner, Placement placement=Placement::AlreadyPlaced)
Low-level primitive: take ownership of windowId's decoration and hide it per placement.
DecorationManager(ICompositorBridge &bridge, QObject *parent=nullptr)
bridge must outlive the manager (the KWin effect owns both, with the bridge destroyed after the manag...
void restoreAll()
Daemon loss / effect teardown: synchronously restore every window we hid to its prior state,...
OwnerKind
Definition DecorationManager.h:48
bool isVetoed(const QString &windowId) const
void setRuleOverride(const QString &windowId, std::optional< bool > ruleValue)
nullopt: rule has no opinion — clear Rule owner and veto.
static Owner rule()
Definition DecorationManager.h:60
Placement
How the physical hide coordinates with geometry application.
Definition DecorationManager.h:66
bool isBorderless(const QString &windowId) const
True when we physically suppressed the window's decoration.
Abstract interface bridging compositor-agnostic logic to compositor-specific APIs.
Definition ICompositorBridge.h:94
Definition DaemonClient.h:22
void * WindowHandle
Opaque handle to a compositor window.
Definition ICompositorBridge.h:31
An owner is a (kind, screen) pair.
Definition DecorationManager.h:55
bool operator==(const Owner &) const =default
QString screenId
Definition DecorationManager.h:57
OwnerKind kind
Definition DecorationManager.h:56