Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
IContextResolver.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include "ContextHandle.h"
7#include "DisabledReason.h"
8#include "phosphorcontextresolver_export.h"
9
10#include <QString>
11
12namespace PhosphorContext {
13
78class PHOSPHORCONTEXTRESOLVER_EXPORT IContextResolver
79{
80public:
81 virtual ~IContextResolver() = default;
82
83 // ── Snapshot construction ───────────────────────────────────────────
84
100 virtual ContextHandle handleFor(const QString& screenId) const = 0;
101
120 virtual ContextHandle globalHandle() const = 0;
121
131 virtual ContextHandle handleForMode(const QString& screenId, PhosphorZones::AssignmentEntry::Mode mode) const = 0;
132
144 virtual ContextHandle handleForPersisted(const QString& screenId, int virtualDesktop,
145 const QString& activity) const = 0;
146
147 // ── Raw workspace-axis readers ─────────────────────────────────────
148 //
149 // These re-cross the bound `IWorkspaceState` on every call — they are
150 // NOT cached snapshots of an earlier `handleFor()` result. Use the
151 // matching field on a `ContextHandle` if consistency with a prior
152 // snapshot is required (e.g. when composing a (screenId, desktop,
153 // activity) tuple that must agree byte-for-byte with the disabled-
154 // context check the same tick made).
155 //
156 // No production caller currently uses these — consumers that need a
157 // live workspace value call `m_layoutManager->currentVirtualDesktop()`
158 // / `m_activityManager->currentActivity()` directly. Kept on the
159 // interface to expose the snapshot-vs-live distinction in the API
160 // surface (so a future consumer doesn't reach into `IWorkspaceState`
161 // and bypass the snapshot semantics by accident) and to support
162 // testing of the raw-read path (`rawWorkspaceAccessorsMatchSnapshot`).
163
166 virtual int currentVirtualDesktop() const = 0;
167
170 virtual QString currentActivity() const = 0;
171
172 // ── Gate queries (the cascade collapse) ────────────────────────────
173
184 virtual DisabledReason disabledReason(const ContextHandle& handle) const = 0;
185
188 bool isDisabled(const ContextHandle& handle) const
189 {
191 }
192
202 virtual bool isLocked(const ContextHandle& handle) const = 0;
203
218 bool isGated(const ContextHandle& handle) const
219 {
220 return isDisabled(handle) || isLocked(handle);
221 }
222};
223
224} // namespace PhosphorContext
The single resolver façade every Phosphor consumer goes through for "what does this screen look like ...
Definition IContextResolver.h:79
virtual bool isLocked(const ContextHandle &handle) const =0
The per-context lock check.
bool isDisabled(const ContextHandle &handle) const
Truthy convenience over disabledReason.
Definition IContextResolver.h:188
virtual ContextHandle handleForPersisted(const QString &screenId, int virtualDesktop, const QString &activity) const =0
Build a handle for a PERSISTED context (not "right now").
virtual ContextHandle handleForMode(const QString &screenId, PhosphorZones::AssignmentEntry::Mode mode) const =0
Build a handle that overrides the mode resolution.
virtual ~IContextResolver()=default
virtual ContextHandle handleFor(const QString &screenId) const =0
Build a frozen handle targeting screenId.
bool isGated(const ContextHandle &handle) const
Composite convenience that ORs the disable and lock legs.
Definition IContextResolver.h:218
virtual QString currentActivity() const =0
Live read of the workspace's current activity, equivalent to calling the bound IWorkspaceState::curre...
virtual ContextHandle globalHandle() const =0
Build a handle without a screen scope.
virtual DisabledReason disabledReason(const ContextHandle &handle) const =0
The disable cascade — Monitor → Desktop → Activity, in priority order.
virtual int currentVirtualDesktop() const =0
Live read of the workspace's current virtual desktop, equivalent to calling the bound IWorkspaceState...
Definition ContextHandle.h:10
DisabledReason
Why a context is considered disabled, in priority order.
Definition DisabledReason.h:20
@ NotDisabled
Definition DisabledReason.h:21
Frozen snapshot of "where am I right now?" for a single resolver query.
Definition ContextHandle.h:46
Mode
Per-context engine selection.
Definition AssignmentEntry.h:213