Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PerScreenConfigResolver.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 <phosphortileengine_export.h>
9#include <QHash>
10#include <QString>
11#include <QVariantMap>
12#include <functional>
13#include <optional>
14
15namespace PhosphorTiles {
16class TilingAlgorithm;
17}
18
19namespace PhosphorTileEngine {
20
22
23class AutotileConfig;
24class AutotileEngine;
25
39class PHOSPHORTILEENGINE_EXPORT PerScreenConfigResolver
40{
41public:
43
44 // ═══════════════════════════════════════════════════════════════════════════
45 // Per-screen override storage
46 // ═══════════════════════════════════════════════════════════════════════════
47
57 void applyPerScreenConfig(const QString& screenId, const QVariantMap& overrides);
58
67 void clearPerScreenConfig(const QString& screenId);
68
72 QVariantMap perScreenOverrides(const QString& screenId) const;
73
77 bool hasPerScreenOverride(const QString& screenId, const QString& key) const;
78
86 void updatePerScreenOverride(const QString& screenId, const QString& key, const QVariant& value);
87
91 void removeOverridesForScreen(const QString& screenId);
92
106 using ContextGapProvider = std::function<QVariantMap(const QString& screenId)>;
108 {
109 m_contextGapProvider = std::move(provider);
110 }
111
112 // ═══════════════════════════════════════════════════════════════════════════
113 // Effective per-screen values (per-screen override → global fallback)
114 // ═══════════════════════════════════════════════════════════════════════════
115
116 int effectiveInnerGap(const QString& screenId) const;
117 int effectiveOuterGap(const QString& screenId) const;
118 ::PhosphorLayout::EdgeGaps effectiveOuterGaps(const QString& screenId) const;
119 bool effectiveSmartGaps(const QString& screenId) const;
120 bool effectiveRespectMinimumSize(const QString& screenId) const;
121 int effectiveMaxWindows(const QString& screenId) const;
122 qreal effectiveSplitRatioStep(const QString& screenId) const;
123 QString effectiveAlgorithmId(const QString& screenId) const;
124 PhosphorTiles::TilingAlgorithm* effectiveAlgorithm(const QString& screenId) const;
125
126private:
127 std::optional<QVariant> perScreenOverride(const QString& screenId, const QString& key) const;
128
131 std::optional<int> contextGap(const QString& screenId, QLatin1String key) const;
132
136 std::optional<::PhosphorLayout::EdgeGaps> contextOuterGaps(const QString& screenId) const;
137
138 AutotileEngine* m_engine = nullptr;
139 QHash<QString, QVariantMap> m_perScreenOverrides;
140 ContextGapProvider m_contextGapProvider{};
141};
142
143} // namespace PhosphorTileEngine
Core engine for automatic window tiling.
Definition AutotileEngine.h:65
Resolves per-screen configuration overrides for autotiling.
Definition PerScreenConfigResolver.h:40
bool effectiveRespectMinimumSize(const QString &screenId) const
PerScreenConfigResolver(AutotileEngine *engine)
void removeOverridesForScreen(const QString &screenId)
Remove all overrides for a screen (used during screen removal)
int effectiveMaxWindows(const QString &screenId) const
void clearPerScreenConfig(const QString &screenId)
Clear per-screen configuration overrides.
::PhosphorLayout::EdgeGaps effectiveOuterGaps(const QString &screenId) const
void applyPerScreenConfig(const QString &screenId, const QVariantMap &overrides)
Apply per-screen configuration overrides.
QString effectiveAlgorithmId(const QString &screenId) const
PhosphorTiles::TilingAlgorithm * effectiveAlgorithm(const QString &screenId) const
bool effectiveSmartGaps(const QString &screenId) const
std::function< QVariantMap(const QString &screenId)> ContextGapProvider
Inject a per-context (window-rule) gap-override provider.
Definition PerScreenConfigResolver.h:106
void setContextGapProvider(ContextGapProvider provider)
Definition PerScreenConfigResolver.h:107
QVariantMap perScreenOverrides(const QString &screenId) const
Get currently applied per-screen overrides for comparison.
qreal effectiveSplitRatioStep(const QString &screenId) const
void updatePerScreenOverride(const QString &screenId, const QString &key, const QVariant &value)
Update a single per-screen override value in-place.
bool hasPerScreenOverride(const QString &screenId, const QString &key) const
Check if a screen has a per-screen override for a specific key.
int effectiveInnerGap(const QString &screenId) const
int effectiveOuterGap(const QString &screenId) const
Abstract base class for tiling algorithms.
Definition TilingAlgorithm.h:51
Definition PerScreenKeys.h:9
Definition AutotileConfig.h:13
Definition AutotileEngine.h:46
Per-side edge gap values (resolved, non-negative pixel values)
Definition EdgeGaps.h:27