|
| | TilingAlgorithm (QObject *parent=nullptr) |
| |
| | ~TilingAlgorithm () override=default |
| |
| | TilingAlgorithm (const TilingAlgorithm &)=delete |
| |
| TilingAlgorithm & | operator= (const TilingAlgorithm &)=delete |
| |
| void | setAppIdResolver (std::function< QString(const QString &)> resolver) |
| | Inject a resolver that maps an opaque instance id to its live app class.
|
| |
| std::function< QString(const QString &)> | appIdResolver () const |
| | Access the current resolver.
|
| |
| QString | registryId () const |
| | The id this algorithm is registered under.
|
| |
| void | setRegistryId (const QString &id) |
| | Registry-internal setter.
|
| |
| virtual QString | name () const =0 |
| | Human-readable name of the algorithm.
|
| |
| virtual QString | description () const =0 |
| | Description of the algorithm behavior.
|
| |
| virtual QVector< QRect > | calculateZones (const TilingParams ¶ms) const =0 |
| | Calculate zone geometries for N windows.
|
| |
| virtual int | masterZoneIndex () const |
| | Get the index of the "master" zone (if applicable)
|
| |
| virtual bool | supportsMasterCount () const |
| | Check if algorithm supports variable master count.
|
| |
| virtual bool | supportsSplitRatio () const |
| | Check if algorithm supports split ratio adjustment.
|
| |
| virtual qreal | defaultSplitRatio () const |
| | Get default split ratio for this algorithm.
|
| |
| virtual int | minimumWindows () const |
| | Get minimum number of windows for meaningful tiling.
|
| |
| virtual int | defaultMaxWindows () const |
| | Get default maximum number of windows for this algorithm.
|
| |
| virtual bool | producesOverlappingZones () const |
| | Whether this algorithm intentionally produces overlapping zones.
|
| |
| virtual QString | zoneNumberDisplay () const noexcept |
| | How zone numbers should be displayed in previews.
|
| |
| virtual bool | centerLayout () const |
| | Whether this algorithm uses a center layout.
|
| |
| virtual bool | isScripted () const noexcept |
| | Whether this algorithm is a user-provided scripted algorithm.
|
| |
| virtual bool | supportsMinSizes () const noexcept |
| | Whether this algorithm supports per-window minimum size constraints.
|
| |
| virtual bool | supportsMemory () const noexcept |
| | Whether this algorithm maintains persistent state across retiles.
|
| |
| virtual void | prepareTilingState (TilingState *state) const |
| | Prepare the TilingState before calculateZones() is called.
|
| |
| virtual bool | isUserScript () const noexcept |
| | Whether this scripted algorithm was loaded from a user directory.
|
| |
| virtual bool | supportsLifecycleHooks () const noexcept |
| | Whether this algorithm implements any lifecycle hooks.
|
| |
| virtual void | onWindowAdded (TilingState *state, int windowIndex) |
| | Called when a window is added to the tiling before retile.
|
| |
| virtual void | onWindowRemoved (TilingState *state, int windowIndex) |
| | Called when a window is removed from the tiling before retile.
|
| |
| virtual bool | supportsCustomParams () const noexcept |
| | Whether this algorithm declares custom parameters.
|
| |
| virtual QVariantList | customParamDefList () const |
| | Get custom parameter definitions as a QVariantList for QML.
|
| |
| virtual bool | hasCustomParam (const QString &name) const |
| | Check if a named custom parameter is declared by this algorithm.
|
| |
|
| static QVector< int > | distributeEvenly (int total, int count) |
| | Distribute a total evenly among N parts with pixel-perfect remainder handling.
|
| |
| static QRect | innerRect (const QRect &screenGeometry, int outerGap) |
| | Compute the usable area after subtracting uniform outer gap from screen edges.
|
| |
| static QRect | innerRect (const QRect &screenGeometry, const EdgeGaps &gaps) |
| | Compute the usable area after subtracting per-side outer gaps from screen edges.
|
| |
| static QVector< int > | distributeWithGaps (int total, int count, int gap) |
| | Distribute total space among count items with gaps between them.
|
| |
| static QVector< int > | distributeWithMinSizes (int total, int count, int gap, const QVector< int > &minDims) |
| | Distribute total space among count items with gaps, respecting per-item minimums.
|
| |
| static int | minWidthAt (const QVector< QSize > &minSizes, int index) |
| | Extract minimum width from minSizes at the given index.
|
| |
| static int | minHeightAt (const QVector< QSize > &minSizes, int index) |
| | Extract minimum height from minSizes at the given index.
|
| |
| static void | solveTwoPartMinSizes (int contentDim, int &firstDim, int &secondDim, int minFirst, int minSecond) |
| | Solve two-column/two-row dimension distribution with min-size constraints.
|
| |
| static void | applyPerWindowMinSize (int &width, int &height, const QVector< QSize > &minSizes, int index) |
| | Apply per-window minimum size constraints (used by overlapping algorithms)
|
| |
| static ThreeColumnWidths | solveThreeColumnWidths (int areaX, int contentWidth, int innerGap, qreal splitRatio, int minLeftWidth, int minCenterWidth, int minRightWidth) |
| | Solve three-column width distribution with ratio and min-size constraints.
|
| |
| static CumulativeMinDims | computeAlternatingCumulativeMinDims (int windowCount, const QVector< QSize > &minSizes, int innerGap) |
| | Precompute direction-aware cumulative min dimensions for alternating splits.
|
| |
| static void | appendGracefulDegradation (QVector< QRect > &zones, const QRect &remaining, int leftover, int innerGap) |
| | Append graceful degradation zones when remaining area is too small.
|
| |
| static qreal | clampOrProportionalFallback (qreal ratio, qreal minFirstRatio, qreal maxFirstRatio, int firstDim, int secondDim) |
| | Clamp split ratio to min/max range, or fall back to proportional split.
|
| |
Abstract base class for tiling algorithms.
Each algorithm generates zone geometries based on:
- Number of windows to tile
- Screen geometry (available area)
- Algorithm-specific parameters (master ratio, gaps, etc.)
Zone geometries are returned as absolute pixel coordinates matching the provided screen geometry. This matches KWin's setFrameGeometry() API.
Subclasses must implement:
Optionally override capability methods to indicate support for:
- Master count adjustment
- Split ratio adjustment
- Note
- Thread Safety: All algorithms are stateless — their const public methods can be called concurrently on the same instance. The TilingState parameter must not be modified during the call.
| virtual QVector< QRect > PhosphorTiles::TilingAlgorithm::calculateZones |
( |
const TilingParams & |
params | ) |
const |
|
pure virtual |
Calculate zone geometries for N windows.
This is the core algorithm method. Given tiling parameters (window count, screen geometry, state, gaps, min sizes), generate zone rectangles.
- Parameters
-
- Returns
- Vector of zone geometries in absolute pixel coordinates
- Note
- The returned vector should have exactly params.windowCount elements. For windowCount == 0, return an empty vector. For windowCount == 1, typically return a single zone inset by outerGap.
Implemented in PhosphorTiles::ScriptedAlgorithm.
| virtual QVariantList PhosphorTiles::TilingAlgorithm::customParamDefList |
( |
| ) |
const |
|
virtual |
Get custom parameter definitions as a QVariantList for QML.
Each entry is a QVariantMap with keys: name, type, defaultValue, description, minValue, maxValue, enumOptions (as applicable).
- Returns
- List of param definition maps, or empty if none declared
Reimplemented in PhosphorTiles::ScriptedAlgorithm.
| static QVector< int > PhosphorTiles::TilingAlgorithm::distributeEvenly |
( |
int |
total, |
|
|
int |
count |
|
) |
| |
|
staticprotected |
Distribute a total evenly among N parts with pixel-perfect remainder handling.
Helper for algorithms that need to divide screen space evenly. Distributes remainder pixels to the first parts to ensure the sum equals the total exactly.
Example: distributeEvenly(100, 3) returns {34, 33, 33}
- Parameters
-
| total | Total pixels to distribute |
| count | Number of parts to divide into (must be > 0) |
- Returns
- Vector of sizes, one per part
| virtual void PhosphorTiles::TilingAlgorithm::onWindowAdded |
( |
TilingState * |
state, |
|
|
int |
windowIndex |
|
) |
| |
|
virtual |
Called when a window is added to the tiling before retile.
Algorithms can use this to update internal state (e.g., BSP tree insertion) instead of rebuilding from scratch in calculateZones().
Unlike calculateZones() (which receives a const TilingState*), lifecycle hooks receive a mutable pointer so algorithms can update internal structures (e.g., split trees) incrementally.
- Parameters
-
| state | Current tiling state (mutable for tree updates) |
| windowIndex | Index where the window was inserted |
Reimplemented in PhosphorTiles::ScriptedAlgorithm.
| virtual void PhosphorTiles::TilingAlgorithm::onWindowRemoved |
( |
TilingState * |
state, |
|
|
int |
windowIndex |
|
) |
| |
|
virtual |
Called when a window is removed from the tiling before retile.
The window is still present in state when this hook fires; it will be removed immediately after the hook returns. This means state->tiledWindowCount() still includes the departing window. Algorithms should use windowIndex to identify the departing window but must not assume the tiled window list will remain unchanged after the call. Hooks must NOT reorder or mutate the tiled window list — the engine relies on list stability for the subsequent removal.
Unlike calculateZones() (which receives a const TilingState*), lifecycle hooks receive a mutable pointer so algorithms can update internal structures (e.g., split trees) incrementally.
- Parameters
-
| state | Current tiling state (window still present, count not yet decremented) |
| windowIndex | Index the window occupied before removal |
Reimplemented in PhosphorTiles::ScriptedAlgorithm.
| void PhosphorTiles::TilingAlgorithm::setAppIdResolver |
( |
std::function< QString(const QString &)> |
resolver | ) |
|
|
inline |
Inject a resolver that maps an opaque instance id to its live app class.
Used by algorithms that need per-window class info (currently only ScriptedAlgorithm, which exposes class to user-authored JS). Built-in geometry algorithms don't care and ignore the resolver.
Injected by AutotileEngine::setWindowRegistry() so every algorithm returned from AlgorithmRegistry::algorithm() is seeded with the live registry's lookup before any lifecycle hook fires. The resolver is a std::function rather than a raw WindowRegistry* so tests can plug in canned answers without constructing a real registry.
Thread safety: setter must be called from the main thread; the resolver itself is invoked only from algorithm methods that already run on the main thread (buildJsState / onWindowAdded / etc.).