Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorTileEngine::PerScreenConfigResolver Class Reference

Resolves per-screen configuration overrides for autotiling. More...

#include <phosphor-tile-engine/include/PhosphorTileEngine/PerScreenConfigResolver.h>

Classes

struct  EffectiveGaps
 

Public Types

using ContextGapProvider = std::function< QVariantMap(const QString &screenId)>
 Inject a per-context (window-rule) gap-override provider.
 

Public Member Functions

 PerScreenConfigResolver (AutotileEngine *engine)
 
void applyPerScreenConfig (const QString &screenId, const QVariantMap &overrides)
 Apply per-screen configuration overrides.
 
void clearPerScreenConfig (const QString &screenId)
 Clear per-screen configuration overrides.
 
QVariantMap perScreenOverrides (const QString &screenId) const
 Get currently applied per-screen overrides for comparison.
 
bool hasPerScreenOverride (const QString &screenId, const QString &key) const
 Check if a screen has a per-screen override for a specific key.
 
void updatePerScreenOverride (const QString &screenId, const QString &key, const QVariant &value)
 Update a single per-screen override value in-place.
 
void removeOverridesForScreen (const QString &screenId)
 Drop a screen's in-memory overrides while REMEMBERING the algorithm they resolved to (autotile toggle-off).
 
void forgetRememberedAlgorithmsForUnknownScreens ()
 Drop remembered algorithms for screens that are no longer connected.
 
void forgetScreen (const QString &screenId)
 Drop a screen's overrides AND the remembered algorithm, for an id that will never be reused (an orphaned virtual screen).
 
void removeOverridesMatching (const std::function< bool(const QString &)> &pred)
 forgetScreen for every stored id matching pred — the whole-OUTPUT reap.
 
void applyGlobalAlgorithmChange (const QString &previousGlobalId, const QString &newGlobalId)
 Apply a GLOBAL algorithm switch to every screen that follows it.
 
void setContextGapProvider (ContextGapProvider provider)
 
int effectiveInnerGap (const QString &screenId) const
 
::PhosphorLayout::EdgeGaps effectiveOuterGaps (const QString &screenId) const
 
EffectiveGaps effectiveGaps (const QString &screenId) const
 Both gap keys from ONE context resolve.
 
bool effectiveSmartGaps (const QString &screenId) const
 
bool effectiveRespectMinimumSize (const QString &screenId) const
 
int effectiveMaxWindows (const QString &screenId) const
 
PhosphorTiles::AutotileOverflowBehavior effectiveOverflowBehavior (const QString &screenId) const
 
PhosphorTiles::AutotileInsertPosition effectiveInsertPosition (const QString &screenId) const
 
QVariantMap effectiveCustomParamsOverride (const QString &screenId) const
 The per-screen custom-parameter override map (a SetAlgorithmParam rule the daemon injected), or an empty map when none.
 
qreal effectiveSplitRatioStep (const QString &screenId) const
 
QString effectiveAlgorithmId (const QString &screenId) const
 
PhosphorTiles::TilingAlgorithmeffectiveAlgorithm (const QString &screenId) const
 

Detailed Description

Resolves per-screen configuration overrides for autotiling.

PerScreenConfigResolver manages per-screen autotile overrides (gaps, algorithm, split ratio, master count, etc.) and resolves effective values by falling back to the global AutotileConfig when no override exists.

Uses a back-pointer to AutotileEngine for access to global config, algorithm registry, and tiling state. Declared as a friend class in AutotileEngine.

See also
AutotileEngine for the owning engine
AutotileConfig for global configuration

Member Typedef Documentation

◆ ContextGapProvider

using PhosphorTileEngine::PerScreenConfigResolver::ContextGapProvider = std::function<QVariantMap(const QString& screenId)>

Inject a per-context (window-rule) gap-override provider.

