layersurface

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT, MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package layersurface maps the wlr-layer-shell role onto a wl_surface: anchor, layer, keyboard mode, the configure handshake, and the closed signal.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("layersurface: closed by compositor")

ErrClosed reports that the compositor closed the layer surface; the surface object must not be used again.

View Source
var ErrNotConfigured = errors.New("layersurface: not configured yet")

ErrNotConfigured reports a draw attempt before the first configure event. The compositor rejects buffers committed before the initial configure.

View Source
var ErrShellTooOld = errors.New("layersurface: the compositor's layer shell is too old for this request")

ErrShellTooOld reports a request the compositor's layer shell version cannot carry.

View Source
var ErrUnavailable = errors.New("layersurface: compositor has no zwlr_layer_shell_v1")

ErrUnavailable reports a compositor without zwlr_layer_shell_v1.

Functions

This section is empty.

Types

type Anchor

type Anchor uint8

Anchor is a bitmask of the edges the surface is anchored to.

const (
	AnchorTop Anchor = 1 << iota
	AnchorBottom
	AnchorLeft
	AnchorRight
)

Anchor edges. The numeric values are the wire values of the protocol enum.

type Config

type Config struct {
	Layer  Layer
	Anchor Anchor

	// Width and Height are the surface size in surface (logical) pixels.
	// An axis set to 0 lets the compositor assign it, which the protocol
	// only allows when both edges of that axis are anchored; New
	// enforces this locally so the error surfaces before the wire.
	Width, Height uint32

	// Margin distances the surface from the edges it is anchored to,
	// in surface (logical) pixels.
	Margin Margins

	// ExclusiveZone reserves space along the anchored edge, in surface
	// pixels. Negative values distance the surface from the edge by the
	// given amount. 0 requests no reservation.
	ExclusiveZone int32

	Keyboard  KeyboardMode
	Namespace string
	// contains filtered or unexported fields
}

Config describes the layer surface before the first commit.

type KeyboardMode

type KeyboardMode uint8

KeyboardMode selects how the compositor gives the surface keyboard focus. The numeric values are the wire values of the protocol enum.

const (
	KeyboardNone KeyboardMode = iota
	KeyboardExclusive
	KeyboardOnDemand
)

Keyboard interactivity modes: none, exclusive grab, on-demand.

type Layer

type Layer uint8

Layer selects the stack layer the surface renders in. The numeric values are the wire values of the protocol enum.

const (
	LayerBackground Layer = iota
	LayerBottom
	LayerTop
	LayerOverlay
)

Stack layers, background through overlay.

type Margins

type Margins struct {
	Top, Right, Bottom, Left int32
}

Margins is the space between the surface and the anchored edges.

func (Margins) Set

func (m Margins) Set(ls *wlr.ZwlrLayerSurfaceV1)

Set applies the margins to the layer surface.

type Shell

type Shell interface {
	LayerShell() *wlr.ZwlrLayerShellV1
	LayerShellVersion() uint32
}

Shell is the bound layer shell and the version it was bound at; the session is one. Taking both together keeps a caller from asking for what the bound version cannot carry.

type Surface

type Surface struct {
	WLSurface *wl.Surface
	Layer     *wlr.ZwlrLayerSurfaceV1
	// contains filtered or unexported fields
}

Surface is one layer surface and its configure handshake.

func New

func New(shell Shell, surf *wl.Surface, output *wl.Output, cfg Config) (*Surface, error)

New assigns the layer role and sends the initial state. The caller must still commit the wl_surface; the compositor answers with the first configure event.

func (*Surface) Close

func (s *Surface) Close()

Close destroys the layer surface from the client side. The closed flag turns on immediately so the owning loop drops the window. Idempotent.

func (*Surface) Closed

func (s *Surface) Closed() bool

Closed reports whether the compositor closed the surface.

func (*Surface) Config

func (s *Surface) Config() Config

Config is the surface's current declarative state: creation's, updated by every accepted runtime change - what a rebuild on a new connection reads back.

func (*Surface) DestroySurface

func (s *Surface) DestroySurface()

DestroySurface destroys the layer role, closed by the client or the compositor, and then the wl_surface. Idempotent.

func (*Surface) EnsureUsable

func (s *Surface) EnsureUsable() error

EnsureUsable gates drawing: the surface must have completed the first configure and must not be closed. A closed surface wins over the configured state.

func (*Surface) HandleZwlrLayerSurfaceV1Closed

func (s *Surface) HandleZwlrLayerSurfaceV1Closed(wlr.ZwlrLayerSurfaceV1ClosedEvent)

HandleZwlrLayerSurfaceV1Closed marks the surface closed.

func (*Surface) HandleZwlrLayerSurfaceV1Configure

func (s *Surface) HandleZwlrLayerSurfaceV1Configure(ev wlr.ZwlrLayerSurfaceV1ConfigureEvent)

HandleZwlrLayerSurfaceV1Configure implements the configure handler: it records the new size and acknowledges the serial. A zero width or height keeps the current choice for that axis, per the protocol.

func (*Surface) HostSurface

func (s *Surface) HostSurface() *wl.Surface

HostSurface returns the underlying wl_surface.

func (*Surface) KeyboardMode

func (s *Surface) KeyboardMode() KeyboardMode

KeyboardMode is the keyboard interactivity in effect.

func (*Surface) LayerPopupSurface

func (s *Surface) LayerPopupSurface() *wlr.ZwlrLayerSurfaceV1

LayerPopupSurface returns the layer surface for popup parenting; layer surfaces have no xdg_surface of their own.

func (*Surface) OnConfigured

func (s *Surface) OnConfigured(f func())

OnConfigured runs f after each configure is applied and acked, when the surface may commit at its new Size. Wire handlers run in no fixed order, so a listener on the wire could precede the ack.

func (*Surface) Reshape

func (s *Surface) Reshape(a Anchor, width, height uint32) error

Reshape changes the anchor and the size together, validated as one state: a zero axis may become concrete in the same change that drops one of its anchors, which SetAnchor and SetSize alone would each refuse. Both requests land with the next commit.

func (*Surface) SetAnchor

func (s *Surface) SetAnchor(a Anchor) error

SetAnchor re-anchors the surface after creation (gtk4-layer-shell allows every declarative property to change): a bar moving from the top edge to the bottom. The auto-axis rule is checked against the current size; the change lands with the next commit.

func (*Surface) SetExclusiveZone

func (s *Surface) SetExclusiveZone(zone int32) error

SetExclusiveZone changes the reserved space along the anchored edge (a bar auto-hiding gives its zone back).

func (*Surface) SetKeyboardMode

func (s *Surface) SetKeyboardMode(mode KeyboardMode) error

SetKeyboardMode changes the keyboard interactivity after creation (a bar that takes keys while one of its popovers is open). The state is double-buffered: it is committed here so it applies before the next request that depends on it, a popup grab.

func (*Surface) SetLayer

func (s *Surface) SetLayer(l Layer) error

SetLayer moves the surface to another stack layer (layer shell v2).

func (*Surface) SetMargin

func (s *Surface) SetMargin(m Margins) error

SetMargin changes the distances from the anchored edges.

func (*Surface) SetSize

func (s *Surface) SetSize(width, height uint32) error

SetSize requests a new size after creation. The same invalid_size rule as the initial size applies and is enforced locally; the size is double-buffered on the wire, so it lands with the next commit.

func (*Surface) Size

func (s *Surface) Size() (int, int)

Size returns the last configured size in surface (logical) pixels. An unconfigured surface reports zeros.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL