11#include <QLatin1String>
47 return state.isEmpty();
106 return engines.value(engineId);
125 if (it.value().isValid() && (best.isEmpty() || it.key() < best)) {
160 for (
auto it =
engines.constBegin(); it !=
engines.constEnd(); ++it) {
192 return QLatin1String(
"snap");
196 return QLatin1String(
"autotile");
200 return QLatin1String(
"scrolling");
212 return QLatin1String(
"free");
216 return QLatin1String(
"floating");
220 return QLatin1String(
"snapped");
224 return QLatin1String(
"tiled");
239 return QLatin1String(
"released");
245 obj[QLatin1String(
"windowId")] =
windowId;
246 obj[QLatin1String(
"screen")] =
screenId;
249 obj[QLatin1String(
"activity")] =
activity;
251 obj[QLatin1String(
"kind")] =
static_cast<int>(
kind);
254 for (
auto it =
engines.constBegin(); it !=
engines.constEnd(); ++it) {
260 so[QLatin1String(
"state")] = s.
state;
263 for (
const QString&
id : s.
zoneIds) {
266 so[QLatin1String(
"zoneIds")] = z;
269 so[QLatin1String(
"order")] = s.
order;
273 if (!eng.isEmpty()) {
274 obj[QLatin1String(
"engines")] = eng;
279 const QRect& g = it.value();
284 go[QLatin1String(
"x")] = g.x();
285 go[QLatin1String(
"y")] = g.y();
286 go[QLatin1String(
"w")] = g.width();
287 go[QLatin1String(
"h")] = g.height();
291 obj[QLatin1String(
"freeGeo")] = fg;
294 obj[QLatin1String(
"seq")] =
static_cast<double>(
sequence);
302 p.
windowId = obj.value(QLatin1String(
"windowId")).toString();
303 p.
screenId = obj.value(QLatin1String(
"screen")).toString();
305 p.
activity = obj.value(QLatin1String(
"activity")).toString();
308 const QJsonObject eng = obj.value(QLatin1String(
"engines")).toObject();
309 for (
auto it = eng.constBegin(); it != eng.constEnd(); ++it) {
310 const QJsonObject so = it.value().toObject();
312 s.
state = so.value(QLatin1String(
"state")).toString();
313 for (
const QJsonValue& v : so.value(QLatin1String(
"zoneIds")).toArray()) {
314 const QString z = v.toString();
319 s.
order = so.value(QLatin1String(
"order")).toInt(-1);
325 const QJsonObject fg = obj.value(QLatin1String(
"freeGeo")).toObject();
326 for (
auto it = fg.constBegin(); it != fg.constEnd(); ++it) {
327 const QJsonObject go = it.value().toObject();
328 const QRect g(go.value(QLatin1String(
"x")).toInt(), go.value(QLatin1String(
"y")).toInt(),
329 go.value(QLatin1String(
"w")).toInt(), go.value(QLatin1String(
"h")).toInt());
335 p.
sequence =
static_cast<quint64
>(obj.value(QLatin1String(
"seq")).toDouble());
404 return !appId.isEmpty() && appId != windowId;
427 return p.
activity.isEmpty() || liveActivity.isEmpty() || p.
activity == liveActivity;
430template<
typename IsEngineMode>
432 const QString& openingScreenId, IsEngineMode&& isEngineMode)
447template<
typename IsSnappingMode>
449 IsSnappingMode&& isSnappingMode)
452 openingScreenId, std::forward<IsSnappingMode>(isSnappingMode));
Definition EngineTypes.h:14
bool pendingCrossScreenSnapRestore(const WindowPlacement &p, const QString &openingScreenId, IsSnappingMode &&isSnappingMode)
The snap-engine specialization of pendingCrossScreenManagedRestore — the original three-way gate (Sna...
Definition WindowPlacement.h:448
bool recordContextMatchesLive(const WindowPlacement &p, int liveDesktop, const QString &liveActivity)
Whether a record's own (desktop, activity) context is compatible with the live context an engine woul...
Definition WindowPlacement.h:422
WindowKind clampWindowKindFromWire(int wire)
Clamp an integer wire value to a valid WindowKind.
Definition EngineTypes.h:82
bool hasStableAppIdFor(const QString &appId, const QString &windowId)
Shared cross-engine ownership predicate over a placement record: does this record carry engineId's sl...
Definition WindowPlacement.h:402
WindowKind
Coarse structural classification for the snap-restore consume gate.
Definition EngineTypes.h:66
bool pendingCrossScreenManagedRestore(const WindowPlacement &p, QLatin1String engineId, QLatin1String managedState, const QString &openingScreenId, IsEngineMode &&isEngineMode)
Definition WindowPlacement.h:431
One engine's view of a window: which managed slot it occupies (or that it is floating / unmanaged) in...
Definition WindowPlacement.h:32
bool isEmpty() const
Definition WindowPlacement.h:45
int order
autotile slot — tile index within the screen; -1 for snap
Definition WindowPlacement.h:35
bool operator==(const EngineSlot &o) const
Definition WindowPlacement.h:37
bool operator!=(const EngineSlot &o) const
Definition WindowPlacement.h:41
QStringList zoneIds
snap slot — zone UUIDs (first is primary); empty for autotile
Definition WindowPlacement.h:34
QString state
engine-defined token: snap "snapped"/"floating"; autotile "tiled"/"floating" ("free" retired)
Definition WindowPlacement.h:33
One window's single, authoritative placement record — the unit of the unified, engine-agnostic restor...
Definition WindowPlacement.h:68
EngineSlot slotFor(const QString &engineId) const
The slot for engineId, or a default (empty) slot if this engine has no recorded state for the window.
Definition WindowPlacement.h:104
static QLatin1String snapEngineId()
Built-in engine-slot ids.
Definition WindowPlacement.h:190
static QLatin1String stateFree()
Common state-token vocabulary.
Definition WindowPlacement.h:210
QRect freeGeometryFor(const QString &screenId) const
The shared free/float geometry for screenId, or an invalid rect if none has been captured on that scr...
Definition WindowPlacement.h:111
static QLatin1String autotileEngineId()
Definition WindowPlacement.h:194
static QLatin1String scrollingEngineId()
Definition WindowPlacement.h:198
WindowKind kind
Definition WindowPlacement.h:86
bool isValid() const
Definition WindowPlacement.h:97
static QLatin1String stateTiled()
Definition WindowPlacement.h:222
bool sameContentAs(const WindowPlacement &o) const
Content equality IGNORING sequence (the store stamps a fresh sequence on every record(),...
Definition WindowPlacement.h:178
static QLatin1String stateReleased()
An engine that KNOWINGLY GAVE THE WINDOW UP (a cross-mode handoff) leaves this instead of its managed...
Definition WindowPlacement.h:237
int virtualDesktop
0 = all-desktops / sticky / unknown.
Definition WindowPlacement.h:84
QString activity
empty = all-activities / unknown
Definition WindowPlacement.h:85
static QLatin1String stateFloating()
Definition WindowPlacement.h:214
QRect anyFreeGeometry() const
Any captured free/float geometry (the deterministic pick of anyFreeGeometryScreenId()),...
Definition WindowPlacement.h:136
QJsonObject toJson() const
Definition WindowPlacement.h:242
QString anyFreeGeometryScreenId() const
The screenId of the deterministic cross-screen fallback pick: the lexicographically-smallest screenId...
Definition WindowPlacement.h:121
static QLatin1String stateSnapped()
Definition WindowPlacement.h:218
static WindowPlacement fromJson(const QString &appId, const QJsonObject &obj)
Definition WindowPlacement.h:298
QString screenId
last managed-context screen
Definition WindowPlacement.h:74
quint64 sequence
Definition WindowPlacement.h:95
QHash< QString, EngineSlot > engines
Definition WindowPlacement.h:89
QString appId
window class; FIFO key for close/reopen (uuid changes)
Definition WindowPlacement.h:71
QHash< QString, QRect > freeGeometryByScreen
Definition WindowPlacement.h:92
QString windowId
full appId|uuid; exact key for daemon-restart (uuid stable)
Definition WindowPlacement.h:70
bool hasRestorableContent() const
Whether this record carries anything worth restoring.
Definition WindowPlacement.h:155