← Back to docs

Core · spatial

Portal Spatial Plugin — Wayfire Integration

Thin Rust cdylib that bridges portal-spatial's zone management into Wayfire via C++ FFI shim. Loaded as a Wayfire plugin to manage spatial zones in the compositor.

portal-spatial-pluginv0.2.0spatial
1.5K
Lines of Code
60
Tests
10
Files

Architecture

The crate is a thin FFI wrapper around portal-spatial. It exports C functions for creating/destroying assignment engines, assigning views, switching dimensions, and querying status. The actual logic lives in portal-spatial — this crate just provides the C ABI boundary.

Overview

portal-spatial-plugin is a C-compatible dynamic library (cdylib) that integrates the portal-spatial zone management system into the Wayfire compositor. It provides FFI functions that the C++ Wayfire plugin shim (portal-spatial-shim.so) calls to create spatial contexts, assign views to zones, and handle dimension switches. The plugin registers the portal_spatial_manager_v1 Wayland global that portal-wm connects to.

Key Types

SpatialContext (FFI)Opaque handle to the spatial plugin state, created from C++ and passed back for each operation.

Data Flow

Wayfire loads portal-spatial-shim.so → shim dlopens libportal_spatial.so → calls spatial_context_create() → registers portal_spatial_manager_v1 global

Dependencies

External (4)

tracing 0.1thiserror workspaceparking_lot 0.12serde_json 1.0

Depends on portal-spatial for all spatial logic. The C++ shim is in portal/wayfire-plugins/portal-spatial/.