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 ¶
- Variables
- type Anchor
- type Config
- type KeyboardMode
- type Layer
- type Margins
- type Shell
- type Surface
- func (s *Surface) Close()
- func (s *Surface) Closed() bool
- func (s *Surface) Config() Config
- func (s *Surface) DestroySurface()
- func (s *Surface) EnsureUsable() error
- func (s *Surface) HandleZwlrLayerSurfaceV1Closed(wlr.ZwlrLayerSurfaceV1ClosedEvent)
- func (s *Surface) HandleZwlrLayerSurfaceV1Configure(ev wlr.ZwlrLayerSurfaceV1ConfigureEvent)
- func (s *Surface) HostSurface() *wl.Surface
- func (s *Surface) KeyboardMode() KeyboardMode
- func (s *Surface) LayerPopupSurface() *wlr.ZwlrLayerSurfaceV1
- func (s *Surface) OnConfigured(f func())
- func (s *Surface) Reshape(a Anchor, width, height uint32) error
- func (s *Surface) SetAnchor(a Anchor) error
- func (s *Surface) SetExclusiveZone(zone int32) error
- func (s *Surface) SetKeyboardMode(mode KeyboardMode) error
- func (s *Surface) SetLayer(l Layer) error
- func (s *Surface) SetMargin(m Margins) error
- func (s *Surface) SetSize(width, height uint32) error
- func (s *Surface) Size() (int, int)
Constants ¶
This section is empty.
Variables ¶
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.
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.
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.
ErrUnavailable reports a compositor without zwlr_layer_shell_v1.
Functions ¶
This section is empty.
Types ¶
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.
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 ¶
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) 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 ¶
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 ¶
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 ¶ added in v0.1.2
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 ¶
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 ¶
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 ¶
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.