Manual zone-based placement engine. Implements IPlacementEngine for screens running a user-drawn layout. Handles auto-snap on window open, directional zone navigation, floating, rotation, resnap-on-layout- change, and serialisation through SnapState.
The Phosphor daemon dispatches every window-lifecycle and shortcut event through PhosphorEngine::IPlacementEngine so it doesn't have to branch on the current placement mode. phosphor-snap-engine is the manual-mode implementation: when a screen has a zone layout active, this engine owns the decisions about which zone a new window joins, how Super+arrow navigates between zones, how rotation cycles windows, and what happens on float / unfloat.
The engine reads from shared services (none of which it owns):
The engine owns SnapState (per-screen mutable state implementing IPlacementState) and SnapNavigationTargetResolver (pure compute for keyboard-navigation target geometries).
| Type | Purpose |
|---|---|
| PhosphorSnapEngine::SnapEngine | Concrete IPlacementEngine for manual zone layouts |
| PhosphorSnapEngine::SnapState | Per-screen IPlacementState: zone assignments, pre-tile geometry, floating set |
| PhosphorEngine::ISnapSettings | Settings the engine reads (exclusions, sticky-window handling, master toggle) |
| PhosphorSnapEngine::INavigationStateProvider | Narrow read-only state contract the daemon implements |
| PhosphorSnapEngine::IZoneAdjacencyResolver | Directional zone lookup contract the daemon implements |
| PhosphorSnapEngine::SnapNavigationTargetResolver | Pure compute for move / focus / swap / push / cycle / restore target geometries |
Wire up the engine inside the daemon's composition root:
#include <PhosphorSnapEngine/SnapEngine.h>
using namespace PhosphorSnapEngine;
auto* snap = new SnapEngine(layoutRegistry,
windowTrackingService,
zoneDetector,
virtualDesktopManager,
/*parent*/ daemon);
snap->setEngineSettings(snapSettingsAdaptor);
snap->setNavigationStateProvider(windowTrackingAdaptor);
snap->setZoneAdjacencyResolver(zoneDetectionAdaptor);
// Dispatch from the daemon:
placementEngineRouter.bind("snap", snap);