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 ¶
- Variables
- type Hooks
- type Lock
- func (l *Lock) Cancel() error
- func (l *Lock) HandleSessionLockV1Finished(wlr.SessionLockV1FinishedEvent)
- func (l *Lock) HandleSessionLockV1Locked(wlr.SessionLockV1LockedEvent)
- func (l *Lock) NewSurface(surf *wl.Surface, out *wl.Output) (*Surface, error)
- func (l *Lock) State() State
- func (l *Lock) SurfaceFor(out *wl.Output) (*Surface, bool)
- func (l *Lock) Unlock() error
- type State
- type Surface
- func (s *Surface) Close()
- func (s *Surface) Closed() bool
- func (s *Surface) DestroySurface()
- func (s *Surface) EnsureUsable() error
- func (s *Surface) HandleSessionLockSurfaceV1Configure(ev wlr.SessionLockSurfaceV1ConfigureEvent)
- func (s *Surface) HostSurface() *wl.Surface
- func (s *Surface) Size() (int, int)
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("sessionlock: lock surface closed")
ErrClosed reports a lock surface that was destroyed.
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.
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.
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.
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.
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 ¶
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 ¶
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) SurfaceFor ¶
SurfaceFor returns the live lock surface on out, if any.
func (*Lock) Unlock ¶
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.
type Surface ¶
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) DestroySurface ¶
func (s *Surface) DestroySurface()
DestroySurface destroys the lock role and then the wl_surface. Idempotent.
func (*Surface) EnsureUsable ¶
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 ¶
HostSurface returns the underlying wl_surface.