Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
phosphor-compositor

‍Compositor-plugin SDK for PlasmaZones. Provides the interface contract, D-Bus client, and shared utilities a compositor plugin needs to give its users zone-based window management.

Responsibility

PlasmaZones splits into a daemon (owns placement logic, zones, layouts, settings) and a compositor plugin (observes windows, applies geometry, renders overlays). This library is the plugin side of that split.

A compositor plugin links PhosphorCompositor, implements ICompositorBridge (22 methods mapping native window handles to the daemon's vocabulary), wires handler interfaces for callbacks, and lets DaemonClient manage all D-Bus communication. The plugin never touches placement logic directly — the daemon decides where, the plugin applies how.

Key types

Type Purpose
ICompositorBridge Abstract interface a plugin implements — window lookup, identity, properties, filtering, actions
DaemonClient Typed D-Bus client — registration, service watching, reconnection, method calls, signal dispatch
IDragHandler Callback interface for drag start/move/end/policy-change
IGeometryHandler Callback interface for geometry apply, batch operations, raise/activate
ILifecycleHandler Callback interface for window open/close/activate/float-change
AutotileState Per-screen border-state tracking + pure helper functions
FloatingCache Compositor-side mirror of daemon float state
SnapAssistFilter Snap-assist candidate building via bridge
TriggerParser Modifier/button activation matching from config
DebouncedAction Generic debounce utility for screen-change coalescing
GeometryHelpers Fractional-scaling-safe rounding

Typical use

#include <PhosphorCompositor/DaemonClient.h>
#include <PhosphorCompositor/ICompositorBridge.h>
#include <PhosphorCompositor/IGeometryHandler.h>

class MyBridge : public PhosphorCompositor::ICompositorBridge { /* ... */ };

class MyPlugin : public PhosphorCompositor::IGeometryHandler,
                 public PhosphorCompositor::IDragHandler,
                 public PhosphorCompositor::ILifecycleHandler
{
    PhosphorCompositor::DaemonClient m_client;
    MyBridge m_bridge;

    void init() {
        m_client.setGeometryHandler(this);
        m_client.setDragHandler(this);
        m_client.setLifecycleHandler(this);

        connect(&m_client, &PhosphorCompositor::DaemonClient::daemonReady,
                this, [this]() {
            m_client.registerBridge("river", 3, {"borderless", "animation"});
        });
    }

    // IGeometryHandler
    void onApplyGeometry(const PhosphorCompositor::GeometryRequest& req) override {
        auto* window = m_bridge.findWindowById(req.windowId);
        if (window) m_bridge.moveResize(window, req.geometry);
    }
    // ... other handlers
};

Existing adapters

Compositor Adapter Location
KWin 6 KWinCompositorBridge kwin-effect/kwin_compositor_bridge.{h,cpp}
river planned

Architecture

Daemon (org.plasmazones D-Bus service)
    ↕ D-Bus IPC
DaemonClient (this library)
    ↓ dispatches to
IDragHandler / IGeometryHandler / ILifecycleHandler
    ↓ implemented by
Compositor Plugin
    ↓ calls
ICompositorBridge (plugin implements, wraps native window APIs)

The daemon always runs. The plugin is stateless with respect to placement — it applies what the daemon tells it and reports window events back.

Dependencies