Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorTiles Namespace Reference

Namespaces

namespace  AutotileDefaults
 Auto-tiling algorithm defaults.
 
namespace  AutotileJsonKeys
 JSON keys for autotile state serialization.
 
namespace  AutotileJsonValues
 JSON value strings (enum-ish discriminants) paired with the keys above.
 
namespace  detail
 
namespace  ScriptedHelpers
 JS builtin sources loaded from the :/builtins/ Qt resource at ScriptedAlgorithm::loadScript() time.
 

Classes

struct  AlgorithmPreviewParams
 User-configured tiling parameters that affect algorithm preview generation. More...
 
class  AlgorithmRegistrar
 Helper for static self-registration of built-in algorithms. More...
 
class  AlgorithmRegistry
 Concrete tiling-algorithm registry. More...
 
class  AutotileLayoutSource
 ILayoutSource adapter wrapping an ITileAlgorithmRegistry. More...
 
class  AutotileLayoutSourceFactory
 Factory for AutotileLayoutSource. More...
 
struct  CumulativeMinDims
 Result of precomputing cumulative min dimensions for alternating V/H splits. More...
 
class  ITileAlgorithmRegistry
 Abstract contract for a tiling-algorithm registry. More...
 
struct  PendingAlgorithmRegistration
 Pending algorithm registration data. More...
 
class  ScriptedAlgorithm
 
class  ScriptedAlgorithmLoader
 Discovers, loads, and hot-reloads ScriptedAlgorithm instances. More...
 
class  ScriptedAlgorithmWatchdog
 Per-loader watchdog for scripted algorithms. More...
 
struct  SplitNode
 A single node in the binary split tree. More...
 
class  SplitTree
 A binary split tree for interactive window tiling. More...
 
struct  ThreeColumnWidths
 Result of solving three-column width distribution. More...
 
class  TilingAlgorithm
 Abstract base class for tiling algorithms. More...
 
struct  TilingParams
 Parameters for zone calculation. More...
 
struct  TilingScreenInfo
 Screen metadata passed to tiling algorithms. More...
 
class  TilingState
 Tracks tiling state for a single screen. More...
 
struct  WindowInfo
 Per-window metadata passed to algorithms. More...
 

Typedefs

using EdgeGaps = ::PhosphorLayout::EdgeGaps
 

Enumerations

enum class  AutotileOverflowBehavior { Float = 0 , Unlimited = 1 }
 
enum class  AutotileInsertPosition { End = 0 , AfterFocused = 1 , AsMaster = 2 }
 
enum class  AutotileDragBehavior { Float = 0 , Reorder = 1 }
 

Functions

PHOSPHORTILES_EXPORT QList< PendingAlgorithmRegistration > & pendingAlgorithmRegistrations ()
 Global list of pending algorithm registrations.
 
PHOSPHORTILES_EXPORT class QMutex & pendingAlgorithmRegistrationsMutex ()
 Mutex protecting pendingAlgorithmRegistrations().
 
PHOSPHORTILES_EXPORT QLatin1String autotileLayoutSourceName ()
 Stable source-name string for the autotile layout source.
 
PHOSPHORTILES_EXPORT void ensureAutotileLayoutSourceProviderLinked ()
 Anchor symbol that forces the translation unit owning the static LayoutSourceProviderRegistrar for this provider to be linked in.
 
PHOSPHORTILES_EXPORT PhosphorLayout::LayoutPreview previewFromAlgorithm (const QString &algorithmId, PhosphorTiles::TilingAlgorithm *algorithm, int windowCount, PhosphorTiles::ITileAlgorithmRegistry *registry, QSize canvasSize={})
 Convert a single TilingAlgorithm into a renderer-ready LayoutPreview.
 
PHOSPHORTILES_EXPORT PhosphorLayout::LayoutPreview previewFromAlgorithm (PhosphorTiles::TilingAlgorithm *algorithm, int windowCount, PhosphorTiles::ITileAlgorithmRegistry *registry, QSize canvasSize={})
 Convenience overload that reads the algorithm's stable id from TilingAlgorithm::registryId() (populated by AlgorithmRegistry::registerAlgorithm).
 
bool hardenSandbox (QJSEngine *engine)
 Harden a QJSEngine sandbox for safe user-script execution.
 
PHOSPHORTILES_EXPORT QVector< WindowInfobuildWindowInfos (const TilingState *state, int windowCount, const std::function< QString(const QString &)> &appIdResolver, int &focusedIndex)
 Build per-window metadata from a TilingState.
 

Typedef Documentation

◆ EdgeGaps

Enumeration Type Documentation

◆ AutotileDragBehavior

Enumerator
Float 
Reorder 

◆ AutotileInsertPosition

Enumerator
End 
AfterFocused 
AsMaster 

◆ AutotileOverflowBehavior

Enumerator
Float 
Unlimited 

Function Documentation

◆ autotileLayoutSourceName()

PHOSPHORTILES_EXPORT QLatin1String PhosphorTiles::autotileLayoutSourceName ( )

Stable source-name string for the autotile layout source.

Exposed publicly so callers that need to look up the bundle's autotile source via LayoutSourceBundle::source(...) (e.g. the daemon's fast-path cache pointer in daemon.cpp) reference one definition instead of repeating the literal at every call site. The factory's name() returns the same value.

◆ buildWindowInfos()

PHOSPHORTILES_EXPORT QVector< WindowInfo > PhosphorTiles::buildWindowInfos ( const TilingState state,
int  windowCount,
const std::function< QString(const QString &)> &  appIdResolver,
int &  focusedIndex 
)

Build per-window metadata from a TilingState.

Shared between AutotileEngine (for TilingParams construction) and ScriptedAlgorithm (for lifecycle hook JS state). Identifies the focused window; app class is resolved via the caller-supplied appIdResolver so live class lookups hit the WindowRegistry instead of parsing stale strings.

