Default IContextResolver implementation backed by three adapter pointers. More...
#include <PhosphorContext/ContextResolver.h>
Public Member Functions | |
| ContextResolver (IWorkspaceState *workspaceState, IModeProvider *modeProvider, IContextGateSource *gateSource) | |
| Bind the resolver to its three adapter inputs. | |
| ~ContextResolver () override=default | |
| ContextHandle | handleFor (const QString &screenId) const override |
Build a frozen handle targeting screenId. | |
| ContextHandle | globalHandle () const override |
| Build a handle without a screen scope. | |
| ContextHandle | handleForMode (const QString &screenId, PhosphorZones::AssignmentEntry::Mode mode) const override |
| Build a handle that overrides the mode resolution. | |
| ContextHandle | handleForPersisted (const QString &screenId, int virtualDesktop, const QString &activity) const override |
| Build a handle for a PERSISTED context (not "right now"). | |
| int | currentVirtualDesktop () const override |
| Live read of the workspace's current virtual desktop, equivalent to calling the bound IWorkspaceState::currentVirtualDesktop. | |
| QString | currentActivity () const override |
| Live read of the workspace's current activity, equivalent to calling the bound IWorkspaceState::currentActivity. | |
| DisabledReason | disabledReason (const ContextHandle &handle) const override |
| The disable cascade — Monitor → Desktop → Activity, in priority order. | |
| bool | isLocked (const ContextHandle &handle) const override |
| The per-context lock check. | |
| Public Member Functions inherited from PhosphorContext::IContextResolver | |
| virtual | ~IContextResolver ()=default |
| bool | isDisabled (const ContextHandle &handle) const |
| Truthy convenience over disabledReason. | |
| bool | isGated (const ContextHandle &handle) const |
| Composite convenience that ORs the disable and lock legs. | |
Default IContextResolver implementation backed by three adapter pointers.
Holds non-owning raw pointers to one of each input interface and routes every public call into the right combination of them. No state of its own — every snapshot is computed fresh from the bound adapters at the moment handleFor() is called. This is the only concrete resolver the project ships; tests subclass it (or implement IContextResolver directly with their own fakes) when they need to inject behaviour the adapter shims do not surface.
The three adapter pointers are all non-null preconditions of the constructor. Passing nullptr is an assertion failure in debug builds and a documented crash in release builds — the resolver has no useful behaviour without all three axes.
| PhosphorContext::ContextResolver::ContextResolver | ( | IWorkspaceState * | workspaceState, |
| IModeProvider * | modeProvider, | ||
| IContextGateSource * | gateSource ) |
Bind the resolver to its three adapter inputs.
The adapters must outlive the resolver. Recommended wiring is for Daemon to own the resolver as a std::unique_ptr data-member and construct it after the routers/managers it depends on, then tear it down in ~Daemon() before any of them.
|
overridedefault |
|
overridevirtual |
Live read of the workspace's current activity, equivalent to calling the bound IWorkspaceState::currentActivity.
Implements PhosphorContext::IContextResolver.
|
overridevirtual |
Live read of the workspace's current virtual desktop, equivalent to calling the bound IWorkspaceState::currentVirtualDesktop.
Implements PhosphorContext::IContextResolver.
|
overridevirtual |
The disable cascade — Monitor → Desktop → Activity, in priority order.
Returns the highest-priority reason the context is disabled, or DisabledReason::NotDisabled when every leg passes. The Mode axis is taken from handle (no separate argument); callers that need to probe a mode different from the snapshot must build a second handle via handleForMode.
Implements PhosphorContext::IContextResolver.
|
overridevirtual |
Build a handle without a screen scope.
Returns a handle whose screenId is empty. The mode field is resolved via IModeProvider::modeFor(QString()) — per IModeProvider's documented empty-screen contract, that returns the bound provider's default mode (today Snapping for the daemon's ScreenModeRouter adapter, but other providers may override). Callers reading the handle's mode must NOT assume Snapping; query the field directly.
Intended for adaptors that want to gate-check on (desktop, activity) only. Currently no production caller exercises this path — every consumer in the daemon and the D-Bus adaptors has a concrete screen at the call site and uses handleFor(screenId). Kept on the interface for the documented future use-case and to pin the empty-screen mode-provider contract under test (globalHandleHasNoScreenButSnapshotsWorkspace).
Implements PhosphorContext::IContextResolver.
|
overridevirtual |
Build a frozen handle targeting screenId.
Resolves the bound mode provider exactly once for screenId and captures the current virtual desktop + activity. The returned handle is safe to pass into every gate / value query on this resolver and to retain across a single event-loop tick — long enough for a drag-drop handler to commit, short enough that the user cannot virtual-desktop-switch underneath it.
Empty screenId is permitted (the resulting handle has empty screenId and mode falls back to the documented default per IModeProvider's contract). Consumers that rely on a non-empty screenId should validate before constructing the handle.
Implements PhosphorContext::IContextResolver.
|
overridevirtual |
Build a handle that overrides the mode resolution.
Specialised entry point for handlers that already know which mode they want to query (e.g. HANDLE_AUTOTILE_ONLY-class shortcut handlers that only fire in autotile mode). Skips the mode provider and stamps mode directly. Use sparingly — preferring handleFor(screenId) keeps the mode dispatch in one place.
Implements PhosphorContext::IContextResolver.
|
overridevirtual |
Build a handle for a PERSISTED context (not "right now").
Specialised for (WindowTrackingAdaptor::isPersistedContextDisabled)-style checks where the desktop/activity come from a persisted entry on disk, not the live workspace state. The screen's mode is still resolved through the mode provider — the disable-list mode axis keys on the screen's CURRENT routing, not its routing at persist time. Use only for persisted lookups; handleFor(screenId) remains the right call for live handlers.
Implements PhosphorContext::IContextResolver.
|
overridevirtual |
The per-context lock check.
Wraps ISettings::isContextLocked with the Mode → lock-key composition the adapter performs internally. Consumers that previously called Utils::contextLockKey(static_cast<int>(mode), screenId) and fed the result into isContextLocked now go through this method directly with a typed handle.
Implements PhosphorContext::IContextResolver.