Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorLayer::PhosphorWaylandTransport Class Reference

Default transport: binds surfaces to wlr-layer-shell via PhosphorWayland's LayerSurface class. More...

#include <phosphor-layer/include/PhosphorLayer/defaults/PhosphorWaylandTransport.h>

Inheritance diagram for PhosphorLayer::PhosphorWaylandTransport:
[legend]

Public Member Functions

 PhosphorWaylandTransport ()
 
 ~PhosphorWaylandTransport () override
 
bool isSupported () const override
 True if the compositor advertises wlr-layer-shell.
 
std::unique_ptr< ITransportHandleattach (QQuickWindow *win, const TransportAttachArgs &args) override
 Mark win as a layer-shell surface with the given initial configuration.
 
CompositorLostCookie addCompositorLostCallback (CompositorLostCallback cb) override
 
void removeCompositorLostCallback (CompositorLostCookie cookie) override
 
- Public Member Functions inherited from PhosphorLayer::ILayerShellTransport
 ILayerShellTransport ()=default
 
virtual ~ILayerShellTransport ()=default
 

Additional Inherited Members

- Public Types inherited from PhosphorLayer::ILayerShellTransport
using CompositorLostCallback = std::function< void()>
 Register a callback fired when the compositor's layer-shell global is removed (compositor crash / restart).
 
using CompositorLostCookie = quint64
 

Detailed Description

Default transport: binds surfaces to wlr-layer-shell via PhosphorWayland's LayerSurface class.

Stateless — isSupported() proxies to LayerSurface::isSupported(), and attach() creates exactly one LayerSurface per QWindow.

Compositor-lost detection covers two edges:

  • Mid-session: PhosphorWayland's QPA plugin observes wl_registry::global_remove for zwlr_layer_shell_v1 and forwards the edge through PhosphorWayland::addCompositorLostCallback. This transport subscribes at construction so a compositor crash / restart fires registered callbacks before Qt tears the connection down.
  • Clean exit: QGuiApplication::aboutToQuit covers the case where the application terminates before the compositor sent a removal.

Both feed the same one-shot internal broadcaster, so consumer callbacks fire at most once.

Thread-safe: addCompositorLostCallback() may be called from any thread. Callbacks fire on the GUI thread (where aboutToQuit is emitted and where the QPA plugin dispatches Wayland events under the standard QGuiApplication setup) and are invoked outside the internal mutex, so callbacks may freely re-enter the transport without deadlocking.

Constructor & Destructor Documentation

◆ PhosphorWaylandTransport()

PhosphorLayer::PhosphorWaylandTransport::PhosphorWaylandTransport ( )

◆ ~PhosphorWaylandTransport()

PhosphorLayer::PhosphorWaylandTransport::~PhosphorWaylandTransport ( )
override

Member Function Documentation

◆ addCompositorLostCallback()

CompositorLostCookie PhosphorLayer::PhosphorWaylandTransport::addCompositorLostCallback ( CompositorLostCallback  cb)
overridevirtual

◆ attach()

std::unique_ptr< ITransportHandle > PhosphorLayer::PhosphorWaylandTransport::attach ( QQuickWindow *  win,
const TransportAttachArgs args 
)
overridevirtual

Mark win as a layer-shell surface with the given initial configuration.

MUST be called before win's first show(). Post-show properties that the protocol forbids mutating (layer output, scope, anchors in v1–3) are fixed at this point; later changes require destroy + re-attach.

Returns nullptr on failure; callers propagate as Surface::Failed.

Implements PhosphorLayer::ILayerShellTransport.

◆ isSupported()

bool PhosphorLayer::PhosphorWaylandTransport::isSupported ( ) const
overridevirtual

True if the compositor advertises wlr-layer-shell.

Surfaces fail construction with a logged reason when this returns false.

Implements PhosphorLayer::ILayerShellTransport.

◆ removeCompositorLostCallback()

void PhosphorLayer::PhosphorWaylandTransport::removeCompositorLostCallback ( CompositorLostCookie  cookie)
overridevirtual

The documentation for this class was generated from the following file: