Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
AutotileConstants.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
7#include <QLatin1String>
8#include <QMetaType>
9#include <limits>
10
27namespace PhosphorTiles {
28
36namespace AutotileDefaults {
37// Default values used by tiling primitives when no setting is supplied.
38// The application config layer surfaces these as the user-facing defaults
39// (see ConfigDefaults::autotile{SplitRatio,MasterCount,MaxWindows} in
40// src/config/configdefaults.h, which delegate here).
41constexpr qreal DefaultSplitRatio = 0.5;
42constexpr int DefaultMasterCount = 1;
43constexpr int DefaultMaxWindows = 5;
48constexpr int ScriptedDefaultMaxWindows = 6;
49inline constexpr QLatin1String DefaultAlgorithmId{"bsp"};
50constexpr qreal DefaultSplitRatioStep = 0.05;
51constexpr qreal MinSplitRatioStep = 0.01;
52constexpr qreal MaxSplitRatioStep = 0.25;
53
54constexpr qreal MinSplitRatio = 0.1;
55constexpr qreal MaxSplitRatio = 0.9;
56constexpr int MinMasterCount = 1;
57constexpr int MaxMasterCount = 5;
58constexpr int DefaultInnerGap = 8;
59constexpr int DefaultOuterGap = 8;
60constexpr int MinGap = 0;
61constexpr int MaxGap = 50;
62constexpr int MinRectSizePx = 50;
63constexpr int GapEdgeThresholdPx = 5;
69constexpr int ResizeEdgeMoveThresholdPx = 5;
70constexpr int MinMaxWindows = 1;
71constexpr int MaxMaxWindows = 12;
72// Sentinel returned by PerScreenConfigResolver::effectiveMaxWindows() when the
73// user has selected AutotileOverflowBehavior::Unlimited. INT_MAX/2 — not
74// INT_MAX — so any caller that does `effectiveMaxWindows(...) + 1` (e.g.
75// growth-headroom calculations) can't overflow.
76constexpr int UnlimitedMaxWindowsSentinel = std::numeric_limits<int>::max() / 2;
77constexpr int MaxZones = 256;
78constexpr int MaxRuntimeTreeDepth = 50;
79// Bounds for the opaque per-algorithm script-state bag (TilingState::scriptState).
80// Enforced by TilingState::sanitizeScriptState at every script write-back, so a
81// buggy or hostile algorithm can't bloat the bag or stall the code that walks it.
82// A whole bag exceeding the byte cap is dropped (reset to empty). The bag is
83// within-session only — nothing writes it to disk — so this is the sole boundary.
84constexpr int ScriptStateMaxBytes = 64 * 1024;
85constexpr int ScriptStateMaxDepth = 16;
86constexpr int ScriptStateMaxKeys = 4096;
87constexpr qreal SplitRatioHysteresis = 0.05;
88constexpr int MinMetadataWindows = 1;
89constexpr int MaxMetadataWindows = 100;
94constexpr qint64 MaxScriptSizeBytes = 1024 * 1024;
99inline constexpr QLatin1String ScriptIdPrefix{"script:"};
100constexpr int MinInsertPosition = 0;
101constexpr int MaxInsertPosition = 2;
102// Bounds for AutotileOverflowBehavior (Float=0 .. Unlimited=1), defined below.
103// Kept in lockstep with that enum so a per-screen override clamp has a named
104// range like MinInsertPosition/MaxInsertPosition rather than a bare literal.
105constexpr int MinOverflowBehavior = 0;
106constexpr int MaxOverflowBehavior = 1;
107// Animation duration + stagger limits previously lived here for
108// historical reasons but are NOT autotile-specific — they bound every
109// animation in the system. Moved to
110// libs/phosphor-animation/include/PhosphorAnimation/AnimationLimits.h
111// (PhosphorAnimation::Limits namespace). Consumers that need them
112// should include that header directly; ConfigDefaults already does.
117constexpr int ScriptWatchdogTimeoutMs = 100;
118
123constexpr bool isNumericMetaType(int typeId)
124{
125 return typeId == QMetaType::Double || typeId == QMetaType::Float || typeId == QMetaType::Int
126 || typeId == QMetaType::UInt || typeId == QMetaType::LongLong || typeId == QMetaType::ULongLong;
127}
128} // namespace AutotileDefaults
129
137namespace AutotileJsonKeys {
138// Per-algorithm layout keys
139inline constexpr QLatin1String MasterCount{"masterCount"};
140inline constexpr QLatin1String SplitRatio{"splitRatio"};
141inline constexpr QLatin1String SplitRatioStep{"splitRatioStep"};
142inline constexpr QLatin1String CustomParams{"customParams"};
143
144// AutotileConfig keys
145inline constexpr QLatin1String PerAlgorithmSettings{"perAlgorithmSettings"};
146inline constexpr QLatin1String AlgorithmId{"algorithmId"};
147inline constexpr QLatin1String InnerGap{"innerGap"};
148inline constexpr QLatin1String OuterGap{"outerGap"};
149
150// Per-side outer-gap keys — canonical definition in phosphor-layout-api's
151// GapKeys.h (shared with phosphor-zones ZoneJsonKeys). Re-exported here so
152// AutotileJsonKeys callers can keep their fully-qualified references
153// unchanged while both libraries consume a single source of truth.
159
160inline constexpr QLatin1String SmartGaps{"smartGaps"};
161inline constexpr QLatin1String FocusNewWindows{"focusNewWindows"};
162inline constexpr QLatin1String FocusFollowsMouse{"focusFollowsMouse"};
163inline constexpr QLatin1String InsertPosition{"insertPosition"};
164inline constexpr QLatin1String RespectMinimumSize{"respectMinimumSize"};
165inline constexpr QLatin1String MaxWindows{"maxWindows"};
166inline constexpr QLatin1String OverflowBehavior{"overflowBehavior"};
167} // namespace AutotileJsonKeys
168
176namespace AutotileJsonValues {
177// OverflowBehavior values
178inline constexpr QLatin1String OverflowFloat{"float"};
179inline constexpr QLatin1String OverflowUnlimited{"unlimited"};
180// InsertPosition values
181inline constexpr QLatin1String InsertEnd{"end"};
182inline constexpr QLatin1String InsertAfterFocused{"afterFocused"};
183inline constexpr QLatin1String InsertAsMaster{"asMaster"};
184} // namespace AutotileJsonValues
185
187 Float = 0,
188 Unlimited = 1
189};
190
192 End = 0,
193 AfterFocused = 1,
194 AsMaster = 2
195};
196
198 Float = 0,
199 Reorder = 1
200};
201
202} // namespace PhosphorTiles
constexpr QLatin1String OuterGapLeft
Definition GapKeys.h:22
constexpr QLatin1String UsePerSideOuterGap
Definition GapKeys.h:19
constexpr QLatin1String OuterGapBottom
Definition GapKeys.h:21
constexpr QLatin1String OuterGapRight
Definition GapKeys.h:23
constexpr QLatin1String OuterGapTop
Definition GapKeys.h:20
constexpr qreal MaxSplitRatio
Definition AutotileConstants.h:55
constexpr int DefaultMasterCount
Single master window.
Definition AutotileConstants.h:42
constexpr int DefaultInnerGap
Definition AutotileConstants.h:58
constexpr int MaxOverflowBehavior
Definition AutotileConstants.h:106
constexpr int DefaultOuterGap
Definition AutotileConstants.h:59
constexpr int ScriptedDefaultMaxWindows
Window cap for a scripted algorithm whose metadata omits defaultMaxWindows.
Definition AutotileConstants.h:48
constexpr bool isNumericMetaType(int typeId)
Returns true if typeId is a numeric QMetaType (Double, Float, Int, UInt, LongLong,...
Definition AutotileConstants.h:123
constexpr int MaxMaxWindows
Definition AutotileConstants.h:71
constexpr int MinInsertPosition
Definition AutotileConstants.h:100
constexpr QLatin1String DefaultAlgorithmId
Default tiling algorithm.
Definition AutotileConstants.h:49
constexpr int ScriptStateMaxBytes
Max compact-JSON size of the bag.
Definition AutotileConstants.h:84
constexpr int MaxMasterCount
Definition AutotileConstants.h:57
constexpr int MinRectSizePx
Definition AutotileConstants.h:62
constexpr int MaxZones
Definition AutotileConstants.h:77
constexpr int MinMaxWindows
Definition AutotileConstants.h:70
constexpr int UnlimitedMaxWindowsSentinel
Definition AutotileConstants.h:76
constexpr int MinOverflowBehavior
Definition AutotileConstants.h:105
constexpr qreal DefaultSplitRatio
50/50 split when nothing else specified
Definition AutotileConstants.h:41
constexpr qint64 MaxScriptSizeBytes
Largest algorithm script the engine will load.
Definition AutotileConstants.h:94
constexpr int GapEdgeThresholdPx
Definition AutotileConstants.h:63
constexpr QLatin1String ScriptIdPrefix
Prefix of the id a scripted algorithm gets when its metadata declares none: this plus the file's base...
Definition AutotileConstants.h:99
constexpr int MinGap
Definition AutotileConstants.h:60
constexpr int ScriptWatchdogTimeoutMs
Watchdog deadline for a single Luau call (tile / lifecycle hook) issued via LuauEngine::callModule.
Definition AutotileConstants.h:117
constexpr int MaxInsertPosition
Definition AutotileConstants.h:101
constexpr int DefaultMaxWindows
Maximum tiled windows before overflow.
Definition AutotileConstants.h:43
constexpr int MaxMetadataWindows
Definition AutotileConstants.h:89
constexpr int ScriptStateMaxKeys
Max total object keys across the bag.
Definition AutotileConstants.h:86
constexpr int MinMetadataWindows
Definition AutotileConstants.h:88
constexpr qreal MaxSplitRatioStep
Definition AutotileConstants.h:52
constexpr qreal MinSplitRatio
Definition AutotileConstants.h:54
constexpr int ScriptStateMaxDepth
Max object/array nesting depth.
Definition AutotileConstants.h:85
constexpr int ResizeEdgeMoveThresholdPx
Minimum pixel movement of a window edge during an interactive resize before it is treated as an inten...
Definition AutotileConstants.h:69
constexpr qreal SplitRatioHysteresis
Band within which algorithm-switch ratio reset is suppressed.
Definition AutotileConstants.h:87
constexpr int MaxRuntimeTreeDepth
Maximum recursion depth for split tree operations.
Definition AutotileConstants.h:78
constexpr qreal DefaultSplitRatioStep
Definition AutotileConstants.h:50
constexpr qreal MinSplitRatioStep
Definition AutotileConstants.h:51
constexpr int MaxGap
Definition AutotileConstants.h:61
constexpr int MinMasterCount
Definition AutotileConstants.h:56
constexpr QLatin1String FocusFollowsMouse
Definition AutotileConstants.h:162
constexpr QLatin1String OuterGap
Definition AutotileConstants.h:148
constexpr QLatin1String InsertPosition
Definition AutotileConstants.h:163
constexpr QLatin1String PerAlgorithmSettings
Definition AutotileConstants.h:145
constexpr QLatin1String SplitRatioStep
Definition AutotileConstants.h:141
constexpr QLatin1String MaxWindows
Definition AutotileConstants.h:165
constexpr QLatin1String SplitRatio
Definition AutotileConstants.h:140
constexpr QLatin1String OverflowBehavior
Definition AutotileConstants.h:166
constexpr QLatin1String SmartGaps
< canonical: PhosphorLayoutApi/GapKeys.h
Definition AutotileConstants.h:160
constexpr QLatin1String CustomParams
Definition AutotileConstants.h:142
constexpr QLatin1String InnerGap
Definition AutotileConstants.h:147
constexpr QLatin1String AlgorithmId
Definition AutotileConstants.h:146
constexpr QLatin1String MasterCount
Definition AutotileConstants.h:139
constexpr QLatin1String RespectMinimumSize
Definition AutotileConstants.h:164
constexpr QLatin1String FocusNewWindows
Definition AutotileConstants.h:161
constexpr QLatin1String OverflowFloat
Definition AutotileConstants.h:178
constexpr QLatin1String InsertAsMaster
Definition AutotileConstants.h:183
constexpr QLatin1String InsertAfterFocused
Definition AutotileConstants.h:182
constexpr QLatin1String InsertEnd
Definition AutotileConstants.h:181
constexpr QLatin1String OverflowUnlimited
Definition AutotileConstants.h:179
Definition AutotileEngine.h:59
AutotileDragBehavior
Definition AutotileConstants.h:197
AutotileInsertPosition
Definition AutotileConstants.h:191
AutotileOverflowBehavior
Definition AutotileConstants.h:186