Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
WindowTypes.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 <PhosphorProtocol/phosphorprotocoltypes_export.h>
7
8#include <QList>
9#include <QMetaType>
10#include <QRect>
11#include <QString>
12#include <QStringList>
13#include <cstdlib>
14
15namespace PhosphorProtocol {
16
30inline constexpr int MaxWireExtent = 100000;
31inline constexpr int MaxWireOrigin = 1000000;
32
46{
47 QString windowId;
48 int x = 0;
49 int y = 0;
50 int width = 0;
51 int height = 0;
52 QString screenId;
53
54 QRect toRect() const
55 {
56 return QRect(x, y, width, height);
57 }
58
68 QString validationError() const
69 {
70 if (windowId.isEmpty()) {
71 return QStringLiteral("WindowGeometryEntry: empty windowId");
72 }
73 // Widened before the absolute value: qAbs(INT_MIN) is itself undefined
74 // behaviour in int, and INT_MIN is exactly the sort of value a corrupt
75 // wire payload carries.
76 if (std::abs(static_cast<qint64>(width)) > MaxWireExtent
77 || std::abs(static_cast<qint64>(height)) > MaxWireExtent) {
78 return QStringLiteral("WindowGeometryEntry: implausible size (windowId=%1 w=%2 h=%3)")
79 .arg(windowId)
80 .arg(width)
81 .arg(height);
82 }
83 if (std::abs(static_cast<qint64>(x)) > MaxWireOrigin || std::abs(static_cast<qint64>(y)) > MaxWireOrigin) {
84 return QStringLiteral("WindowGeometryEntry: implausible origin (windowId=%1 x=%2 y=%3)")
85 .arg(windowId)
86 .arg(x)
87 .arg(y);
88 }
89 return {};
90 }
91
92 static WindowGeometryEntry fromRect(const QString& id, const QRect& r)
93 {
94 return {id, r.x(), r.y(), r.width(), r.height(), QString()};
95 }
96 static WindowGeometryEntry fromRect(const QString& id, const QRect& r, const QString& screenId)
97 {
98 return {id, r.x(), r.y(), r.width(), r.height(), screenId};
99 }
100};
101
102using WindowGeometryList = QList<WindowGeometryEntry>;
103
106{
107 QString windowId;
108 QString zoneId;
109 QString screenId;
110 bool isRestore = false;
111};
112
113using SnapConfirmationList = QList<SnapConfirmationEntry>;
114
117{
118 QString windowId;
119 QString screenId;
120 int minWidth = 0;
121 int minHeight = 0;
127 bool focusEligible = false;
128};
129
130using WindowOpenedList = QList<WindowOpenedEntry>;
131
134{
135 QString windowId;
136 QString zoneId;
137 QString screenId;
138 bool isFloating = false;
139 QString changeType;
140 QStringList zoneIds;
141 bool isSticky = false;
142
148 QString validationError() const
149 {
150 if (windowId.isEmpty()) {
151 return QStringLiteral("WindowStateEntry: empty windowId");
152 }
153 return QString();
154 }
155};
156
157using WindowStateList = QList<WindowStateEntry>;
158
164{
165 bool found = false;
166 QStringList zoneIds;
167 QString screenName;
168 int x = 0;
169 int y = 0;
170 int width = 0;
171 int height = 0;
172
173 QRect toRect() const
174 {
175 return QRect(x, y, width, height);
176 }
177};
178
186{
187 QString windowId;
189 QString outputUuid;
191 QString screenId;
195 bool sourceConnected = true;
196 int x = 0, y = 0, width = 0, height = 0;
197 int baseX = 0, baseY = 0, baseWidth = 0, baseHeight = 0;
201 bool fullscreen = false;
204 bool kwinOnly = true;
206 bool placeableNow = true;
208 bool hasS0 = false;
209 QString s0Uuid;
210 QString s0ScreenId;
214 bool s0Fullscreen = false;
215 int s0X = 0, s0Y = 0, s0Width = 0, s0Height = 0;
216
217 QRect geometry() const
218 {
219 return QRect(x, y, width, height);
220 }
221 QRect baseline() const
222 {
223 return QRect(baseX, baseY, baseWidth, baseHeight);
224 }
225
231 QString validationError() const
232 {
233 if (windowId.isEmpty()) {
234 return QStringLiteral("OutputSettleRow: empty windowId");
235 }
236 if (screenId.isEmpty()) {
237 return QStringLiteral("OutputSettleRow: empty screenId (windowId=%1)").arg(windowId);
238 }
239 return QString();
240 }
241};
242
243using OutputSettleRowList = QList<OutputSettleRow>;
244
247{
248 enum Kind : int {
249 None = 0,
254 };
255 QString windowId;
258 QString screenId;
259
260 QString validationError() const
261 {
262 if (windowId.isEmpty()) {
263 return QStringLiteral("OutputSettleVerdict: empty windowId");
264 }
266 return QStringLiteral("OutputSettleVerdict: unknown verdict %1 (windowId=%2)").arg(verdict).arg(windowId);
267 }
268 return QString();
269 }
270};
271
272using OutputSettleVerdictList = QList<OutputSettleVerdict>;
273
280enum class PlacementPurpose : int {
283};
284
292
303
311
312} // namespace PhosphorProtocol
313
314Q_DECLARE_METATYPE(PhosphorProtocol::OutputSettleRow)
319Q_DECLARE_METATYPE(PhosphorProtocol::WindowGeometryList)
322Q_DECLARE_METATYPE(PhosphorProtocol::WindowOpenedEntry)
323Q_DECLARE_METATYPE(PhosphorProtocol::WindowOpenedList)
324Q_DECLARE_METATYPE(PhosphorProtocol::WindowStateEntry)
325Q_DECLARE_METATYPE(PhosphorProtocol::WindowStateList)
D-Bus marshalling for the shared tiling-family value types (see AutotileTypes.h; the file names preda...
Definition AutotileMarshalling.h:19
constexpr int MaxWireOrigin
Definition WindowTypes.h:31
QList< SnapConfirmationEntry > SnapConfirmationList
Definition WindowTypes.h:113
PlacementPurpose
Why the daemon asks the compositor to place a window, carried by WindowTracking.applyGeometryRequeste...
Definition WindowTypes.h:280
@ Restatement
Definition WindowTypes.h:282
@ UserVerb
Definition WindowTypes.h:281
ScreenDesktopSwitchPurpose
Why the daemon asks the compositor to switch one output's virtual desktop, carried by WindowTracking....
Definition WindowTypes.h:299
@ UserSwitch
Definition WindowTypes.h:300
@ Correction
Definition WindowTypes.h:301
QList< WindowStateEntry > WindowStateList
Definition WindowTypes.h:157
ScreenDesktopSwitchPurpose clampScreenDesktopSwitchPurposeFromWire(int wire)
Clamp an integer wire value to a ScreenDesktopSwitchPurpose.
Definition WindowTypes.h:306
QList< OutputSettleRow > OutputSettleRowList
Definition WindowTypes.h:243
QList< WindowGeometryEntry > WindowGeometryList
Definition WindowTypes.h:102
constexpr int MaxWireExtent
Magnitude ceilings shared by every geometry-bearing wire struct.
Definition WindowTypes.h:30
QList< OutputSettleVerdict > OutputSettleVerdictList
Definition WindowTypes.h:272
QList< WindowOpenedEntry > WindowOpenedList
Definition WindowTypes.h:130
PlacementPurpose clampPlacementPurposeFromWire(int wire)
Clamp an integer wire value to a PlacementPurpose.
Definition WindowTypes.h:287
One window in the effect's output-settle report, sent when a screen change settles that added or remo...
Definition WindowTypes.h:186
int baseWidth
Definition WindowTypes.h:197
int maximizeMode
Definition WindowTypes.h:199
bool kwinOnly
Only KWin moved it: no interactive move or resize since the baseline.
Definition WindowTypes.h:204
bool sourceConnected
Whether that output is still connected.
Definition WindowTypes.h:195
QString screenId
The PlasmaZones physical id of that output.
Definition WindowTypes.h:191
QRect geometry() const
Definition WindowTypes.h:217
QString outputUuid
KWin's uuid of the output the window is on now (moveResizeOutput).
Definition WindowTypes.h:189
int s0MaximizeMode
Definition WindowTypes.h:212
int x
Definition WindowTypes.h:196
QString validationError() const
Definition WindowTypes.h:231
int baseX
Definition WindowTypes.h:197
QString s0ScreenId
Definition WindowTypes.h:210
int s0MoveResizeCount
Definition WindowTypes.h:211
int s0Y
Definition WindowTypes.h:215
int s0Height
Definition WindowTypes.h:215
bool fullscreen
Definition WindowTypes.h:201
int s0Width
Definition WindowTypes.h:215
int quickTileMode
Definition WindowTypes.h:200
bool placeableNow
On the desktop its own output shows and the current activity, and not minimized.
Definition WindowTypes.h:206
int height
moveResizeGeometry now
Definition WindowTypes.h:196
int y
Definition WindowTypes.h:196
int width
Definition WindowTypes.h:196
int s0QuickTileMode
Definition WindowTypes.h:213
int moveResizeCount
interactiveMoveResizeCount now
Definition WindowTypes.h:198
int s0X
Definition WindowTypes.h:215
bool hasS0
The fields below carry S0, the state when its output went away.
Definition WindowTypes.h:208
QString sourceScreenId
The PlasmaZones physical id of the output it was on when the debounce began.
Definition WindowTypes.h:193
int baseY
Definition WindowTypes.h:197
QRect baseline() const
Definition WindowTypes.h:221
int baseHeight
the frame when the debounce began
Definition WindowTypes.h:197
QString s0Uuid
Definition WindowTypes.h:209
bool s0Fullscreen
Definition WindowTypes.h:214
bool stateEqualsS0() const
Whether the window's KWin state now equals S0 (false without one).
Definition WindowTypes.h:226
QString windowId
Definition WindowTypes.h:187
The daemon's answer for one OutputSettleRow: (sis).
Definition WindowTypes.h:247
Kind
Definition WindowTypes.h:248
@ EvacueeFloat
an evacuee: adopted floating where KWin put it
Definition WindowTypes.h:251
@ Reassert
the daemon re-asserted its placement after KWin moved it
Definition WindowTypes.h:252
@ Readopt
re-seated in its parked place on the output it returned to
Definition WindowTypes.h:250
@ None
nothing to do; the effect replays a deferred crossing as a move
Definition WindowTypes.h:249
@ UserMove
touched: the crossing is the user's move
Definition WindowTypes.h:253
int verdict
Definition WindowTypes.h:256
QString validationError() const
Definition WindowTypes.h:260
QString windowId
Definition WindowTypes.h:255
QString screenId
The screen the verdict placed the window on, when it placed it.
Definition WindowTypes.h:258
D-Bus struct for batch snap confirmation: (sssb).
Definition WindowTypes.h:106
QString windowId
Definition WindowTypes.h:107
bool isRestore
Definition WindowTypes.h:110
QString zoneId
Definition WindowTypes.h:108
QString screenId
Definition WindowTypes.h:109
D-Bus struct for unfloat restore result: (bassiiii).
Definition WindowTypes.h:164
QStringList zoneIds
D-Bus type 'as'.
Definition WindowTypes.h:166
int y
Definition WindowTypes.h:169
int x
Definition WindowTypes.h:168
QString screenName
Definition WindowTypes.h:167
int height
Definition WindowTypes.h:171
bool found
Definition WindowTypes.h:165
int width
Definition WindowTypes.h:170
QRect toRect() const
Definition WindowTypes.h:173
D-Bus struct for batch geometry entries: (siiiis).
Definition WindowTypes.h:46
int width
Definition WindowTypes.h:50
QString screenId
target VS/physical screen (empty = fall back to geometry resolution)
Definition WindowTypes.h:52
QString windowId
Definition WindowTypes.h:47
static WindowGeometryEntry fromRect(const QString &id, const QRect &r, const QString &screenId)
Definition WindowTypes.h:96
static WindowGeometryEntry fromRect(const QString &id, const QRect &r)
Definition WindowTypes.h:92
QRect toRect() const
Definition WindowTypes.h:54
int x
Definition WindowTypes.h:48
int y
Definition WindowTypes.h:49
QString validationError() const
Empty when the entry is safe to consume; a diagnostic otherwise.
Definition WindowTypes.h:68
int height
Definition WindowTypes.h:51
D-Bus struct for batch window-opened notification: (ssii).
Definition WindowTypes.h:117
QString windowId
Definition WindowTypes.h:118
QString screenId
Definition WindowTypes.h:119
int minWidth
Definition WindowTypes.h:120
int minHeight
Definition WindowTypes.h:121
bool focusEligible
NOT on the wire (the marshalling carries the four fields above): the daemon stamps it from the method...
Definition WindowTypes.h:127
D-Bus struct for window state: (sssbsasb).
Definition WindowTypes.h:134
QString changeType
"snapped", "unsnapped", "floated", "unfloated", "screen_changed"
Definition WindowTypes.h:139
QString screenId
Definition WindowTypes.h:137
QString validationError() const
Returns empty QString if valid, else a human-readable description of the invariant violation.
Definition WindowTypes.h:148
QString windowId
Definition WindowTypes.h:135
QString zoneId
Definition WindowTypes.h:136
bool isFloating
Definition WindowTypes.h:138
QStringList zoneIds
D-Bus type 'as' — all zone IDs for multi-zone span (query only).
Definition WindowTypes.h:140
bool isSticky
Whether window is on all virtual desktops (query only).
Definition WindowTypes.h:141