13#include <QLatin1String>
75 return state.isEmpty();
145 return engines.value(engineId);
170 return exact.value();
184 if (bestKey.isEmpty() || it.key() < bestKey) {
201 if (it.value().isValid() && (best.isEmpty() || it.key() < best)) {
237 for (
auto it =
engines.constBegin(); it !=
engines.constEnd(); ++it) {
269 return QLatin1String(
"snap");
273 return QLatin1String(
"autotile");
277 return QLatin1String(
"scrolling");
289 return QLatin1String(
"free");
293 return QLatin1String(
"floating");
297 return QLatin1String(
"snapped");
301 return QLatin1String(
"tiled");
316 return QLatin1String(
"released");
322 obj[QLatin1String(
"windowId")] =
windowId;
323 obj[QLatin1String(
"screen")] =
screenId;
326 obj[QLatin1String(
"activity")] =
activity;
328 obj[QLatin1String(
"kind")] =
static_cast<int>(
kind);
331 for (
auto it =
engines.constBegin(); it !=
engines.constEnd(); ++it) {
337 so[QLatin1String(
"state")] = s.
state;
340 for (
const QString&
id : s.
zoneIds) {
343 so[QLatin1String(
"zoneIds")] = z;
346 so[QLatin1String(
"order")] = s.
order;
353 QJsonObject byDesktop;
355 if (d.value().isEmpty()) {
359 for (
const QString&
id : d.value()) {
362 byDesktop[QString::number(d.key())] = dz;
364 if (!byDesktop.isEmpty()) {
365 so[QLatin1String(
"zonesByDesktop")] = byDesktop;
370 if (!eng.isEmpty()) {
371 obj[QLatin1String(
"engines")] = eng;
376 const QRect& g = it.value();
381 go[QLatin1String(
"x")] = g.x();
382 go[QLatin1String(
"y")] = g.y();
383 go[QLatin1String(
"w")] = g.width();
384 go[QLatin1String(
"h")] = g.height();
388 obj[QLatin1String(
"freeGeo")] = fg;
391 obj[QLatin1String(
"seq")] =
static_cast<double>(
sequence);
400 p.
windowId = obj.value(QLatin1String(
"windowId")).toString();
401 p.
screenId = obj.value(QLatin1String(
"screen")).toString();
408 const int rawDesktop = obj.value(QLatin1String(
"desktop")).toInt();
410 p.
activity = obj.value(QLatin1String(
"activity")).toString();
413 const QJsonObject eng = obj.value(QLatin1String(
"engines")).toObject();
414 for (
auto it = eng.constBegin(); it != eng.constEnd(); ++it) {
415 const QJsonObject so = it.value().toObject();
417 s.
state = so.value(QLatin1String(
"state")).toString();
418 for (
const QJsonValue& v : so.value(QLatin1String(
"zoneIds")).toArray()) {
419 const QString z = v.toString();
424 s.
order = so.value(QLatin1String(
"order")).toInt(-1);
425 const QJsonObject byDesktop = so.value(QLatin1String(
"zonesByDesktop")).toObject();
426 for (
auto d = byDesktop.constBegin(); d != byDesktop.constEnd(); ++d) {
428 const int desktop = d.key().toInt(&ok);
439 for (
const QJsonValue& v : d.value().toArray()) {
440 const QString z = v.toString();
445 if (!zones.isEmpty()) {
454 const QJsonObject fg = obj.value(QLatin1String(
"freeGeo")).toObject();
455 for (
auto it = fg.constBegin(); it != fg.constEnd(); ++it) {
456 const QJsonObject go = it.value().toObject();
457 const QRect g(go.value(QLatin1String(
"x")).toInt(), go.value(QLatin1String(
"y")).toInt(),
458 go.value(QLatin1String(
"w")).toInt(), go.value(QLatin1String(
"h")).toInt());
464 p.
sequence =
static_cast<quint64
>(obj.value(QLatin1String(
"seq")).toDouble());
466 p.
reclaimEligible = obj.value(QLatin1String(
"liveAtSave")).toBool(
true);
517 return !appId.isEmpty() && appId != windowId;
540 return p.
activity.isEmpty() || liveActivity.isEmpty() || p.
activity == liveActivity;
543template<
typename IsEngineMode>
545 const QString& openingScreenId, IsEngineMode&& isEngineMode)
559template<
typename IsSnappingMode>
561 IsSnappingMode&& isSnappingMode)
564 openingScreenId, std::forward<IsSnappingMode>(isSnappingMode));
576template<
typename IsEngineMode>
578 const QString& openingWindowId,
const QString& openingScreenId,
579 IsEngineMode&& isEngineMode)
588 std::forward<IsEngineMode>(isEngineMode));
592template<
typename IsSnappingMode>
594 const QString& openingScreenId, IsSnappingMode&& isSnappingMode)
597 openingWindowId, openingScreenId,
598 std::forward<IsSnappingMode>(isSnappingMode));
609 if (own.
screenId.isEmpty() || openingScreenId.isEmpty() || own.
screenId == openingScreenId) {
612 for (
auto it = own.
engines.constBegin(); it != own.
engines.constEnd(); ++it) {
Definition DesktopRemap.h:12
bool pendingCrossScreenSnapRestore(const WindowPlacement &p, const QString &openingScreenId, IsSnappingMode &&isSnappingMode)
The snap-engine specialization of the 5-argument form.
Definition WindowPlacement.h:560
constexpr int MAX_PLAUSIBLE_VIRTUAL_DESKTOP
Upper sanity bound for a virtual desktop number read back from disk.
Definition WindowPlacement.h:27
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:535
WindowKind clampWindowKindFromWire(int wire)
Clamp an integer wire value to a valid WindowKind.
Definition EngineTypes.h:89
bool hasStableAppIdFor(const QString &appId, const QString &windowId)
The REOPEN CONTRACT, which the predicates below implement: a window is restored only on the KWin outp...
Definition WindowPlacement.h:515
WindowKind
Coarse structural classification of a window, carried on the open and close wire calls and on the pla...
Definition EngineTypes.h:77
@ Unknown
Definition EngineTypes.h:78
bool pendingCrossScreenManagedRestore(const WindowPlacement &p, QLatin1String engineId, QLatin1String managedState, const QString &openingScreenId, IsEngineMode &&isEngineMode)
Definition WindowPlacement.h:544
bool ownRecordLeftScreen(const WindowPlacement &own, const QString &openingScreenId)
Whether a window's OWN record names a different screen than the one it is opening on while some engin...
Definition WindowPlacement.h:607
bool samePhysical(const QString &idA, const QString &idB)
Check if two screen IDs share the same physical screen.
Definition VirtualScreenId.h:70
bool sameWindowInstance(const QString &lhs, const QString &rhs)
Do two window ids name the same live window instance?
Definition WindowId.h:97
One engine's view of a window: which managed slot it occupies (or that it is floating / unmanaged) in...
Definition WindowPlacement.h:41
QHash< int, QStringList > zonesByDesktop
Snap slot — the zones this window occupies on EACH desktop it is present on, keyed by x11 desktop num...
Definition WindowPlacement.h:63
bool isEmpty() const
Definition WindowPlacement.h:73
int order
autotile slot — tile index within the screen; -1 for snap
Definition WindowPlacement.h:44
bool operator==(const EngineSlot &o) const
Definition WindowPlacement.h:65
bool operator!=(const EngineSlot &o) const
Definition WindowPlacement.h:69
QStringList zoneIds
snap slot — zone UUIDs (first is primary); empty for autotile
Definition WindowPlacement.h:43
QString state
engine-defined token: snap "snapped"/"floating"; autotile "tiled"/"floating" ("free" retired)
Definition WindowPlacement.h:42
One window's single, authoritative placement record — the unit of the unified, engine-agnostic restor...
Definition WindowPlacement.h:96
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:143
static QLatin1String snapEngineId()
Built-in engine-slot ids.
Definition WindowPlacement.h:267
static QLatin1String stateFree()
Common state-token vocabulary.
Definition WindowPlacement.h:287
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:166
static QLatin1String autotileEngineId()
Definition WindowPlacement.h:271
static QLatin1String scrollingEngineId()
Definition WindowPlacement.h:275
WindowKind kind
Definition WindowPlacement.h:114
bool isValid() const
Definition WindowPlacement.h:136
static QLatin1String stateTiled()
Definition WindowPlacement.h:299
bool sameContentAs(const WindowPlacement &o) const
Content equality IGNORING sequence (the store stamps a fresh sequence on every record(),...
Definition WindowPlacement.h:255
static QLatin1String stateReleased()
An engine that KNOWINGLY GAVE THE WINDOW UP (a cross-mode handoff) leaves this instead of its managed...
Definition WindowPlacement.h:314
int virtualDesktop
0 = all-desktops / sticky / unknown.
Definition WindowPlacement.h:112
QString activity
empty = all-activities / unknown
Definition WindowPlacement.h:113
static QLatin1String stateFloating()
Definition WindowPlacement.h:291
QRect anyFreeGeometry() const
Any captured free/float geometry (the deterministic pick of anyFreeGeometryScreenId()),...
Definition WindowPlacement.h:212
QJsonObject toJson() const
Definition WindowPlacement.h:319
QString anyFreeGeometryScreenId() const
The screenId of the deterministic cross-screen fallback pick: the lexicographically-smallest screenId...
Definition WindowPlacement.h:197
qint64 closedAtMsecs
INERT, kept for ABI layout. Never stamped or read.
Definition WindowPlacement.h:134
static QLatin1String stateSnapped()
Definition WindowPlacement.h:295
static WindowPlacement fromJson(const QString &appId, const QJsonObject &obj)
Definition WindowPlacement.h:396
QString screenId
last managed-context screen
Definition WindowPlacement.h:102
quint64 sequence
Definition WindowPlacement.h:123
QHash< QString, EngineSlot > engines
Definition WindowPlacement.h:117
bool reclaimEligible
The cross-screen reclaim's credit, retired with the reclaim: a window is now restored only on the out...
Definition WindowPlacement.h:132
QString appId
window class; FIFO key for close/reopen (uuid changes)
Definition WindowPlacement.h:99
QHash< QString, QRect > freeGeometryByScreen
Definition WindowPlacement.h:120
QString windowId
full appId|uuid; exact key for daemon-restart (uuid stable)
Definition WindowPlacement.h:98
bool hasRestorableContent() const
Whether this record carries anything worth restoring.
Definition WindowPlacement.h:232