The dynamic-workspace lifecycle state machine. More...
#include <PhosphorWorkspaces/WorkspaceReconciler.h>
Signals | |
| void | requestCreateDesktop (uint position, const QString &name) |
| Create a desktop at a 0-based position. | |
| void | requestRemoveDesktop (const QString &desktopId) |
| void | requestSetCurrent (const QString &screenId, const QString &desktopId) |
| void | requestSetDesktopName (const QString &desktopId, const QString &name) |
| Sync a desktop's KWin name (named-workspace claim, rename, revert to KWin's positional default). | |
| void | mapChanged () |
| Map mutated (any structural or metadata change), or a settle moved the published 1-based positions. | |
| void | structuralOpsSettled () |
| hasPendingStructuralOps() just turned false: the settled list now reflects every create and remove this reconciler had in flight. | |
| void | foreignSwitchDetected (const QString &screenId, const QString &desktopId, const QString &ownerScreenId) |
| An unmatched (external) switch put screenId on a desktop owned by another screen. | |
| void | removalRaceDetected (const QString &desktopId, const QString &ownerScreenId) |
| A window populated desktopId while our removeDesktop for it was in flight (plan §4.3 destroy step 4): KWin will sweep its windows to an arbitrary neighbour when the removal lands. | |
| void | removalAbandoned (const QString &desktopId) |
| Our removeDesktop for desktopId expired unanswered, or KWin answered it without removing anything (onRemoveDesktopAnswered): the desktop is staying, so any removalRaceDetected snapshot taken for it is stale. | |
| void | namedWorkspaceMoved (const QString &namedId, const QString &name, const QString &screenId, int sliceIndex) |
| A verb moved a named workspace (reorder within its slice, or transfer to another screen). | |
| void | namedWorkspaceRenamedInKWin (const QString &namedId, const QString &desktopId, const QString &kwinName) |
| KWin carries a user-chosen name for a named workspace's desktop that differs from the declaration and is not a name we pushed: it was renamed on KWin's side (Pager, System Settings). | |
| void | capReached () |
| The desktop cap stopped a create (once per episode). | |
| void | resyncRequested () |
| A ledger entry expired; controller should re-pull authoritative state. | |
Public Member Functions | |
| WorkspaceReconciler (QObject *parent=nullptr) | |
| const WorkspaceMap & | map () const |
| quint64 | generation () const |
| bool | restoreState (const QString &json, const std::function< QString(const QString &)> &canonicalScreenId={}) |
| Load a state-file payload as the candidate map adoption reconciles. | |
| bool | isAdopted () const |
| True once adoptAll has accepted a world. | |
| int | desktopCap () const |
| KWin's desktop-count ceiling as the reconciler currently believes it. | |
| void | setDesktopCap (int cap) |
| The configured ceiling. | |
| void | setTimeouts (int ledgerTimeoutMs, int destroyDebounceMs) |
| Ledger expiry and destroy debounce, in milliseconds. | |
| int | ledgerTimeoutMs () const |
| int | destroyDebounceMs () const |
| void | setFocusedScreen (const QString &screenId) |
| Fallback for the screen that adopts externally created desktops and realizes unpinned named workspaces. | |
| void | setFocusedScreenProvider (std::function< QString()> provider) |
| Pull provider for the focused screen, asked at the moment a desktop needs a home. | |
| void | setDefaultDesktopNameProvider (std::function< QString(int)> provider) |
| KWin's default label for the desktop at a 1-based position (KWin's own defaultName(), translated in KWin's catalog). | |
| void | onDesktopListSettled (const QStringList &ids, const QStringList &rawNames={}) |
| Authoritative ordered KWin id list settled (from desktopListChanged). | |
| void | onKwinDesktopCreated (const QString &desktopId) |
| Early id-only echo of a KWin desktop creation (position and name unknown); matches the oldest open create. | |
| void | onKwinDesktopCreatedAt (const QString &desktopId, int position, const QString &name) |
| Echo of a KWin desktop creation with KWin's own position (0-based) and name, as its desktopCreated signal carries them. | |
| void | onKwinDesktopRemoved (const QString &desktopId) |
| Early id-only echo of a KWin desktop removal. | |
| void | onCreateDesktopAnswered (uint position, const QString &name, bool answered) |
| KWin's answer to one of our createDesktop calls, with the call's own arguments (VirtualDesktopManager::createDesktopAnswered). | |
| void | onRemoveDesktopAnswered (const QString &desktopId, bool answered) |
| KWin's answer to one of our removeDesktop calls. | |
| void | onKwinDesktopRenamed (const QString &desktopId, const QString &rawName) |
| KWin's raw name for a desktop changed (VirtualDesktopManager:: desktopRenamed), including the echo of a name we pushed. | |
| bool | onScreenDesktopReport (const QString &screenId, int desktop) |
| A screen's current desktop report (1-based int, effect path), resolved at once against the settled id list, which must already be the list the report's numbering refers to. | |
| void | onScreenDesktopSeeded (const QString &screenId, int desktop) |
| A screen's current desktop as seeded rather than switched to (a replug or an id rename re-reporting where the output already is). | |
| void | onPopulationChanged (const QString &desktopId, int windowCount) |
| Window population for a desktop id changed (controller-maintained). | |
| void | onScreenAdded (const QString &screenId) |
| void | onScreenRemoved (const QString &screenId) |
| void | onScreenRenamed (const QString &fromScreenId, const QString &toScreenId) |
| A screen's id changed while the output stayed connected (a bare id flipping to its connector-qualified spelling). | |
| void | onScreenOrderChanged (const QStringList &order) |
| Screen order recomputed by the controller (geometry left-to-right). | |
| bool | adoptAll (const QStringList &ids, const QHash< QString, QString > ¤tDesktopIdByScreen, const QHash< QString, QString > &preferredScreenByDesktopId={}, const QStringList &rawNames={}) |
| First-run / restart adoption (plan §4.3): distribute ids (KWin global order) over screens given each screen's current desktop id. | |
| void | applyNamedWorkspaces (const QList< NamedWorkspace > &declarations, const QStringList &kwinNames) |
| Reconcile the declared named workspaces against the map (called after adoption and on every declaration change; implemented in WorkspaceReconcilerNamed.cpp). | |
| bool | hasPendingStructuralOps () const |
| True while any structural op (create/remove) is open or echoed but not yet settled — verb execution defers until the ledger is quiet (renumbering window, plan §4.5). | |
| QString | currentDesktopIdOf (const QString &screenId) const |
| The desktop id a screen currently shows, as last reported and carried across renumbers by id; empty when unknown. | |
| QHash< QString, int > | currentIndexByScreen () const |
| Every screen's current desktop as a 1-based position in the settled list, for the state file. | |
| QString | desktopIdAtOffset (const QString &screenId, int delta) const |
| The id delta slots up (-1) / down (+1) from the screen's current desktop WITHIN ITS OWN SLICE (foreign desktops are skipped by construction); empty at the slice edge (no wrap) or when unresolved. | |
| QString | desktopIdAtOffsetFrom (const QString &screenId, const QString &fromDesktopId, int delta) const |
| Like desktopIdAtOffset, counted from fromDesktopId instead of the current desktop. | |
| QString | desktopIdAtSliceIndex (const QString &screenId, int sliceIndex) const |
| The id at 0-based position sliceIndex of the screen's slice, or empty. | |
| QString | inFlightSetCurrentTarget (const QString &screenId) const |
| The target of the screen's open per-screen switch, or empty. | |
| bool | issueSetCurrent (const QString &screenId, const QString &desktopId) |
| Issue a ledgered per-screen switch (focus verbs and snap-back). | |
| bool | issueSetCurrentReplacing (const QString &screenId, const QString &desktopId) |
| Issue a per-screen switch for a navigation verb, REPLACING an open one that was also issued through this call (a repeated next/prev before the first press echoed). | |
| bool | snapBack (const QString &screenId) |
| Owner-wins correction: return screenId to its last-shown owned desktop (fallback: its slice head). | |
| bool | reorderCurrentWorkspace (const QString &screenId, int delta) |
| Reorder the screen's CURRENT workspace within its slice by delta. | |
| QString | transferCurrentWorkspace (const QString &screenId, const QString &targetScreenId) |
| Re-own the screen's current workspace to targetScreenId, inserted before that screen's trailing empty. | |
Static Public Attributes | |
| static constexpr int | LedgerTimeoutMs = 2000 |
| static constexpr int | DestroyDebounceMs = 300 |
| static constexpr int | MaxRemovalRefusals = 3 |
| How many times a removal KWin never answered is re-armed before the desktop is left alone. | |
| static constexpr int | MaxCreateRefusals = 3 |
| How many expiry passes in which a screen's unnamed create went unanswered before that screen stops asking. | |
| static constexpr int | MaxSetCurrentRefusals = 3 |
| How many per-screen corrections went unechoed or were refused before that screen's owner-wins corrections stop. | |
| static constexpr int | DefaultDesktopCap = 25 |
| KWin's desktop ceiling (VirtualDesktopManager::maximum(), 25 in KWin 6.8). | |
| static constexpr int | CapProbeExpiries = 2 |
| How many Create expiries in one episode (the id list unchanged throughout) it takes before the ceiling is believed. | |
| static constexpr int | MaxNamePushRefusals = 3 |
| The probe concludes on its CapProbeExpiries-th expiry, and every expiry before that one has to be followed by a re-drive for there to be a next one. | |
The dynamic-workspace lifecycle state machine.
Owns the WorkspaceMap and the pending-op ledger (echo safety). All inputs are plain method calls — no D-Bus, no daemon types — so unit tests drive it with scripted sequences. Outputs are signals the controller wires to VirtualDesktopManager (KWin calls), the engines, and the state-file persistence.
Echo-safety contract: every create, remove and per-screen switch the reconciler requests is recorded in the ledger FIRST. Name pushes (requestSetDesktopName) are not ledgered: they carry no structural consequence, and their retry is bounded by their own push record instead. Incoming notifications try to match a ledger entry; matched notifications update the map but trigger no reactive policy. Unmatched notifications are external and get the full policy response. A create or remove KWin has ECHOED stays open until the settled list confirms it, so the structural window (hasPendingStructuralOps) closes only once the numbering the verbs resolve against is the new one.
Entries expire after ledgerTimeoutMs() with a resyncRequested(), which re-pulls KWin's global desktop list. That pull carries no per-output state, so an expired per-screen switch is followed up here instead: the screen is re-evaluated against the owner-wins rule, within a per-screen budget (MaxSetCurrentRefusals).
Nothing runs policy before adoptAll(): until then the map is a candidate restored from the state file, and creating, destroying or correcting against it would act on ownership nobody has reconciled yet.
|
explicit |
| bool PhosphorWorkspaces::WorkspaceReconciler::adoptAll | ( | const QStringList & | ids, |
| const QHash< QString, QString > & | currentDesktopIdByScreen, | ||
| const QHash< QString, QString > & | preferredScreenByDesktopId = {}, | ||
| const QStringList & | rawNames = {} ) |
First-run / restart adoption (plan §4.3): distribute ids (KWin global order) over screens given each screen's current desktop id.
Existing map content is kept where consistent (restore path passes a pre-loaded map), and a restored entry whose home screen is connected again goes home. Refused (false, nothing changed, still unadopted) for an empty id list or an empty screen order: KWin never has zero desktops, so either is a failed read, and adopting it would wipe the candidate map.
Each still-unowned desktop goes, in this order: to the screen showing it; to preferredScreenByDesktopId[id] when that names a screen in the order (the caller passes the screen holding most of the desktop's windows, in the map's screen id space); otherwise to the owner of the nearest preceding owned desktop in KWin order, a leading run to the first screen.
rawNames, when given, must be KWin's raw names aligned with ids (as for onDesktopListSettled). They seed the names the label refresh and an expired named create's re-apply read, and positional labels already stale at adoption are refreshed at once.
| void PhosphorWorkspaces::WorkspaceReconciler::applyNamedWorkspaces | ( | const QList< NamedWorkspace > & | declarations, |
| const QStringList & | kwinNames ) |
Reconcile the declared named workspaces against the map (called after adoption and on every declaration change; implemented in WorkspaceReconcilerNamed.cpp).
Per declaration, in row order: the entry carrying the declaration's id is kept (and renamed in place when the declared name changed); else an entry carrying the name is kept and stamped with the id; else an unnamed desktop whose KWin name matches (kwinNames is aligned with the settled id list) is claimed; else a desktop is created with the name (cap-guarded and budgeted, so a refusal logs and hints, never crashes). A realized workspace is moved to its pinned output, and explicit positions are laid out per screen in (position, row) order. Map names no declaration claimed revert to dynamic, and KWin's name for them is reset to its positional default.
kwinNames MUST be KWin's raw names (VirtualDesktopManager:: rawDesktopNames()). KWin gives every unnamed desktop a positional default label, and a label the default-name provider recognizes as one never claims anything: a workspace declared as "Desktop 3" must not claim a dynamic desktop that merely carries KWin's default.
|
signal |
The desktop cap stopped a create (once per episode).
| QString PhosphorWorkspaces::WorkspaceReconciler::currentDesktopIdOf | ( | const QString & | screenId | ) | const |
The desktop id a screen currently shows, as last reported and carried across renumbers by id; empty when unknown.
| QHash< QString, int > PhosphorWorkspaces::WorkspaceReconciler::currentIndexByScreen | ( | ) | const |
Every screen's current desktop as a 1-based position in the settled list, for the state file.
Screens with no known current are absent.
| int PhosphorWorkspaces::WorkspaceReconciler::desktopCap | ( | ) | const |
KWin's desktop-count ceiling as the reconciler currently believes it.
| QString PhosphorWorkspaces::WorkspaceReconciler::desktopIdAtOffset | ( | const QString & | screenId, |
| int | delta ) const |
The id delta slots up (-1) / down (+1) from the screen's current desktop WITHIN ITS OWN SLICE (foreign desktops are skipped by construction); empty at the slice edge (no wrap) or when unresolved.
| QString PhosphorWorkspaces::WorkspaceReconciler::desktopIdAtOffsetFrom | ( | const QString & | screenId, |
| const QString & | fromDesktopId, | ||
| int | delta ) const |
Like desktopIdAtOffset, counted from fromDesktopId instead of the current desktop.
The base a repeated next/prev chains off while an earlier press is still in flight (inFlightSetCurrentTarget).
| QString PhosphorWorkspaces::WorkspaceReconciler::desktopIdAtSliceIndex | ( | const QString & | screenId, |
| int | sliceIndex ) const |
The id at 0-based position sliceIndex of the screen's slice, or empty.
| int PhosphorWorkspaces::WorkspaceReconciler::destroyDebounceMs | ( | ) | const |
|
signal |
An unmatched (external) switch put screenId on a desktop owned by another screen.
The controller answers with snapBack.
| quint64 PhosphorWorkspaces::WorkspaceReconciler::generation | ( | ) | const |
| bool PhosphorWorkspaces::WorkspaceReconciler::hasPendingStructuralOps | ( | ) | const |
True while any structural op (create/remove) is open or echoed but not yet settled — verb execution defers until the ledger is quiet (renumbering window, plan §4.5).
structuralOpsSettled() announces the moment this turns false.
| QString PhosphorWorkspaces::WorkspaceReconciler::inFlightSetCurrentTarget | ( | const QString & | screenId | ) | const |
The target of the screen's open per-screen switch, or empty.
| bool PhosphorWorkspaces::WorkspaceReconciler::isAdopted | ( | ) | const |
True once adoptAll has accepted a world.
Policy (maintenance, the destroy sweep, owner-wins) is suspended until then.
| bool PhosphorWorkspaces::WorkspaceReconciler::issueSetCurrent | ( | const QString & | screenId, |
| const QString & | desktopId ) |
Issue a ledgered per-screen switch (focus verbs and snap-back).
Refused (returns false) when the target is not in the settled list yet, when the target is empty, and while a switch for the screen is already open — the single-correction rule that breaks re-assertion loops.
| bool PhosphorWorkspaces::WorkspaceReconciler::issueSetCurrentReplacing | ( | const QString & | screenId, |
| const QString & | desktopId ) |
Issue a per-screen switch for a navigation verb, REPLACING an open one that was also issued through this call (a repeated next/prev before the first press echoed).
An open owner-wins correction (snapBack, issueSetCurrent) is never replaced; the call is refused instead, so the loop breaker issueSetCurrent enforces stays intact.
| int PhosphorWorkspaces::WorkspaceReconciler::ledgerTimeoutMs | ( | ) | const |
| const WorkspaceMap & PhosphorWorkspaces::WorkspaceReconciler::map | ( | ) | const |
|
signal |
Map mutated (any structural or metadata change), or a settle moved the published 1-based positions.
The controller persists on it.
|
signal |
A verb moved a named workspace (reorder within its slice, or transfer to another screen).
The declaration's pin and position are the controller's to rewrite, or the next apply moves it back. namedId is empty for a declaration without an id, which name then identifies.
|
signal |
KWin carries a user-chosen name for a named workspace's desktop that differs from the declaration and is not a name we pushed: it was renamed on KWin's side (Pager, System Settings).
Emitted once per distinct KWin name; the reconciler does not push the declared name back, so adopting the rename into the declaration (same id) is the controller's call.
| void PhosphorWorkspaces::WorkspaceReconciler::onCreateDesktopAnswered | ( | uint | position, |
| const QString & | name, | ||
| bool | answered ) |
KWin's answer to one of our createDesktop calls, with the call's own arguments (VirtualDesktopManager::createDesktopAnswered).
KWin echoes a create before it returns, so answered with our create still un-echoed is a REFUSAL: KWin declines a create only at its maximum, and the ceiling is learned on the spot. answered false is a stall (an error or no reply in time): the create stays open to its deadline, since the echo can still land, and its expiry teaches the cap probe nothing.
| void PhosphorWorkspaces::WorkspaceReconciler::onDesktopListSettled | ( | const QStringList & | ids, |
| const QStringList & | rawNames = {} ) |
Authoritative ordered KWin id list settled (from desktopListChanged).
Re-homes each screen's current desktop through the id delta (a removed current desktop moves to KWin's successor), repairs the map, adopts unowned ids, then runs invariant maintenance. rawNames, when given, must be KWin's raw names aligned with ids; they let the reconciler refresh positional labels a mid-list create or remove left stale, and a names-only change is acted on even when the id list is unchanged.
| void PhosphorWorkspaces::WorkspaceReconciler::onKwinDesktopCreated | ( | const QString & | desktopId | ) |
Early id-only echo of a KWin desktop creation (position and name unknown); matches the oldest open create.
| void PhosphorWorkspaces::WorkspaceReconciler::onKwinDesktopCreatedAt | ( | const QString & | desktopId, |
| int | position, | ||
| const QString & | name ) |
Echo of a KWin desktop creation with KWin's own position (0-based) and name, as its desktopCreated signal carries them.
Every create of ours carries a name KWin keeps verbatim, so an echo with any other name is external, and the position picks among several open creates. A negative position or a null name means unknown.
| void PhosphorWorkspaces::WorkspaceReconciler::onKwinDesktopRemoved | ( | const QString & | desktopId | ) |
Early id-only echo of a KWin desktop removal.
| void PhosphorWorkspaces::WorkspaceReconciler::onKwinDesktopRenamed | ( | const QString & | desktopId, |
| const QString & | rawName ) |
KWin's raw name for a desktop changed (VirtualDesktopManager:: desktopRenamed), including the echo of a name we pushed.
A named workspace's desktop given a name a user chose is reported through namedWorkspaceRenamedInKWin; a dynamic desktop's stale positional label is refreshed.
| void PhosphorWorkspaces::WorkspaceReconciler::onPopulationChanged | ( | const QString & | desktopId, |
| int | windowCount ) |
Window population for a desktop id changed (controller-maintained).
| void PhosphorWorkspaces::WorkspaceReconciler::onRemoveDesktopAnswered | ( | const QString & | desktopId, |
| bool | answered ) |
KWin's answer to one of our removeDesktop calls.
Answered while the removal is still un-echoed is a refusal (KWin keeps its last desktop and ignores an id it does not know); unanswered is a stall.
| void PhosphorWorkspaces::WorkspaceReconciler::onScreenAdded | ( | const QString & | screenId | ) |
| bool PhosphorWorkspaces::WorkspaceReconciler::onScreenDesktopReport | ( | const QString & | screenId, |
| int | desktop ) |
A screen's current desktop report (1-based int, effect path), resolved at once against the settled id list, which must already be the list the report's numbering refers to.
A report past the end of that list is kept and resolved by the next settle. Returns true when the report was a matched echo of our own SetCurrent (the caller then skips its own reactive policy for it).
The effect answers every switch request exactly once, so a report for a screen with a SetCurrent open that names a DIFFERENT desktop is the answer that the switch did not happen: the entry is retired at once (not left to block the screen until it expires), a refused correction spends one of the screen's MaxSetCurrentRefusals like an expiry does, and the report then gets the normal owner-wins policy for what the screen shows. A user switch that replaced earlier presses first lets the answers to those presses go by.
| void PhosphorWorkspaces::WorkspaceReconciler::onScreenDesktopSeeded | ( | const QString & | screenId, |
| int | desktop ) |
A screen's current desktop as seeded rather than switched to (a replug or an id rename re-reporting where the output already is).
Recorded like a report, and the owner-wins rule applies, but it is never taken as the echo of a switch we asked for, and it never claims an external desktop for the screen.
| void PhosphorWorkspaces::WorkspaceReconciler::onScreenOrderChanged | ( | const QStringList & | order | ) |
Screen order recomputed by the controller (geometry left-to-right).
| void PhosphorWorkspaces::WorkspaceReconciler::onScreenRemoved | ( | const QString & | screenId | ) |
| void PhosphorWorkspaces::WorkspaceReconciler::onScreenRenamed | ( | const QString & | fromScreenId, |
| const QString & | toScreenId ) |
A screen's id changed while the output stayed connected (a bare id flipping to its connector-qualified spelling).
Re-keys the slice, the home stamps and every per-screen record in place. Must be called INSTEAD of a remove/add pair, which would stamp the slice displaced and then, for the last screen, drop it.
|
signal |
Our removeDesktop for desktopId expired unanswered, or KWin answered it without removing anything (onRemoveDesktopAnswered): the desktop is staying, so any removalRaceDetected snapshot taken for it is stale.
|
signal |
A window populated desktopId while our removeDesktop for it was in flight (plan §4.3 destroy step 4): KWin will sweep its windows to an arbitrary neighbour when the removal lands.
The controller snapshots the census and re-routes those windows to the owner's current workspace once the desktop is gone.
| bool PhosphorWorkspaces::WorkspaceReconciler::reorderCurrentWorkspace | ( | const QString & | screenId, |
| int | delta ) |
Reorder the screen's CURRENT workspace within its slice by delta.
The map order only: KWin's global order is not rewritten. The trailing empty never moves, and nothing moves behind it.
|
signal |
Create a desktop at a 0-based position.
name is never empty: a named workspace's name, or for a dynamic desktop the positional label KWin would give it (see setDefaultDesktopNameProvider).
|
signal |
|
signal |
|
signal |
Sync a desktop's KWin name (named-workspace claim, rename, revert to KWin's positional default).
Creates carry their name in createDesktop and never ride this.
| bool PhosphorWorkspaces::WorkspaceReconciler::restoreState | ( | const QString & | json, |
| const std::function< QString(const QString &)> & | canonicalScreenId = {} ) |
Load a state-file payload as the candidate map adoption reconciles.
Parsed before anything is replaced, so a malformed or wrong-version file returns false and changes nothing. canonicalScreenId, when given, normalizes every restored home stamp into the caller's screen id space, and a stamp that then names the entry's own owner is dropped (the entry is not displaced). Announces through mapChanged.
|
signal |
A ledger entry expired; controller should re-pull authoritative state.
| void PhosphorWorkspaces::WorkspaceReconciler::setDefaultDesktopNameProvider | ( | std::function< QString(int)> | provider | ) |
KWin's default label for the desktop at a 1-based position (KWin's own defaultName(), translated in KWin's catalog).
Pushed wherever the reconciler means "unnamed", and used to tell a generated positional label from a name a user chose. Unset, the untranslated "Desktop <n>" form VirtualDesktopManager also uses is assumed.
| void PhosphorWorkspaces::WorkspaceReconciler::setDesktopCap | ( | int | cap | ) |
The configured ceiling.
Trailing-empty appends are suspended at the cap (capReached() hints once per episode). A learned ceiling below this value self-heals back to it, never to DefaultDesktopCap. Nothing in the daemon calls this; tests use it to build a small-cap world.
| void PhosphorWorkspaces::WorkspaceReconciler::setFocusedScreen | ( | const QString & | screenId | ) |
Fallback for the screen that adopts externally created desktops and realizes unpinned named workspaces.
Consulted only when the provider below is unset or answers a screen the map does not know.
| void PhosphorWorkspaces::WorkspaceReconciler::setFocusedScreenProvider | ( | std::function< QString()> | provider | ) |
Pull provider for the focused screen, asked at the moment a desktop needs a home.
Its answer must be in the map's screen id space. The provider usually captures daemon objects, so the owner clears it (passes an empty function) before those go away.
| void PhosphorWorkspaces::WorkspaceReconciler::setTimeouts | ( | int | ledgerTimeoutMs, |
| int | destroyDebounceMs ) |
Ledger expiry and destroy debounce, in milliseconds.
Defaults are LedgerTimeoutMs and DestroyDebounceMs; tests shorten them so the time-driven paths run in a fraction of the real timeouts.
| bool PhosphorWorkspaces::WorkspaceReconciler::snapBack | ( | const QString & | screenId | ) |
Owner-wins correction: return screenId to its last-shown owned desktop (fallback: its slice head).
No-op when the screen already shows an owned desktop. Returns true when a correction was issued.
|
signal |
hasPendingStructuralOps() just turned false: the settled list now reflects every create and remove this reconciler had in flight.
Deferred verbs resume on this. Emitted from inside the settle, so a consumer that needs other subscribers of the same desktop-list change to have run first connects with Qt::QueuedConnection.
| QString PhosphorWorkspaces::WorkspaceReconciler::transferCurrentWorkspace | ( | const QString & | screenId, |
| const QString & | targetScreenId ) |
Re-own the screen's current workspace to targetScreenId, inserted before that screen's trailing empty.
Window relocation is the controller's job (§4.2); this is the map half. The source switches to the workspace that took the moved one's slot. Refused for the source's last desktop and for its trailing empty. Returns the moved desktop id (empty on failure).
|
staticconstexpr |
How many Create expiries in one episode (the id list unchanged throughout) it takes before the ceiling is believed.
KWin refuses a create past its maximum with no reply at all, and so does a stalled bus, so a single unanswered create is not evidence of a cap — see expireLedger.
|
staticconstexpr |
KWin's desktop ceiling (VirtualDesktopManager::maximum(), 25 in KWin 6.8).
Shared by the daemon's gate and the settings app's cap badge. It is the STARTING value only: a lower ceiling is learned from the compositor at runtime, from a create KWin answered without creating anything (onCreateDesktopAnswered) or from repeated unanswered creates (expireLedger), and forgotten again as soon as a create succeeds or the live count exceeds it.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
How many expiry passes in which a screen's unnamed create went unanswered before that screen stops asking.
The mirror of MaxRemovalRefusals, and for the same reason: expireLedger re-runs maintenance after a Create expiry so a transient stall retries, and without a budget a create KWin permanently refuses becomes one D-Bus call per ledger timeout for the life of the session. Named creates spend a budget of the same size kept per declaration instead. Every budget is restored when any create lands (KWin's ceiling is global, so one answered create is proof for every screen), when the desktop count drops, and when the screen or declaration goes away.
|
staticconstexpr |
The probe concludes on its CapProbeExpiries-th expiry, and every expiry before that one has to be followed by a re-drive for there to be a next one.
A screen's create budget refuses the re-drive once it is spent, so a budget smaller than the probe would end every episode unconcluded. How many times a KWin rename that never took effect is re-pushed before the desktop is left with the name it has. The mirror of MaxRemovalRefusals, for the same reason: applyNamedWorkspaces runs on every settle, so a permanently declined rename would re-fire forever. The budget is restored when KWin's names agree, when the name reverts to dynamic, and when the desktop goes away.
|
staticconstexpr |
How many times a removal KWin never answered is re-armed before the desktop is left alone.
A genuinely refused removal (KWin declining to drop that desktop) would otherwise re-arm, re-issue, expire and resync forever; after this many rounds the surplus empty desktop simply stays. The budget is restored the moment the desktop's population changes or the desktop actually goes away.
|
staticconstexpr |
How many per-screen corrections went unechoed or were refused before that screen's owner-wins corrections stop.
Each expiry or refusing answer re-evaluates the screen, so a switch the compositor cannot perform would otherwise snap back forever. Restored by any report for the screen other than a refusing answer.