Returns a QVariantMap keyed by the same PerScreenKeys gap keys this resolver already understands (InnerGap, OuterGap, OuterGap{Top,Bottom, Left,Right}, UsePerSideOuterGap) for the screen's CURRENT context (desktop / activity, resolved by the daemon closure). These take precedence over the static per-screen overrides, matching the snapping gap pipeline where a context-rule gap override is the highest-priority layer. Engine library stays settings-agnostic (LGPL boundary): the daemon adapts its LayoutRegistry::resolveContextGaps result into the map. Empty / unset → no context override (the historical behaviour).

Constructor & Destructor Documentation

◆ PerScreenConfigResolver()

PhosphorTileEngine::PerScreenConfigResolver::PerScreenConfigResolver ( AutotileEngine engine)
explicit

Member Function Documentation

◆ applyGlobalAlgorithmChange()

void PhosphorTileEngine::PerScreenConfigResolver::applyGlobalAlgorithmChange ( const QString &  previousGlobalId,
const QString &  newGlobalId 
)

Apply a GLOBAL algorithm switch to every screen that follows it.

Called by AutotileEngine::setAlgorithm with the outgoing and incoming global ids. A screen follows the global one unless it is pinned by a per-screen Algorithm override, and the pinning must be read from what the screen's states were BUILT UNDER rather than from the live override map: a toggle-off has already dropped that map, so a screen pinned by persisted settings reads there as a follower. Acting on that reading wiped the bags of screens whose effective algorithm never moved.

Only screens holding at least one live state are visited. A screen with no state anywhere keeps both its remembered id and its stashed bags, so a switch away and back hands them over intact.

This is the single entry point for "the effective algorithm moved" on a global switch; per-screen changes reach the same wipe through applyPerScreenConfig. Keeping one implementation is deliberate — two of them disagreeing about the gate is what produced the bug above.

◆ applyPerScreenConfig()

void PhosphorTileEngine::PerScreenConfigResolver::applyPerScreenConfig ( const QString &  screenId,
const QVariantMap &  overrides 
)

Apply per-screen configuration overrides.

Merges per-screen autotile settings into the PhosphorTiles::TilingState for a screen. Overrides take precedence over global config for that screen.

Parameters
screenIdScreen to configure
overridesKey-value map of autotile settings

◆ clearPerScreenConfig()

void PhosphorTileEngine::PerScreenConfigResolver::clearPerScreenConfig ( const QString &  screenId)

Clear per-screen configuration overrides.

Removes all overrides for the screen and restores global defaults on its PhosphorTiles::TilingState.

Parameters
screenIdScreen to clear overrides for

◆ effectiveAlgorithm()

PhosphorTiles::TilingAlgorithm * PhosphorTileEngine::PerScreenConfigResolver::effectiveAlgorithm ( const QString &  screenId) const

◆ effectiveAlgorithmId()

QString PhosphorTileEngine::PerScreenConfigResolver::effectiveAlgorithmId ( const QString &  screenId) const

◆ effectiveCustomParamsOverride()

QVariantMap PhosphorTileEngine::PerScreenConfigResolver::effectiveCustomParamsOverride ( const QString &  screenId) const

The per-screen custom-parameter override map (a SetAlgorithmParam rule the daemon injected), or an empty map when none.

Layered over the global per-algorithm config by the engine; the daemon has already gated it on the screen's effective algorithm.

◆ effectiveGaps()

EffectiveGaps PhosphorTileEngine::PerScreenConfigResolver::effectiveGaps ( const QString &  screenId) const

Both gap keys from ONE context resolve.

Prefer this over calling the two accessors above in sequence: each of those runs a full LayoutRegistry::resolveContextGaps through the context-gap provider, so the pair costs two resolves per screen per retile.

◆ effectiveInnerGap()

int PhosphorTileEngine::PerScreenConfigResolver::effectiveInnerGap ( const QString &  screenId) const

◆ effectiveInsertPosition()

PhosphorTiles::AutotileInsertPosition PhosphorTileEngine::PerScreenConfigResolver::effectiveInsertPosition ( const QString &  screenId) const

◆ effectiveMaxWindows()

int PhosphorTileEngine::PerScreenConfigResolver::effectiveMaxWindows ( const QString &  screenId) const

◆ effectiveOuterGaps()

