Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PanelWindow.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 <PhosphorShell/phosphorshell_export.h>
7
8#include <QMargins>
9#include <QPointer>
10#include <QQuickItem>
11
12QT_BEGIN_NAMESPACE
13class QScreen;
14QT_END_NAMESPACE
15
16namespace PhosphorShell {
17
18class PHOSPHORSHELL_EXPORT PanelWindow : public QQuickItem
19{
20 Q_OBJECT
21
22 Q_PROPERTY(Edge edge READ edge WRITE setEdge NOTIFY edgeChanged)
23 Q_PROPERTY(int thickness READ thickness WRITE setThickness NOTIFY thicknessChanged)
32 Q_PROPERTY(int shadowSize READ shadowSize WRITE setShadowSize NOTIFY shadowSizeChanged)
45 Q_PROPERTY(int cornerCarveRadius READ cornerCarveRadius WRITE setCornerCarveRadius NOTIFY cornerCarveRadiusChanged)
46 Q_PROPERTY(QScreen* screen READ screen WRITE setScreen NOTIFY screenChanged)
47 // `panelLayer` rather than `layer` — QQuickItem already exposes a
48 // FINAL `layer` group property (the cached-rendering layer accessed
49 // as `Item.layer.enabled`), and shadowing it triggered a
50 // `qt.qml.propertyCache: Final member layer is overridden` warning
51 // on every panel construction. Renaming avoids the collision.
52 Q_PROPERTY(Layer panelLayer READ panelLayer WRITE setPanelLayer NOTIFY panelLayerChanged)
53 Q_PROPERTY(int exclusiveZone READ exclusiveZone WRITE setExclusiveZone NOTIFY exclusiveZoneChanged)
54 Q_PROPERTY(bool exclusiveZoneEnabled READ exclusiveZoneEnabled WRITE setExclusiveZoneEnabled NOTIFY
55 exclusiveZoneEnabledChanged)
56 Q_PROPERTY(Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
57 Q_PROPERTY(int panelLength READ panelLength WRITE setPanelLength NOTIFY panelLengthChanged)
58 Q_PROPERTY(QMargins margins READ margins WRITE setMargins NOTIFY marginsChanged)
59 // Layer-shell keyboard_interactivity. Default `None` matches what
60 // Plasma's panel ships with: panels grab pointer events for their
61 // own widgets but never keyboard focus from other windows. Clicking
62 // a tray icon shouldn't steal focus from the user's terminal /
63 // editor / browser. Set to `OnDemand` when the panel hosts an
64 // input field (search launcher etc.) that needs key events; set
65 // to `Exclusive` for shell-modal surfaces like a lock screen.
66 // Popups attached to the panel get their own xdg_popup grab and
67 // can receive keyboard input independently of this setting.
68 Q_PROPERTY(KeyboardFocus keyboardFocus READ keyboardFocus WRITE setKeyboardFocus NOTIFY keyboardFocusChanged)
69
70public:
77 Q_ENUM(Edge)
78
85 Q_ENUM(Layer)
86
93 Q_ENUM(Alignment)
94
95 // Mirror of PhosphorLayer::KeyboardInteractivity. Kept in this
96 // namespace so QML doesn't need to import PhosphorLayer just to
97 // name the enumerators. ShellEngine maps these to the layer
98 // library's enum at surface-creation time.
102 Exclusive
103 };
104 Q_ENUM(KeyboardFocus)
105
106 explicit PanelWindow(QQuickItem* parent = nullptr);
107 ~PanelWindow() override;
108
109 [[nodiscard]] Edge edge() const;
110 void setEdge(Edge edge);
111
112 [[nodiscard]] int thickness() const;
113 void setThickness(int thickness);
114
115 [[nodiscard]] int shadowSize() const;
116 void setShadowSize(int size);
117
118 [[nodiscard]] int cornerCarveRadius() const;
119 void setCornerCarveRadius(int radius);
120
121 [[nodiscard]] QScreen* screen() const;
122 void setScreen(QScreen* screen);
123
124 [[nodiscard]] Layer panelLayer() const;
125 void setPanelLayer(Layer layer);
126
127 [[nodiscard]] int exclusiveZone() const;
128 void setExclusiveZone(int zone);
129
130 [[nodiscard]] bool exclusiveZoneEnabled() const;
131 void setExclusiveZoneEnabled(bool enabled);
132
133 [[nodiscard]] Alignment alignment() const;
134 void setAlignment(Alignment alignment);
135
136 [[nodiscard]] int panelLength() const;
137 void setPanelLength(int length);
138
139 [[nodiscard]] QMargins margins() const;
140 void setMargins(const QMargins& margins);
141
142 [[nodiscard]] KeyboardFocus keyboardFocus() const;
143 void setKeyboardFocus(KeyboardFocus focus);
144
145Q_SIGNALS:
146 void edgeChanged();
147 void thicknessChanged();
148 void shadowSizeChanged();
149 void cornerCarveRadiusChanged();
150 void screenChanged();
151 void panelLayerChanged();
152 void exclusiveZoneChanged();
153 void exclusiveZoneEnabledChanged();
154 void alignmentChanged();
155 void panelLengthChanged();
156 void marginsChanged();
157 void keyboardFocusChanged();
158
159private:
160 Edge m_edge = Top;
161 int m_thickness = 32;
162 int m_shadowSize = 0;
163 int m_cornerCarveRadius = 0;
164 // QPointer so monitor hot-unplug doesn't leave us with a dangling
165 // QScreen pointer. ScreenManager owns QScreen lifetimes externally.
166 QPointer<QScreen> m_screen;
167 Layer m_layer = LayerTop;
168 // -1 sentinel: "no explicit override, derive from alignment"
169 // 0 sentinel: "auto-fit to content via implicitWidth/Height"
170 // >0: "explicit pin in screen-axis pixels"
171 int m_exclusiveZone = -1;
172 bool m_exclusiveZoneEnabled = true;
173 Alignment m_alignment = Fill;
174 // -1 sentinel: "fill the screen-aligned axis (Fill alignment)"
175 // 0 sentinel: "auto-fit to root item's implicitWidth/Height"
176 // >0: "explicit pin in screen-axis pixels"
177 int m_panelLength = -1;
178 QMargins m_margins;
179 KeyboardFocus m_keyboardFocus = None;
180};
181
182} // namespace PhosphorShell
Definition PanelWindow.h:19
Alignment
Definition PanelWindow.h:87
@ Fill
Definition PanelWindow.h:88
@ Center
Definition PanelWindow.h:90
@ Start
Definition PanelWindow.h:89
@ End
Definition PanelWindow.h:91
Edge
Additional surface pixels rendered BEYOND the visible panel thickness, intended for the shell to draw...
Definition PanelWindow.h:71
@ Left
Definition PanelWindow.h:74
@ Right
Definition PanelWindow.h:75
@ Top
Definition PanelWindow.h:72
@ Bottom
Definition PanelWindow.h:73
KeyboardFocus
Definition PanelWindow.h:99
@ None
Never receives keyboard focus (default — typical panel).
Definition PanelWindow.h:100
@ OnDemand
Receives focus when the user clicks the surface.
Definition PanelWindow.h:101
Layer
Definition PanelWindow.h:79
@ LayerOverlay
Definition PanelWindow.h:83
@ LayerTop
Definition PanelWindow.h:82
@ LayerBottom
Definition PanelWindow.h:81
@ LayerBackground
Definition PanelWindow.h:80
Definition Environment.h:11