TilingState::m_windowOrder contains bare instance ids; parsing them as "appId|uuid" would hand hex strings to user-authored JS algorithms. The resolver lets each caller plug in whatever knows the live class for a given instance id (typically AutotileEngine::currentAppIdFor bound as a lambda, which consults the shared WindowRegistry).

Parameters
stateCurrent tiling state (may be null — returns empty vector)
windowCountNumber of windows to process (may differ from state->tiledWindowCount())
appIdResolverFunction that maps an instance id to its current class. Pass a no-op returning QString() to keep info.appId empty.
[out]focusedIndexSet to the index of the focused window, or -1
Returns
WindowInfo vector (empty if state is null; size may be less than windowCount)

◆ ensureAutotileLayoutSourceProviderLinked()

PHOSPHORTILES_EXPORT void PhosphorTiles::ensureAutotileLayoutSourceProviderLinked ( )

Anchor symbol that forces the translation unit owning the static LayoutSourceProviderRegistrar for this provider to be linked in.

Under SHARED builds (today's default) every TU of the loaded library has its static initialisers run, so this anchor is a no-op. The function exists so that STATIC builds + linker GC (--gc-sections, --as-needed) can't drop autotilelayoutsourcefactory.cpp silently — at which point the static registrar never runs and the bundle ships without the autotile provider. Composition-root glue (buildStandardLayoutSourceBundle) calls this once during bundle wiring. The body is an empty no-op; only the symbol reference matters. See the @todo(plugin-compositor) note in PhosphorLayoutApi/LayoutSourceProviderRegistry.h.

◆ hardenSandbox()

bool PhosphorTiles::hardenSandbox ( QJSEngine *  engine)

Harden a QJSEngine sandbox for safe user-script execution.

Applies all sandbox hardening steps in order:

  1. Freeze built-in helper globals (applyTreeGeometry, etc.)
  2. Lock down eval(), Function, GeneratorFunction, AsyncFunction constructors
  3. Freeze Object.prototype and Array.prototype (fatal on failure)
  4. Close Object.constructor escape on all major built-in objects
  5. Disable Proxy, Reflect, WeakRef, FinalizationRegistry
  6. Strip dangerous QJSEngine-provided globals (Qt, print, console, gc, timers)
Parameters
engineThe QJSEngine to harden (must not be null)
Returns
true if all critical hardening steps succeeded, false if compromised

◆ pendingAlgorithmRegistrations()

PHOSPHORTILES_EXPORT QList< PendingAlgorithmRegistration > & PhosphorTiles::pendingAlgorithmRegistrations ( )

Global list of pending algorithm registrations.

Separate from the template so every registrar instantiation appends to the same list regardless of template specialisation.

Warning
Callers MUST hold pendingAlgorithmRegistrationsMutex() across every access. The list is append-only at static-init time and snapshot-only at AlgorithmRegistry construction, so contention is rare — but with the singleton gone (PR #343) two registries can be constructed concurrently in the same process (daemon + KCM tests), and a Qt plugin loader spawning a worker thread that triggers dlopen of an algorithm library is a realistic future case.

◆ pendingAlgorithmRegistrationsMutex()

PHOSPHORTILES_EXPORT class QMutex & PhosphorTiles::pendingAlgorithmRegistrationsMutex ( )

Mutex protecting pendingAlgorithmRegistrations().

Same Meyer's-singleton lifetime as the list itself.

◆ previewFromAlgorithm() [1/2]

PHOSPHORTILES_EXPORT PhosphorLayout::LayoutPreview PhosphorTiles::previewFromAlgorithm ( const QString &  algorithmId,
PhosphorTiles::TilingAlgorithm algorithm,
int  windowCount,
PhosphorTiles::ITileAlgorithmRegistry registry,
QSize  canvasSize = {} 
)

Convert a single TilingAlgorithm into a renderer-ready LayoutPreview.

Pure projection that runs the algorithm at windowCount windows against a canvas, normalises the resulting zone rects to 0..1 space, and packages them with the algorithm's display metadata.

algorithmId is the registry id for algorithm — embedded into the returned preview as "autotile:<id>".

registry — tile-algorithm registry consulted for previewParams() (the user-configured master-count / split-ratio / per-algorithm saved settings). Must be non-null; composition roots inject the registry they own.

canvasSize — preview canvas dimensions. Default-empty (or non-positive on either axis) means "use a square canvas" — appropriate for generic algorithm thumbnails shown in screen-agnostic UIs (settings list, layout picker). Aspect-aware callers (e.g. the per-screen OSD preview) MUST pass the target screen's size so that algorithms whose split decisions depend on aspect ratio (BSP, fibonacci, …) produce a preview matching what the live tiler will actually render. Only the ratio matters; output zones are normalised regardless.

Provided as a free function so consumers that already hold a TilingAlgorithm* can build a preview without going through AutotileLayoutSource (mirrors PhosphorZones::previewFromLayout).

◆ previewFromAlgorithm() [2/2]

PHOSPHORTILES_EXPORT PhosphorLayout::LayoutPreview PhosphorTiles::previewFromAlgorithm ( PhosphorTiles::TilingAlgorithm algorithm,
int  windowCount,
PhosphorTiles::ITileAlgorithmRegistry registry,
QSize  canvasSize = {} 
)

Convenience overload that reads the algorithm's stable id from TilingAlgorithm::registryId() (populated by AlgorithmRegistry::registerAlgorithm).

Bails with a warning if the algorithm is not currently registered (empty registryId() — a preview has no stable id to reference). The supplied registry is consulted only for preview-params resolution, not for an id reverse-lookup — every call is O(1) regardless of registry size.