7#include "phosphorengine_export.h"
75 std::optional<WindowPlacement>
take(
const QString& windowId,
const QString& appId,
101 std::optional<WindowPlacement>
154 std::optional<WindowPlacement>
takeForReopen(
const QString& engineId,
const QString& windowId,
const QString& appId,
155 const QString& screenId);
168 std::optional<WindowPlacement>
peek(
const QString& windowId,
const QString& appId,
170 bool excludeLiveSiblings =
false)
const;
176 std::optional<WindowPlacement>
peekExact(
const QString& windowId)
const
178 return peek(windowId, QString());
199 std::optional<WindowPlacement>
peekForReclaim(
const QString& windowId,
const QString& appId,
204 bool contains(
const QString& windowId,
const QString& appId = QString())
const;
247 std::optional<WindowPlacement>
claimForOpen(
const QString& windowId,
const QString& appId);
267 std::optional<WindowPlacement>
claimForOpen(
const QString& windowId,
const QString& appId,
268 const QString& openingScreenId,
284 m_liveInstanceProbe = std::move(probe);
294 return m_liveInstanceProbe && m_liveInstanceProbe(windowId);
329 bool clear(
const QString& windowId);
434 using OutputOrigin = std::function<std::optional<QPoint>(
const QString& screenId)>;
449 void evictForCapacity(QList<WindowPlacement>& bucket);
458 bool pairingAllows(
const QString& windowId,
const WindowPlacement& candidate)
const;
463 void dropClaimsNaming(
const QString& recordWindowId);
466 void forgetRemovedRecord(
const QString& recordWindowId);
478 bool boundToLiveOther(
const QString& askingWindowId,
const WindowPlacement& p)
const;
502 QHash<QString, QList<WindowPlacement>> m_byApp;
503 quint64 m_sequence = 0;
504 std::function<bool(
const QString&)> m_liveInstanceProbe;
519 QHash<QString, QString> m_openPairing;
520 QHash<QString, QString> m_claimedBy;
530 QSet<QString> m_touchedThisSession;
537 std::optional<WindowPlacement> claimForOpenImpl(
const QString& windowId,
const QString& appId,
bool ownRecordFinal,
538 const QString& openingScreenId,
How KWin's desktop positions moved in one change of its desktop list: for each 1-based position in th...
Definition DesktopRemap.h:29
void deserialize(const QJsonObject &obj, const OutputOrigin &originFor)
bool clear(const QString &windowId)
Drop any record for the same live instance (and prune the empty bucket).
bool collapsePureFloatSiblings(const QString &appId, const QString &keepWindowId)
Collapse stale pure-float duplicates for an app, keeping keepWindowId.
std::optional< WindowPlacement > claimForOpen(const QString &windowId, const QString &appId, const QString &openingScreenId, const std::function< bool(const WindowPlacement &)> &restorableHere)
The reopen-contract claim: claimForOpen restricted to what the opening screen can restore.
std::function< std::optional< QPoint >(const QString &screenId)> OutputOrigin
The top-left of the output a free-geometry key (a screen id, virtual or not) lies on,...
Definition WindowPlacementStore.h:434
int releaseOpenClaimsExcept(const QSet< QString > &aliveInstanceIds)
Drop every open claim whose instance is not in aliveInstanceIds (instance ids, as PhosphorIdentity::W...
bool forgetDesktopZones(const QString &windowId, const QString &engineId, int desktop)
Drop one desktop's entry from an engine slot's zonesByDesktop map.
int remapRestoredDesktopZones(const DesktopRemap &remap, quint64 restoredUpTo)
remapDesktopZones for the start-up renumber that KWin's first desktop list brings when it lands after...
bool markInstanceClosed(const QString &windowId, bool graceEligible=true)
The window CLOSED: drop its open claim (releaseOpenClaim).
bool releaseEngineSlot(const QString &windowId, const QString &engineId)
DOWNGRADE one engine's slot to WindowPlacement::stateReleased() on every record for the same live ins...
std::optional< WindowPlacement > claimForOpen(const QString &windowId, const QString &appId)
Reserve, once per opening window instance, the record that instance owns.
std::optional< WindowPlacement > peekForReclaim(const QString &windowId, const QString &appId, const std::function< bool(const WindowPlacement &)> &accept={}) const
Non-consuming lookup for the tiling engines' reopen claim (IPlacementEngine::claimCrossScreenReopen),...
std::optional< WindowPlacement > peekExact(const QString &windowId) const
Same-instance peek: branch 1 of peek() only, never the appId-FIFO fallback.
Definition WindowPlacementStore.h:176
static constexpr qint64 ShutdownCloseGraceMs
INERT, kept for source compatibility: the shutdown-close grace serialize() once applied to the reclai...
Definition WindowPlacementStore.h:486
std::optional< WindowPlacement > takeForReopen(const QString &engineId, const QString &windowId, const QString &appId, const QString &screenId)
Reopen resolve: the shared consumption pattern the TILING engines' open-time restores use (SnapEngine...
static constexpr int MaxPerApp
Per-app record cap (public so tests can pin the eviction contract).
Definition WindowPlacementStore.h:482
bool contains(const QString &windowId, const QString &appId=QString()) const
True if a record exists for the same live instance, or (if appId non-empty) any record in that appId ...
void markInstanceMovedLive(const QString &windowId)
INERT, kept for ABI.
QJsonObject serialize(const std::function< bool(const WindowPlacement &)> &keep, const OutputOrigin &originFor) const
The on-disk form keeps each float-back RELATIVE to its output, so a spot survives a rearrangement of ...
void setLiveInstanceProbe(std::function< bool(const QString &windowId)> probe)
Inject the live-window probe behind every live-sibling exclusion in the store (take,...
Definition WindowPlacementStore.h:282
int renumberDesktopZones(int removedDesktop)
Drop removedDesktop from every slot's zonesByDesktop map and shift the entries above it down by one,...
int transform(const std::function< bool(WindowPlacement &)> &fn)
Apply an in-place mutation to every record; fn returns true when it changed the record.
quint64 sequence() const
The stamp of the newest record.
Definition WindowPlacementStore.h:405
int removeIf(const std::function< bool(const WindowPlacement &)> &pred)
Remove every record matching pred. Returns the count removed.
static int formatVersionOf(const QJsonObject &stored)
The version stored was written in (1 when unstamped).
void releaseOpenClaim(const QString &windowId)
Drop windowId's open claim, so a claim never outlives the instance that made it.
std::optional< WindowPlacement > peek(const QString &windowId, const QString &appId, const std::function< bool(const WindowPlacement &)> &accept={}, bool excludeLiveSiblings=false) const
Non-consuming lookup (unlike take): the record for the same live instance, else the NEWEST record in ...
QList< WindowPlacement > records() const
All records, in no particular order.
static constexpr int FormatVersion
The serialized format's version, stamped as "_version".
Definition WindowPlacementStore.h:490
std::optional< WindowPlacement > take(const QString &windowId, const QString &appId, const std::function< bool(const WindowPlacement &)> &accept={}, const std::function< bool(const WindowPlacement &)> &preferred={})
Restore lookup: the first record whose accept predicate passes, trying the same-instance match before...
std::optional< WindowPlacement > peekLiveSibling(const QString &windowId, const QString &appId, const std::function< bool(const WindowPlacement &)> &accept={}) const
The EARLIEST-RECORDED record in appId's bucket that is bound to a live window OTHER than windowId's i...
bool clearFreeGeometry(const QString &windowId)
Clear ONLY the shared free/float geometry for the same live instance, leaving the engine slots and co...
QJsonObject serialize(const std::function< bool(const WindowPlacement &)> &keep={}) const
JSON shape: { "_version": FormatVersion, appId: [ record, ... ] }.
WindowPlacementStore()=default
bool isLiveInstance(const QString &windowId) const
Whether the probe reports windowId's instance as a still-open window.
Definition WindowPlacementStore.h:292
int remapDesktopZones(const DesktopRemap &remap)
Move every slot's zonesByDesktop entries and the record-level desktop through remap,...
void deserialize(const QJsonObject &obj)
bool burnReclaimCredit(const QString &windowId, const QString &appId)
INERT, kept for ABI.
bool clearFreeGeometry(const QString &windowId, const QString &screenId)
bool record(WindowPlacement placement)
Record / MERGE this window's placement.
Definition DesktopRemap.h:12
One window's single, authoritative placement record — the unit of the unified, engine-agnostic restor...
Definition WindowPlacement.h:96