sessionlock

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 5 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 sessionlock maps ext-session-lock-v1 onto lys-ui: the lock object's locked/finished lifecycle and the per-output lock surface role with its configure handshake.

The protocol is a security boundary, so the client-side rules it states are enforced here instead of being left to callers:

  • a lock that received locked is only ever released with unlock_and_destroy (destroy would be invalid_destroy), and unlock_and_destroy is refused until locked arrived (invalid_unlock);
  • an output gets at most one lock surface (duplicate_output);
  • a lock surface is not usable (nothing may commit on it) before its first configure was acked (commit_before_first_ack), and its size is exactly the acked configure size (dimensions_mismatch);
  • finished releases the lock with the request matching its state, and no surface can be created on an ended lock.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("sessionlock: lock surface closed")

ErrClosed reports a lock surface that was destroyed.

View Source
var ErrDuplicateOutput = errors.New("sessionlock: output already has a lock surface")

ErrDuplicateOutput reports a second lock surface for one output, the duplicate_output protocol error.

View Source
var ErrEnded = errors.New("sessionlock: lock has ended")

ErrEnded reports a request on a lock that was already unlocked, cancelled, or finished by the compositor.

View Source
var ErrLocked = errors.New("sessionlock: session is locked; only Unlock ends it")

ErrLocked reports a cancel attempted after the compositor sent locked: destroy would be the invalid_destroy protocol error, and a locked session only ends through Unlock.

View Source
var ErrNotConfigured = errors.New("sessionlock: lock surface not configured yet")

ErrNotConfigured gates drawing before the first configure: the compositor kills the client for committing earlier.

View Source
var ErrNotLocked = errors.New("sessionlock: session is not locked yet")

ErrNotLocked reports an unlock attempted before the compositor sent locked: unlock_and_destroy would be the invalid_unlock protocol error. Cancel the pending lock instead.

Functions

This section is empty.

Types

type Hooks

type Hooks struct {
	// Locked fires once the compositor confirmed the lock: every
	// output shows lock content, nothing unlocked is visible.
	Locked func()
	// Finished fires when the compositor ended the lock: it denied it
	// (another client holds the lock) or ended a locked session by its
	// own policy. The lock is already released on the wire.
	Finished func()
}

Hooks observe the compositor's verdicts. Both run on the event-loop goroutine, inside dispatch.

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

Lock is one ext_session_lock_v1 object.

func New

func New(mgr *wlr.SessionLockManagerV1, hooks Hooks) (*Lock, error)

New requests a session lock from the manager. The compositor answers with locked or finished; lock surfaces should be created for every output right away so it can show them in the first locked frame.

func (*Lock) Cancel

func (l *Lock) Cancel() error

Cancel withdraws a lock the compositor has not confirmed yet. Refused with ErrLocked once locked arrived: a locked session only ends through Unlock.

func (*Lock) HandleSessionLockV1Finished

func (l *Lock) HandleSessionLockV1Finished(wlr.SessionLockV1FinishedEvent)

HandleSessionLockV1Finished implements wlr.SessionLockV1FinishedHandler.

func (*Lock) HandleSessionLockV1Locked

func (l *Lock) HandleSessionLockV1Locked(wlr.SessionLockV1LockedEvent)

HandleSessionLockV1Locked implements wlr.SessionLockV1LockedHandler.

func (*Lock) NewSurface

func (l *Lock) NewSurface(surf *wl.Surface, out *wl.Output) (*Surface, error)

NewSurface assigns the lock-surface role for out to surf. The surface must be fresh: no role, nothing attached or committed. The compositor answers with the first configure; until it is acked the surface reports ErrNotConfigured and must not commit.

func (*Lock) State

func (l *Lock) State() State

State returns the lifecycle state.

func (*Lock) SurfaceFor

func (l *Lock) SurfaceFor(out *wl.Output) (*Surface, bool)

SurfaceFor returns the live lock surface on out, if any.

func (*Lock) Unlock

func (l *Lock) Unlock() error

Unlock ends a locked session: unlock_and_destroy goes out and every lock surface is destroyed. Refused with ErrNotLocked while the lock is pending — the compositor never confirmed it, so it cannot be unlocked; Cancel withdraws it instead.

A client that exits right after unlocking must round-trip the display first, or the compositor may never process the request.

type State

type State uint8

State is where a lock is in its lifecycle.

const (
	// Pending: lock was requested; neither locked nor finished arrived.
	Pending State = iota
	// Locked: the compositor confirmed the session is locked.
	Locked
	// Unlocked: the client released a locked session.
	Unlocked
	// Cancelled: the client withdrew a lock that never locked.
	Cancelled
	// Finished: the compositor ended the lock (denied it, or ended a
	// locked session through its own policy).
	Finished
)

Lock lifecycle states.

func (State) Ended

func (s State) Ended() bool

Ended reports whether the lock is over, whichever way it ended.

func (State) String

func (s State) String() string

String names the state for logs.

type Surface

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

Surface is one ext_session_lock_surface_v1 and its configure handshake. It implements the host contract the app layer draws through: usable only after the first acked configure, sized exactly as configured.

func (*Surface) Close

func (s *Surface) Close()

Close destroys the lock surface. On a still-locked session the compositor falls back to a solid color on that output — the behavior the protocol prescribes for a removed output's surface. Idempotent.

func (*Surface) Closed

func (s *Surface) Closed() bool

Closed reports whether the surface was destroyed.

func (*Surface) DestroySurface

func (s *Surface) DestroySurface()

DestroySurface destroys the lock role and then the wl_surface. Idempotent.

func (*Surface) EnsureUsable

func (s *Surface) EnsureUsable() error

EnsureUsable gates drawing: nothing may commit before the first configure was acked, and a closed surface never draws again.

func (*Surface) HandleSessionLockSurfaceV1Configure

func (s *Surface) HandleSessionLockSurfaceV1Configure(ev wlr.SessionLockSurfaceV1ConfigureEvent)

HandleSessionLockSurfaceV1Configure implements the configure handler: record the exact size and ack the serial.

func (*Surface) HostSurface

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

HostSurface returns the underlying wl_surface.

func (*Surface) Size

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

Size returns the last configured size in surface (logical) pixels; buffers must match it exactly. Zero before the first configure.

Jump to

Keyboard shortcuts

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