Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
Role.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 <PhosphorLayer/phosphorlayer_export.h>
7
8#include <QFlags>
9#include <QMargins>
10#include <QObject>
11#include <QString>
12
13#include <cstdint>
14
15namespace PhosphorLayer {
16
19Q_NAMESPACE_EXPORT(PHOSPHORLAYER_EXPORT)
20
21// ── Protocol-level enums (match zwlr_layer_shell_v1 values) ────────────
22
23
24enum class Layer : int {
25 Background = 0,
26 Bottom = 1,
27 Top = 2,
28 Overlay = 3,
29};
30Q_ENUM_NS(Layer)
31
32
34enum class Anchor : std::uint32_t {
35 None = 0,
36 Top = 1U << 0,
37 Bottom = 1U << 1,
38 Left = 1U << 2,
39 Right = 1U << 3,
40};
41Q_DECLARE_FLAGS(Anchors, Anchor)
42Q_FLAG_NS(Anchors)
43
44// Constructed via QFlags' initializer_list ctor so these expressions don't
45// depend on the global-scope operator| from Q_DECLARE_OPERATORS_FOR_FLAGS,
46// which is only declared at the bottom of this header.
47inline constexpr Anchors AnchorNone = Anchors();
49
51enum class KeyboardInteractivity : int {
52 None = 0,
53 Exclusive = 1,
54 OnDemand = 2,
55};
56Q_ENUM_NS(KeyboardInteractivity)
57
58// ── Role: protocol-level configuration bundle ──────────────────────────
59
60
76struct PHOSPHORLAYER_EXPORT Role
77{
79 Anchors anchors = AnchorNone;
80 int exclusiveZone = -1;
83 QString scopePrefix;
84
85 [[nodiscard]] Role withLayer(Layer l) const;
86 [[nodiscard]] Role withAnchors(Anchors a) const;
87 [[nodiscard]] Role withExclusiveZone(int z) const;
88 [[nodiscard]] Role withKeyboard(KeyboardInteractivity k) const;
89 [[nodiscard]] Role withMargins(QMargins m) const;
90 [[nodiscard]] Role withScopePrefix(QString prefix) const;
91
98 [[nodiscard]] bool isValid() const;
99
100 friend bool operator==(const Role& a, const Role& b) = default;
101};
102
103// The legacy `Roles` namespace was removed in phase 1 of the surface
104// taxonomy refactor, and the axis-2 Patterns vocabulary was lifted into
105// its own sibling library `phosphor-shell-patterns` in phase 3. New
106// consumers should depend on PhosphorShellPatterns and use
107// `PhosphorShellPatterns::{Hud, Modal, Wallpaper, Floating, Panel(Edge),
108// Toast(Corner)}` rather than re-deriving Role values inline. See
109// `docs/surface-taxonomy-refactor-plan.md` for the migration map.
110
111} // namespace PhosphorLayer
112
113Q_DECLARE_OPERATORS_FOR_FLAGS(PhosphorLayer::Anchors)
Definition SurfaceAnimator.h:26
constexpr Anchors AnchorAll
Definition Role.h:48
KeyboardInteractivity
Keyboard focus policy (wlr-layer-shell v4 adds OnDemand).
Definition Role.h:51
@ Exclusive
Surface takes exclusive keyboard focus (modals)
@ OnDemand
Surface receives focus when clicked (panels)
@ None
Surface never receives keyboard focus (click-through)
Layer
Meta-object context for namespace-level enums so QML and QMetaEnum can stringify them.
Definition Role.h:24
@ Bottom
Above background, below windows (live wallpapers)
@ Overlay
Above everything including fullscreen (HUDs, OSDs)
@ Top
Above windows (panels, docks)
@ Background
Behind windows (wallpapers)
constexpr Anchors AnchorNone
Definition Role.h:47
Anchor
Edge anchors.
Definition Role.h:34
Value type describing a surface's protocol-level configuration.
Definition Role.h:77
Role withExclusiveZone(int z) const
Role withKeyboard(KeyboardInteractivity k) const
friend bool operator==(const Role &a, const Role &b)=default
Role withLayer(Layer l) const
Role withScopePrefix(QString prefix) const
bool isValid() const
True if this Role is a semantically valid wlr-layer-shell configuration.
Role withMargins(QMargins m) const
QMargins defaultMargins
Definition Role.h:82
Role withAnchors(Anchors a) const
QString scopePrefix
Namespace for this role's surfaces (wl_surface scope)
Definition Role.h:83