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
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// plasmazones/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 = 200;
68constexpr int MinRectSizePx = 50;
69constexpr int GapEdgeThresholdPx = 5;
75constexpr int ResizeEdgeMoveThresholdPx = 5;
76constexpr int MinMaxWindows = 1;
82constexpr int MaxMaxWindows = 12;
83// Sentinel returned by PerScreenConfigResolver::effectiveMaxWindows() when the
84// user has selected AutotileOverflowBehavior::Unlimited. INT_MAX/2 — not
85// INT_MAX — so any caller that does `effectiveMaxWindows(...) + 1` (e.g.
86// growth-headroom calculations) can't overflow.
87constexpr int UnlimitedMaxWindowsSentinel = std::numeric_limits<int>::max() / 2;
93constexpr int MaxZones = 256;
94constexpr int MaxRuntimeTreeDepth = 50;
95// Bounds for the opaque per-algorithm script-state bag (TilingState::scriptState).
96// Enforced by TilingState::sanitizeScriptState at every script write-back, so a
97// buggy or hostile algorithm can't bloat the bag or stall the code that walks it.
98// A whole bag exceeding the byte cap is dropped (reset to empty). The bag is
99// within-session only — nothing writes it to disk — so this is the sole boundary.
100constexpr int ScriptStateMaxBytes = 64 * 1024;
101constexpr int ScriptStateMaxDepth = 16;
102constexpr int ScriptStateMaxKeys = 4096;
103constexpr qreal SplitRatioHysteresis = 0.05;
104constexpr int MinMetadataWindows = 1;
105constexpr int MaxMetadataWindows = 100;
110constexpr qint64 MaxScriptSizeBytes = 1024 * 1024;
115inline constexpr QLatin1String ScriptIdPrefix{"script:"};
116constexpr int MinInsertPosition = 0;
117constexpr int MaxInsertPosition = 2;
118// Bounds for AutotileOverflowBehavior (Float=0 .. Unlimited=1), defined below.
119// Kept in lockstep with that enum so a per-screen override clamp has a named
120// range like MinInsertPosition/MaxInsertPosition rather than a bare literal.
121constexpr int MinOverflowBehavior = 0;
122constexpr int MaxOverflowBehavior = 1;
123// Animation duration + stagger limits previously lived here for
124// historical reasons but are NOT autotile-specific — they bound every
125// animation in the system. Moved to
126// libs/phosphor-animation/include/PhosphorAnimation/AnimationLimits.h
127// (PhosphorAnimation::Limits namespace). Consumers that need them
128// should include that header directly; ConfigDefaults already does.
133constexpr int ScriptWatchdogTimeoutMs = 100;
134
139constexpr bool isNumericMetaType(int typeId)
140{
141 return typeId == QMetaType::Double || typeId == QMetaType::Float || typeId == QMetaType::Int
142 || typeId == QMetaType::UInt || typeId == QMetaType::LongLong || typeId == QMetaType::ULongLong;
143}
144} // namespace AutotileDefaults
145
154// Per-algorithm layout keys
155inline constexpr QLatin1String MasterCount{"masterCount"};
156inline constexpr QLatin1String SplitRatio{"splitRatio"};
157inline constexpr QLatin1String SplitRatioStep{"splitRatioStep"};
158inline constexpr QLatin1String CustomParams{"customParams"};
159
160// AutotileConfig keys
161inline constexpr QLatin1String PerAlgorithmSettings{"perAlgorithmSettings"};
162inline constexpr QLatin1String AlgorithmId{"algorithmId"};
163inline constexpr QLatin1String InnerGap{"innerGap"};
164inline constexpr QLatin1String OuterGap{"outerGap"};
165
166// Per-side outer-gap keys — canonical definition in phosphor-layout-api's
167// GapKeys.h (shared with phosphor-zones ZoneJsonKeys). Re-exported here so
168// AutotileJsonKeys callers can keep their fully-qualified references
169// unchanged while both libraries consume a single source of truth.
175
176inline constexpr QLatin1String SmartGaps{"smartGaps"};
177inline constexpr QLatin1String FocusNewWindows{"focusNewWindows"};
178inline constexpr QLatin1String FocusFollowsMouse{"focusFollowsMouse"};
179inline constexpr QLatin1String InsertPosition{"insertPosition"};
180inline constexpr QLatin1String RespectMinimumSize{"respectMinimumSize"};
181inline constexpr QLatin1String MaxWindows{"maxWindows"};
182inline constexpr QLatin1String OverflowBehavior{"overflowBehavior"};
183} // namespace AutotileJsonKeys
184
193// OverflowBehavior values
194inline constexpr QLatin1String OverflowFloat{"float"};
195inline constexpr QLatin1String OverflowUnlimited{"unlimited"};
196// InsertPosition values
197inline constexpr QLatin1String InsertEnd{"end"};
198inline constexpr QLatin1String InsertAfterFocused{"afterFocused"};
199inline constexpr QLatin1String InsertAsMaster{"asMaster"};
200} // namespace AutotileJsonValues
201
206
212
214 Float = 0,
216};
217
218} // 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
Auto-tiling algorithm defaults.
Definition AutotileConstants.h:36
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:122
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:139
constexpr int MaxMaxWindows
Bounds the CONFIG-sourced window cap (the settings spin box, the per-screen override,...
Definition AutotileConstants.h:82
constexpr int MinInsertPosition
Definition AutotileConstants.h:116
constexpr QLatin1String DefaultAlgorithmId
Default tiling algorithm.
Definition AutotileConstants.h:49
constexpr int ScriptStateMaxBytes
Max compact-JSON size of the bag.
Definition AutotileConstants.h:100
constexpr int MaxMasterCount
Definition AutotileConstants.h:57
constexpr int MinRectSizePx
Smallest rect the tiling primitives will emit on either axis.
Definition AutotileConstants.h:68
constexpr int MaxZones
Ceiling on zones in one LAYOUT.
Definition AutotileConstants.h:93
constexpr int MinMaxWindows
Definition AutotileConstants.h:76
constexpr int UnlimitedMaxWindowsSentinel
Definition AutotileConstants.h:87
constexpr int MinOverflowBehavior
Definition AutotileConstants.h:121
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:110
constexpr int GapEdgeThresholdPx
Definition AutotileConstants.h:69
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:115
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:133
constexpr int MaxInsertPosition
Definition AutotileConstants.h:117
constexpr int DefaultMaxWindows
Maximum tiled windows before overflow.
Definition AutotileConstants.h:43
constexpr int MaxMetadataWindows
Definition AutotileConstants.h:105
constexpr int ScriptStateMaxKeys
Max total object keys across the bag.
Definition AutotileConstants.h:102
constexpr int MinMetadataWindows
Definition AutotileConstants.h:104
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:101
constexpr int ResizeEdgeMoveThresholdPx
Minimum pixel movement of a window edge during an interactive resize before it is treated as an inten...
Definition AutotileConstants.h:75
constexpr qreal SplitRatioHysteresis
Band within which algorithm-switch ratio reset is suppressed.
Definition AutotileConstants.h:103
constexpr int MaxRuntimeTreeDepth
Maximum recursion depth for split tree operations.
Definition AutotileConstants.h:94
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
JSON keys for autotile CONFIG serialization.
Definition AutotileConstants.h:153
constexpr QLatin1String FocusFollowsMouse
Definition AutotileConstants.h:178
constexpr QLatin1String OuterGap
Definition AutotileConstants.h:164
constexpr QLatin1String InsertPosition
Definition AutotileConstants.h:179
constexpr QLatin1String PerAlgorithmSettings
Definition AutotileConstants.h:161
constexpr QLatin1String SplitRatioStep
Definition AutotileConstants.h:157
constexpr QLatin1String MaxWindows
Definition AutotileConstants.h:181
constexpr QLatin1String SplitRatio
Definition AutotileConstants.h:156
constexpr QLatin1String OverflowBehavior
Definition AutotileConstants.h:182
constexpr QLatin1String SmartGaps
< canonical: PhosphorLayoutApi/GapKeys.h
Definition AutotileConstants.h:176
constexpr QLatin1String CustomParams
Definition AutotileConstants.h:158
constexpr QLatin1String InnerGap
Definition AutotileConstants.h:163
constexpr QLatin1String AlgorithmId
Definition AutotileConstants.h:162
constexpr QLatin1String MasterCount
Definition AutotileConstants.h:155
constexpr QLatin1String RespectMinimumSize
Definition AutotileConstants.h:180
constexpr QLatin1String FocusNewWindows
Definition AutotileConstants.h:177
JSON value strings (enum-ish discriminants) paired with the keys above.
Definition AutotileConstants.h:192
constexpr QLatin1String OverflowFloat
Definition AutotileConstants.h:194
constexpr QLatin1String InsertAsMaster
Definition AutotileConstants.h:199
constexpr QLatin1String InsertAfterFocused
Definition AutotileConstants.h:198
constexpr QLatin1String InsertEnd
Definition AutotileConstants.h:197
constexpr QLatin1String OverflowUnlimited
Definition AutotileConstants.h:195
Definition AutotileEngine.h:52
AutotileDragBehavior
Definition AutotileConstants.h:213
@ Reorder
Definition AutotileConstants.h:215
AutotileInsertPosition
Definition AutotileConstants.h:207
@ AfterFocused
Definition AutotileConstants.h:209
@ End
Definition AutotileConstants.h:208
@ AsMaster
Definition AutotileConstants.h:210
AutotileOverflowBehavior
Definition AutotileConstants.h:202
@ Float
Definition AutotileConstants.h:203
@ Unlimited
Definition AutotileConstants.h:204