::PhosphorLayout::EdgeGaps PhosphorTileEngine::PerScreenConfigResolver::effectiveOuterGaps ( const QString &  screenId) const

◆ effectiveOverflowBehavior()

PhosphorTiles::AutotileOverflowBehavior PhosphorTileEngine::PerScreenConfigResolver::effectiveOverflowBehavior ( const QString &  screenId) const

◆ effectiveRespectMinimumSize()

bool PhosphorTileEngine::PerScreenConfigResolver::effectiveRespectMinimumSize ( const QString &  screenId) const

◆ effectiveSmartGaps()

bool PhosphorTileEngine::PerScreenConfigResolver::effectiveSmartGaps ( const QString &  screenId) const

◆ effectiveSplitRatioStep()

qreal PhosphorTileEngine::PerScreenConfigResolver::effectiveSplitRatioStep ( const QString &  screenId) const

◆ forgetRememberedAlgorithmsForUnknownScreens()

void PhosphorTileEngine::PerScreenConfigResolver::forgetRememberedAlgorithmsForUnknownScreens ( )

Drop remembered algorithms for screens that are no longer connected.

The mirror of the engine's stash purge, run on the same event: these ids describe bags that have just been discarded, so keeping them would leave a stale "old" side for a screen that is never coming back. Keyed on connectedness, NOT autotile membership — a screen merely toggled out of autotile keeps its memory, which is what marks it as pinned rather than following the global algorithm.

◆ forgetScreen()

void PhosphorTileEngine::PerScreenConfigResolver::forgetScreen ( const QString &  screenId)

Drop a screen's overrides AND the remembered algorithm, for an id that will never be reused (an orphaned virtual screen).

No wipe: the caller is destroying every state of the id, so there is nothing left to protect from crossing algorithms.

◆ hasPerScreenOverride()

bool PhosphorTileEngine::PerScreenConfigResolver::hasPerScreenOverride ( const QString &  screenId,
const QString &  key 
) const

Check if a screen has a per-screen override for a specific key.

◆ perScreenOverrides()

QVariantMap PhosphorTileEngine::PerScreenConfigResolver::perScreenOverrides ( const QString &  screenId) const

Get currently applied per-screen overrides for comparison.

◆ removeOverridesForScreen()

void PhosphorTileEngine::PerScreenConfigResolver::removeOverridesForScreen ( const QString &  screenId)

Drop a screen's in-memory overrides while REMEMBERING the algorithm they resolved to (autotile toggle-off).

Unlike clearPerScreenConfig() this restores nothing on the TilingState and schedules no retile — the caller is tearing the screen down. It also does NOT wipe state bags, and that is the point: dropping the in-memory map is not a configuration change. The persisted per-screen settings survive and re-derive the same algorithm on re-enable, so a wipe here would destroy the bags of every (desktop, activity) state the teardown left alive, on a comparison that only reads as a change because this call is what caused it.

The resolved id is recorded instead, so the next genuine change compares against what the screen's states were actually built under. Use forgetScreen() for an id that is never coming back.

◆ removeOverridesMatching()

void PhosphorTileEngine::PerScreenConfigResolver::removeOverridesMatching ( const std::function< bool(const QString &)> &  pred)

forgetScreen for every stored id matching pred — the whole-OUTPUT reap.

The maps key on effective ("/vs:N") ids, so a removed physical monitor needs a predicate sweep to reach its virtual sub-screens' entries.

◆ setContextGapProvider()

void PhosphorTileEngine::PerScreenConfigResolver::setContextGapProvider ( ContextGapProvider  provider)
inline

◆ updatePerScreenOverride()

void PhosphorTileEngine::PerScreenConfigResolver::updatePerScreenOverride ( const QString &  screenId,
const QString &  key,
const QVariant &  value 
)

Update a single per-screen override value in-place.

Used by shortcut handlers to persist runtime-adjusted values (e.g. split ratio, master count) back into the stored override map so they survive settings reloads and applyPerScreenConfig round-trips.


The documentation for this class was generated from the following file: