wlsession

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 37 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

XDG activation: optional xdg_activation_v1 support — the compositor-consented focus request. A client asks for a token anchored to a real user interaction (the serial of a pointer press or keyboard event); once the compositor issues it, the token may be spent to raise and focus a surface, or handed to a spawned app through XDG_ACTIVATION_TOKEN so the child can focus itself. The manager global is feature-detected: without it a token request reports ErrActivationUnavailable and Activate does nothing.

Data control: optional ext_data_control_v1 and zwlr_data_control_unstable_v1 support, the clipboard-manager protocols. Unlike wl_data_device they need no surface and no keyboard focus, so a bar or a background clipboard history can watch, read, and claim the seat's selections. Both manager globals are feature-detected; the session only owns the manager objects, and internal/datacontrol creates the device and drives it.

xdg-dialog-v1: optional window-level dialog modality — the compositor-side companion of xdg_toplevel.set_parent. Registering a parented toplevel as a dialog and hinting it modal lets the compositor block input to the parent itself (keep the dialog on top, dismiss-on-outside-click, dimming), where the toolkit's application-level block only reaches as far as this client's own windows. The manager global is feature-detected: without it the session hands out nil and every caller degrades to application-level modality.

Compositor disconnect classification. When the connection dies — the compositor crashed, was reloaded, or was upgraded out from under the client — the wire surfaces it as a read or write failure on the unix socket, and the neurlang Context folds those into a handful of error shapes. This file maps every shape the dispatch paths can return onto one typed error, so an application's loop sees a disconnect it can act on instead of whatever a raw errno means.

Escape arm: optional lys_escape_v1 support. An open dropdown that leaves the keyboard with another client's window claims the next Escape press through it, which no standard protocol can do. Feature- detected: without the global ArmEscape fails with ErrEscapeUnavailable.

xdg-foreign-unstable-v2: exporting a toplevel yields a string handle another client can name it by. xdg-desktop-portal takes it as a dialog's parent_window ("wayland:<handle>"), so portal dialogs stack over and stay modal to the window that opened them. The exporter global is feature-detected: without it the session hands out nil and portal calls go unparented.

Global shortcuts: the optional hyprland_global_shortcuts_manager_v1, the de-facto wlroots way for a client to register actions the compositor binds to keys (Hyprland offers it; a portal bridges it to org.freedesktop.portal.GlobalShortcuts).

GPU presentation: wl_subcompositor places an application-rendered surface inside a window (widget.GPUArea), and zwp_linux_dmabuf_v1 turns the application's dmabufs into wl_buffers on this connection. Both globals are optional; without them GPUArea reports why.

Idle inhibit: optional zwp_idle_inhibit_manager_v1 support — the way to keep the compositor from marking the user idle (and suspending the screen) while something visible is happening, like a server stream. Inhibitors are explicit handles: create one for the surface that plays the activity, destroy it when it ends. The manager global is feature-detected: without it creation fails with ErrIdleInhibitUnavailable.

The session-facing half of the debug inspector's doctor block (internal/inspect): a read-only snapshot of what the connection bound and resolved. Everything here is observation only - no wire traffic beyond the one-time cursor theme load the cursor path performs anyway on first SetCursor.

Primary selection: optional zwp_primary_selection_unstable_v1 support, the X11-style PRIMARY that middle-click pastes. The manager global is feature-detected — compositors without it keep the session running with every primary-selection call a no-op.

Package wlsession owns the wl_display connection: registry discovery, globals binding, output scale tracking, seat input, and the blocking event dispatch.

Session lock: optional ext_session_lock_manager_v1 support — the secure lock-screen protocol (internal/sessionlock drives it). The manager global is feature-detected: without it SessionLockManager stays nil and locking is unavailable.

Output watchers live here too: a lock must cover every output, hotplugged ones included, without claiming the single-slot OnOutputAdded/OnOutputRemoved hooks the application owns.

Keyboard shortcuts inhibit: optional zwp_keyboard_shortcuts_inhibit_unstable_v1 support — the way a pane (a VM display, a game view) keeps the compositor's own shortcuts from stealing keystrokes while it holds keyboard focus. Inhibitors are explicit handles per surface and seat. The manager global is feature-detected: without it creation fails with ErrShortcutsInhibitUnavailable.

Text input: optional zwp_text_input_v3 support. The manager global is feature-detected — compositors without it keep the session running with every text-input call a no-op.

Foreign toplevels: optional zwlr_foreign_toplevel_management_unstable_v1 support — the window list a taskbar or alt-tab drives. The manager global is feature-detected: compositors without it keep the session running with no toplevels and every request a no-op. The compositor sends a handle for every toplevel surface, including our own windows, so a lys-ui process that binds the manager sees itself in the list under its xdg-toplevel title and app-id.

xdg-toplevel-icon-v1: optional toplevel window icons (#70). The manager creates icon objects and assigns them to toplevels; its icon_size events name the sizes the compositor prefers, which the client rasterizes into square shm buffers. Without the global every window-icon call is a silent no-op - the icon stays whatever the compositor derives from the desktop entry. Like all session state, the size list lives on the loop goroutine the events arrive from.

XDG output: optional xdg_output_unstable_v1 support — the stable output identities (DP-1, HDMI-A-1) that compositor configs are written against, plus the output's logical position and size in the global compositor space. Without it outputs are only identifiable by their registry order and their Name stays empty. The manager global is feature-detected; below manager version 2 the protocol simply sends no names.

Index

Constants

View Source
const (
	CursorLeftPtr           = "left_ptr"
	CursorTopSide           = "top_side"
	CursorBottomSide        = "bottom_side"
	CursorLeftSide          = "left_side"
	CursorRightSide         = "right_side"
	CursorTopLeftCorner     = "top_left_corner"
	CursorTopRightCorner    = "top_right_corner"
	CursorBottomLeftCorner  = "bottom_left_corner"
	CursorBottomRightCorner = "bottom_right_corner"
)

The xcursor names of the shapes the toolkit asks for by name.

View Source
const CursorHidden = "none"

CursorHidden is the shape name that hides the pointer over a surface (GTK's "none"): set_cursor with no surface, no theme lookup. A frozen-screen color picker draws its own loupe in its place.

View Source
const MaxIMESurrounding = 4000

MaxIMESurrounding is the wayland message size cap the protocol puts on surrounding text.

Variables

View Source
var ErrActivationUnavailable = errors.New("wlsession: the compositor offers no xdg_activation_v1")

ErrActivationUnavailable is a token request on a compositor without xdg_activation_v1.

View Source
var ErrAlreadyConstrained = errors.New("wlsession: surface already constrained")

ErrAlreadyConstrained reports a second constraint on one surface, which the protocol forbids.

View Source
var ErrDisconnected = errors.New("wlsession: compositor disconnected")

ErrDisconnected reports that the compositor ended the connection. Every disconnect the dispatch paths return matches it under errors.Is; the classified reason lives on the *DisconnectError in the chain (errors.As), and app re-exports both for its callers.

View Source
var ErrEscapeUnavailable = errors.New("wlsession: no lys-escape protocol")

ErrEscapeUnavailable reports that the compositor advertised no lys_escape_manager_v1.

View Source
var ErrIdleInhibitUnavailable = errors.New("wlsession: no idle-inhibit protocol")

ErrIdleInhibitUnavailable reports that the compositor advertised no idle-inhibit manager, so nothing can be inhibited.

View Source
var ErrIdleNotifyUnavailable = errors.New("wlsession: idle notification unavailable")

ErrIdleNotifyUnavailable reports a compositor without ext-idle-notify-v1 (or no seat to watch).

View Source
var ErrNoInputEvent = errors.New("wlsession: no user input event has arrived to anchor the request")

ErrNoInputEvent reports a request the protocol anchors to a user action made before the seat delivered any input event: there is no serial for it to carry, and compositors refuse it without one.

View Source
var ErrPointerConstraintsUnavailable = errors.New("wlsession: pointer constraints unavailable")

ErrPointerConstraintsUnavailable reports a compositor without pointer constraints, or no pointer to constrain.

View Source
var ErrProtocolUnavailable = errors.New("wlsession: protocol unavailable")

ErrProtocolUnavailable reports a compositor without the protocol a surface request needs.

View Source
var ErrShortcutsInhibitUnavailable = errors.New("wlsession: no keyboard-shortcuts-inhibit protocol")

ErrShortcutsInhibitUnavailable reports that the compositor advertised no shortcuts-inhibit manager.

Functions

func AxisSteps

func AxisSteps(v float64) int

AxisSteps converts a smooth axis value to scroll steps (one per 10 units), keeping at least one step when the value is nonzero: what every surface's HandlePointerAxis hands its router.

func SetLogger

func SetLogger(l *slog.Logger)

SetLogger installs the library-wide logger: protocol-level warnings (an advertised optional global that failed to bind), event-loop diagnostics (missing optional protocols, capability changes) and terminal conditions (the compositor raising a fatal protocol error) are emitted through it. Nothing logs per-frame or per-keypress, and nothing logs at Info. A nil logger selects the default: discard all output. Safe from any goroutine.

Types

type ContentType

type ContentType uint32

ContentType is a surface's content kind (wp_content_type_v1).

type DisconnectError

type DisconnectError struct {
	Reason DisconnectReason
	// Err is the wire failure, decorated with the compositor's verdict
	// when one was recorded before the drop.
	Err error
}

DisconnectError is the typed shape of a dead connection: the classified reason plus the underlying wire failure.

func (*DisconnectError) Error

func (e *DisconnectError) Error() string

func (*DisconnectError) Is

func (e *DisconnectError) Is(target error) bool

Is makes every DisconnectError match the ErrDisconnected sentinel, whatever else the chain wraps.

func (*DisconnectError) Unwrap

func (e *DisconnectError) Unwrap() error

type DisconnectReason

type DisconnectReason int

DisconnectReason classifies why the compositor connection ended.

const (
	// DisconnectConnectionLost means the compositor went away without
	// a verdict — EOF on the socket read, or EPIPE/ECONNRESET on a
	// read or write. This is the crash/reload/upgrade case: the
	// compositor is gone, and every proxy on the connection is dead
	// with it.
	DisconnectConnectionLost DisconnectReason = iota
	// DisconnectProtocol means the compositor raised a fatal
	// wl_display.error against this client before the connection
	// ended. That is a bug (client or compositor) rather than a
	// restart: reconnecting would replay the fatal exchange.
	DisconnectProtocol
)

func (DisconnectReason) String

func (r DisconnectReason) String() string

type DmabufLayout

type DmabufLayout struct {
	Format   fourcc.Format
	Modifier fourcc.Modifier
}

DmabufLayout is a format and modifier pair the compositor imports.

type EscapeArm added in v0.2.0

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

EscapeArm is one claim on the next Escape press: pressed runs when the compositor kept that press from the focused window, at most once.

func (*EscapeArm) Disarm added in v0.2.0

func (a *EscapeArm) Disarm()

Disarm gives the claim up; a second call does nothing.

func (*EscapeArm) HandleLysEscapeArmV1Pressed added in v0.2.0

func (a *EscapeArm) HandleLysEscapeArmV1Pressed(wlr.LysEscapeArmV1PressedEvent)

HandleLysEscapeArmV1Pressed implements wlr.LysEscapeArmV1PressedHandler.

type FrameDone added in v0.2.5

type FrameDone struct {
	Ready bool
	MS    uint32
}

FrameDone receives a frame callback's answer: a listener that takes no allocation per frame, and the compositor's timestamp for the animation clock.

func (*FrameDone) HandleCallbackDone added in v0.2.5

func (f *FrameDone) HandleCallbackDone(ev wl.CallbackDoneEvent)

HandleCallbackDone implements wl.CallbackDoneHandler. The delete_id that follows a done retires the callback for the next frame to reuse.

type GestureKind

type GestureKind uint8

GestureKind is a touchpad gesture's kind.

const (
	GestureSwipe GestureKind = iota
	GesturePinch
	GestureHold
)

Touchpad gestures.

type GesturePhase

type GesturePhase uint8

GesturePhase is where a gesture is in its life.

const (
	GestureBegin GesturePhase = iota
	GestureUpdate
	GestureEnd
	GestureCancel
)

Gesture phases.

type IMEEvent

type IMEEvent struct {
	// Commit is the text to insert at the caret (may be empty).
	Commit string
	// Preedit is the composing text to show at the caret (may be
	// empty, ending composition).
	Preedit string
	// PreeditCursorBegin and PreeditCursorEnd are byte offsets into
	// Preedit; both -1 hide the composing caret.
	PreeditCursorBegin, PreeditCursorEnd int
	// DeleteBefore and DeleteAfter are byte counts to remove before
	// and after the caret.
	DeleteBefore, DeleteAfter uint32
	// Current reports that the done serial matches the commits we
	// sent, so the pushed state is still known and may be re-pushed.
	// A stale batch still applies — committed text is never dropped —
	// but skips the resync.
	Current bool
}

IMEEvent is one applied text-input batch (a done event), carrying the double-buffered changes in the order the protocol applies them: delete surrounding text, insert the commit string, show the new preedit.

type IMEState

type IMEState struct {
	// Enabled requests input-method composition because an editable
	// widget holds focus; false disables it.
	Enabled bool
	// Multiline hints the input method at multi-line content.
	Multiline bool
	// Surrounding is the text around the caret (preedit excluded)
	// with Cursor and Anchor as byte offsets into it, at most
	// MaxIMESurrounding bytes.
	Surrounding    string
	Cursor, Anchor int
	// CursorRect is the caret rectangle in surface-local coordinates,
	// where the input method may place a candidate window.
	CursorRect Rect
	// CauseOther marks a change made without the input method
	// (typing, clipboard, caret motion), asking it to drop whatever
	// it is composing.
	CauseOther bool
}

IMEState is one atomic text-input state update. Callers push the focused editable widget's state; UpdateIME applies it with a commit request.

type IdleInhibitor

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

IdleInhibitor keeps the compositor from idling while its surface is visible. Destroy it when the activity ends; Destroy is nil-safe and idempotent.

func (*IdleInhibitor) Destroy

func (i *IdleInhibitor) Destroy()

Destroy releases the inhibitor, letting the compositor idle again.

type IdleNotification

type IdleNotification struct {
	OnIdle func()
	// OnResume fires when the user is active again after an idle.
	OnResume func()
	// contains filtered or unexported fields
}

IdleNotification is one idle watch: OnIdle fires once the seat has been idle for its timeout, OnResume when activity returns. Both run on the loop goroutine. Destroy ends the watch.

func (*IdleNotification) Destroy

func (n *IdleNotification) Destroy()

Destroy ends the watch.

func (*IdleNotification) HandleExtIdleNotificationV1Idled

func (n *IdleNotification) HandleExtIdleNotificationV1Idled(wlr.ExtIdleNotificationV1IdledEvent)

HandleExtIdleNotificationV1Idled implements the idled handler.

func (*IdleNotification) HandleExtIdleNotificationV1Resumed

func (n *IdleNotification) HandleExtIdleNotificationV1Resumed(wlr.ExtIdleNotificationV1ResumedEvent)

HandleExtIdleNotificationV1Resumed implements the resumed handler.

func (*IdleNotification) Idle

func (n *IdleNotification) Idle() bool

Idle reports whether the seat is idle by this watch's timeout.

type InspectInfo

type InspectInfo struct {
	// Globals maps every interface the registry advertised to the
	// version it advertised. Nil means there is no session.
	Globals map[string]uint32
	// Outputs are the live outputs in registry order.
	Outputs []*Output
	// CursorTheme is the resolved xcursor theme name and its nominal
	// size; CursorErr reports why it is unavailable when empty.
	CursorTheme string
	CursorSize  uint32
	CursorErr   error
	// FractionalScale reports both wp_viewporter and
	// wp_fractional_scale_manager_v1 are bound, so surfaces scale
	// fractionally instead of through integer set_buffer_scale.
	FractionalScale bool
}

InspectInfo is a diagnostics snapshot of the session: the bound globals with their registry versions, the live outputs, the resolved cursor theme, and which scale protocols the compositor offered. internal/inspect formats it into the doctor block.

type Locks

type Locks struct {
	Caps, Num, Scroll bool
}

Locks is which lock keys are on, read from the keymap's indicators, so a layout that moves Num Lock to another modifier still reads true.

type Mods

type Mods uint8

Mods is a bitmask of held keyboard modifiers, mirroring the low bits of the wayland ModsDepressed map.

const (
	ModShift Mods = 1 << iota
	ModCapsLock
	ModCtrl
	ModAlt
	// ModSuper is Mod4, the logo key.
	ModSuper Mods = 1 << 6
)

Modifier bits: xkb's core modifier indices (Shift, Lock, Control, Mod1 for Alt, Mod4 for Super).

type Output

type Output struct {
	WL    *wl.Output
	Scale int

	// ModeW and ModeH are the current mode's pixel size.
	ModeW, ModeH int

	// Transform is the output's rotation/flip as wl_output.geometry
	// reports it (a wl_output.transform enum); surfaces pinned to the
	// output publish it with wl_surface.set_buffer_transform.
	Transform int32

	// Name and Description are the output's stable xdg-output identity
	// (DP-1, HDMI-A-1) — what compositor configs are written against.
	// Empty when the compositor lacks xdg_output or advertises it
	// below version 2, in which case outputs are only identifiable by
	// registry order.
	Name, Description string

	// LogicalX/Y and LogicalW/H are the output's position and size in
	// the global compositor space, as xdg_output.logical_position and
	// logical_size report them.
	LogicalX, LogicalY, LogicalW, LogicalH int32
	// contains filtered or unexported fields
}

Output is one wl_output and its current integer scale.

type PointerConstraint

type PointerConstraint struct {

	// OnActive fires with the compositor's activation state.
	OnActive func(active bool)
	// contains filtered or unexported fields
}

PointerConstraint is one lock or confinement on a surface. The compositor activates it while the pointer is in the surface (and the region, if any); OnActive hears each activation and deactivation. A persistent constraint re-activates when the pointer returns; a oneshot one ends with its first deactivation. Release removes it.

func (*PointerConstraint) Active

func (c *PointerConstraint) Active() bool

Active reports whether the compositor has the constraint in effect.

func (*PointerConstraint) HandleZwpConfinedPointerV1Confined

func (c *PointerConstraint) HandleZwpConfinedPointerV1Confined(wlr.ZwpConfinedPointerV1ConfinedEvent)

HandleZwpConfinedPointerV1Confined implements the confined handler.

func (*PointerConstraint) HandleZwpConfinedPointerV1Unconfined

func (c *PointerConstraint) HandleZwpConfinedPointerV1Unconfined(wlr.ZwpConfinedPointerV1UnconfinedEvent)

HandleZwpConfinedPointerV1Unconfined implements the unconfined handler.

func (*PointerConstraint) HandleZwpLockedPointerV1Locked

func (c *PointerConstraint) HandleZwpLockedPointerV1Locked(wlr.ZwpLockedPointerV1LockedEvent)

HandleZwpLockedPointerV1Locked implements the locked handler.

func (*PointerConstraint) HandleZwpLockedPointerV1Unlocked

func (c *PointerConstraint) HandleZwpLockedPointerV1Unlocked(wlr.ZwpLockedPointerV1UnlockedEvent)

HandleZwpLockedPointerV1Unlocked implements the unlocked handler.

func (*PointerConstraint) Release

func (c *PointerConstraint) Release()

Release removes the constraint.

func (*PointerConstraint) SetCursorHint

func (c *PointerConstraint) SetCursorHint(x, y float64)

SetCursorHint tells the compositor where the cursor should appear when a lock ends (surface coordinates); it applies on the surface's next commit. Confinements ignore it.

type PointerGesture

type PointerGesture struct {
	Kind     GestureKind
	Phase    GesturePhase
	Fingers  int
	DX, DY   float64
	Scale    float64
	Rotation float64
}

PointerGesture is one touchpad gesture event: on update, DX/DY are the centroid's motion since the last event, Scale the pinch relative to its start, Rotation the degrees clockwise since the last event.

type Rect

type Rect struct {
	X, Y, W, H int32
}

Rect is a rectangle in surface-local coordinates.

type Session

type Session struct {
	Display *wl.Display

	// OnOutputAdded fires when a wl_output global appears, including
	// after Connect for hotplug; OnOutputRemoved fires when its global
	// goes away. Set them after Connect to drive per-output windows.
	OnOutputAdded   func(*Output)
	OnOutputRemoved func(*Output)

	// OnKey fires on key presses (never releases) with the evdev
	// keycode and the held modifiers. Keyboard focus is seat-wide,
	// unlike pointer events which route per surface.
	OnKey func(keycode uint32, mods Mods)
	// OnLocks fires on the loop when a lock key's state changes, the
	// first modifiers event after the keyboard's enter included: Caps
	// Lock already on at startup arrives this way.
	OnLocks func(Locks)
	// OnKeyUp fires on key releases with the evdev keycode.
	OnKeyUp func(keycode uint32)

	// OnKeyboardFocus fires when keyboard focus moves: an enter, a
	// leave, the keyboard going away, or the focused surface being
	// unregistered (a client-side destroy, which the compositor never
	// answers with a leave). A key held across the move releases
	// wherever focus went, so no release follows here.
	OnKeyboardFocus func()
	// OnIME fires when the input method applies a batch of changes (a
	// done event) — commit, preedit, and surrounding-text deletion in
	// protocol order. Nil without the text-input protocol, or when no
	// host consumes the events.
	OnIME func(IMEEvent)
	// OnIMEFocus fires when text-input focus enters or leaves a
	// surface; committed state is invalidated and must be re-pushed
	// for whichever surface the input method now targets.
	OnIMEFocus func()

	// OnToplevelAdded fires when the compositor advertises a foreign
	// toplevel — including our own windows; OnToplevelRemoved fires
	// when one closes, OnToplevelUpdated when a batch (title, app-id,
	// state) applied. Nil without the foreign-toplevel protocol or
	// when no host consumes the events.
	OnToplevelAdded   func(*Toplevel)
	OnToplevelRemoved func(*Toplevel)
	OnToplevelUpdated func(*Toplevel)

	// OnOutputIdentity fires when an output's stable xdg-output name
	// arrives or changes — the point where an `output "DP-1"` config
	// section can be matched to a hotplugged monitor.
	OnOutputIdentity func(*Output)
	// contains filtered or unexported fields
}

Session is a connected display with the globals lys-ui needs bound.

func Connect

func Connect() (*Session, error)

Connect binds the display, waits for the initial registry burst and the shm format list, and fails when a required global, the HiDPI-capable compositor version, or the ARGB8888 shm format is missing.

func (*Session) Activate

func (s *Session) Activate(surface *wl.Surface, token string)

Activate raises and focuses surface with a token the compositor issued through RequestActivationToken (the one the launcher handed to the spawned app). No-op without the protocol.

func (*Session) ActivationAvailable

func (s *Session) ActivationAvailable() bool

ActivationAvailable reports whether the compositor advertised xdg_activation_v1. When false, every activation call on the session is a no-op.

func (*Session) AfterSync

func (s *Session) AfterSync(fn func()) error

AfterSync runs fn from the dispatch of the compositor's answer to a display sync sent now: by then the compositor has processed every request the client sent before the call. Its done handler is in place before the request goes out, so no dispatch can miss the answer. On a closed session or a dead connection it fails with ErrDisconnected and fn never runs.

func (*Session) ArmEscape added in v0.2.0

func (s *Session) ArmEscape(pressed func()) (*EscapeArm, error)

ArmEscape claims the next Escape press for pressed.

func (*Session) Bell

func (s *Session) Bell(surf *wl.Surface) error

Bell rings the system bell for surf (nil: the session's), the error ding of a rejected input; a compositor may flash the window instead.

func (*Session) BlurAvailable

func (s *Session) BlurAvailable() bool

BlurAvailable reports whether the compositor blurs behind surfaces: ext_background_effect_v1 bound and its blur capability offered.

func (*Session) Classify

func (s *Session) Classify(err error) error

Classify maps a raw wire failure onto the disconnect taxonomy — the same mapping Step and Roundtrip apply before returning. The app loop runs it on failures that surface outside the park (a frame's attach/commit on a dead socket), so every dispatch surface reports disconnects the same way.

func (*Session) Close

func (s *Session) Close()

Close disconnects from the display and releases the session's shared buffer arena: the pool proxy, mapping, and the session's one fd.

func (*Session) Closed

func (s *Session) Closed() bool

Closed reports whether Close ran.

func (*Session) ComposeBackspace

func (s *Session) ComposeBackspace() bool

ComposeBackspace unwinds one level of an in-flight sequence, reporting whether anything was pending. The caller consumes the backspace either way when a sequence was in flight — the widget must not delete text for it — and passes it through when none was.

func (*Session) ComposePending

func (s *Session) ComposePending() bool

ComposePending reports whether a compose sequence is in flight.

func (*Session) Compositor

func (s *Session) Compositor() *wl.Compositor

Compositor returns the bound wl_compositor.

func (*Session) ConfinePointer

func (s *Session) ConfinePointer(surf *wl.Surface, region []image.Rectangle, persistent bool) (*PointerConstraint, error)

ConfinePointer keeps the pointer inside region (surface rects; nil is the whole surface) while it is in surf.

func (*Session) CursorTheme

func (s *Session) CursorTheme() (name string, size uint32, err error)

CursorTheme reports the xcursor theme the session resolves pointer shapes from: the theme's name and nominal size, as the environment names them. Without a shm global no theme can draw, and the error says so.

func (*Session) DataDevice

func (s *Session) DataDevice() *wl.DataDevice

DataDevice returns the seat's data device, or nil before both the manager and the seat are bound.

func (*Session) DataDeviceManager

func (s *Session) DataDeviceManager() *wl.DataDeviceManager

DataDeviceManager returns the bound wl_data_device_manager, or nil when the compositor does not provide it; clipboard support needs it.

func (*Session) DataDeviceVersion

func (s *Session) DataDeviceVersion() uint32

DataDeviceVersion returns the negotiated wl_data_device_manager version: three and above have the dnd action requests and events (set_actions, finish), below that drags run in the v1 subset.

func (*Session) DecorationManager

func (s *Session) DecorationManager() *deco.ZxdgDecorationManagerV1

DecorationManager returns the bound xdg-decoration manager, or nil when the compositor does not provide it; server-side window decorations need it.

func (*Session) DialogManager

func (s *Session) DialogManager() *wlr.WmDialogV1

DialogManager returns the bound xdg_wm_dialog_v1 manager, or nil when the compositor does not advertise the protocol; a nil manager makes every dialog-modality hint a no-op, and modality falls back to the application-level block.

func (*Session) Dmabuf

func (s *Session) Dmabuf() *wlr.ZwpDmabufV1

Dmabuf returns the bound zwp_linux_dmabuf_v1 (version 2 or later), or nil.

func (*Session) DmabufDevice

func (s *Session) DmabufDevice() (dev uint64, ok bool)

DmabufDevice is the compositor's main device, the dev_t of the DRM node whose memory it imports buffers from; ok is false where the compositor names none (linux-dmabuf before v4).

func (*Session) DmabufImports

func (s *Session) DmabufImports(l DmabufLayout) bool

DmabufImports reports whether the compositor advertised the layout; importing any other is a fatal protocol error.

func (*Session) DmabufModifiers

func (s *Session) DmabufModifiers(format fourcc.Format) []fourcc.Modifier

DmabufModifiers lists, sorted, the explicit modifiers the compositor imports format in (fourcc.Invalid, an implicit layout, left out).

func (*Session) Exporter

func (s *Session) Exporter() *wlr.ZxdgExporterV2

Exporter returns the bound zxdg_exporter_v2, or nil when the compositor does not advertise xdg-foreign v2.

func (*Session) ExtDataControlManager

func (s *Session) ExtDataControlManager() *wlr.DataControlManagerV1

ExtDataControlManager returns the bound ext_data_control_manager_v1, nil when the compositor lacks it.

func (*Session) FeedCompose

func (s *Session) FeedCompose(sym xkb.Keysym) (compose.Result, string)

FeedCompose advances the compose machine by the keysym of a key press, answering pending, done-with-text, or none. None means the keysym takes no part in compose and normal text handling should proceed; a sequence that was in flight has been cancelled by then.

func (*Session) ForeignToplevelAvailable

func (s *Session) ForeignToplevelAvailable() bool

ForeignToplevelAvailable reports whether the compositor advertised zwlr_foreign_toplevel_manager_v1. When false, Toplevels stays empty and every toplevel request is a no-op.

func (*Session) FractionalScaleManager

func (s *Session) FractionalScaleManager() *wlr.WpScaleManagerV1

FractionalScaleManager returns the bound wp_fractional_scale_manager_v1, or nil when the compositor does not provide it; without it there are no preferred_scale events and surfaces keep their integer scale.

func (*Session) GlobalShortcutsManager

func (s *Session) GlobalShortcutsManager() *wlr.GlobalShortcutsManagerV1

GlobalShortcutsManager returns the bound manager, nil when the compositor lacks it.

func (*Session) Globals

func (s *Session) Globals() map[string]uint32

Globals returns a copy of the bound wayland globals mapped to the registry version each was advertised with.

func (*Session) HandleDataDeviceDrop

func (s *Session) HandleDataDeviceDrop(wl.DataDeviceDropEvent)

HandleDataDeviceDrop implements wl.DataDeviceDropHandler.

func (*Session) HandleDataDeviceEnter

func (s *Session) HandleDataDeviceEnter(ev wl.DataDeviceEnterEvent)

HandleDataDeviceEnter implements wl.DataDeviceEnterHandler: a drag entered a surface; route it to that surface's drop handler.

func (*Session) HandleDataDeviceLeave

func (s *Session) HandleDataDeviceLeave(wl.DataDeviceLeaveEvent)

HandleDataDeviceLeave implements wl.DataDeviceLeaveHandler: the drag ended over every surface. The event names no surface, so every registered handler hears it; only the one holding a drag acts.

func (*Session) HandleDataDeviceMotion

func (s *Session) HandleDataDeviceMotion(ev wl.DataDeviceMotionEvent)

HandleDataDeviceMotion implements wl.DataDeviceMotionHandler.

func (*Session) HandleDisplayError

func (s *Session) HandleDisplayError(ev wl.DisplayErrorEvent)

HandleDisplayError implements wl.DisplayErrorHandler: record the compositor's fatal protocol error so the dispatch failure that ends the run names the compositor's verdict, trace it, and report it at Error on the injected logger — a protocol error is terminal: the connection is dead, and reconnecting would replay the fatal exchange. Registered in Connect; a closed connection without an error event leaves protoErr nil, which is itself diagnostic (the compositor dropped us without saying why).

func (*Session) HandleKeyboardEnter

func (s *Session) HandleKeyboardEnter(ev wl.KeyboardEnterEvent)

HandleKeyboardEnter implements wl.KeyboardEnterHandler: the named surface receives keyboard input until a leave or another enter.

func (*Session) HandleKeyboardKey

func (s *Session) HandleKeyboardKey(ev wl.KeyboardKeyEvent)

HandleKeyboardKey implements wl.KeyboardKeyHandler.

func (*Session) HandleKeyboardKeymap

func (s *Session) HandleKeyboardKeymap(ev wl.KeyboardKeymapEvent)

HandleKeyboardKeymap implements wl.KeyboardKeymapHandler: the keymap fd is mapped (keymapfd.Read), compiled, and closed on the background goroutine, with the loop free to draw meanwhile.

Key codes mean what the latest keymap says, so what follows this event on the wire must not be read through the one before it, and the old keymap is still what applies to everything before it. Every keyboard event arriving before the compile ends therefore waits behind it, in wire order (enter, leave, key, modifiers, the seat's loss of the keyboard), and is delivered when the keymap is installed: late, never lost, never mistranslated. Keymaps in a row install in turn, each with the events that belong to it. A keymap that fails to compile leaves keys untranslated, as dropKeymap says. Synthesized repeats hold off while KeymapPending reports true.

func (*Session) HandleKeyboardLeave

func (s *Session) HandleKeyboardLeave(wl.KeyboardLeaveEvent)

HandleKeyboardLeave implements wl.KeyboardLeaveHandler.

func (*Session) HandleKeyboardModifiers

func (s *Session) HandleKeyboardModifiers(ev wl.KeyboardModifiersEvent)

HandleKeyboardModifiers implements wl.KeyboardModifiersHandler.

func (*Session) HandleKeyboardRepeatInfo

func (s *Session) HandleKeyboardRepeatInfo(ev wl.KeyboardRepeatInfoEvent)

HandleKeyboardRepeatInfo implements wl.KeyboardRepeatInfoHandler: the compositor's rate (keys per second) and delay (milliseconds).

func (*Session) HandlePointerAxis

func (s *Session) HandlePointerAxis(ev wl.PointerAxisEvent)

HandlePointerAxis implements wl.PointerAxisHandler: the axis value of this frame accumulates per axis and the frame routes it (a seat before version 5 has no frames, so it routes at once). Scrolling follows the grab while dragging.

func (*Session) HandlePointerAxisDiscrete

func (s *Session) HandlePointerAxisDiscrete(ev wl.PointerAxisDiscreteEvent)

HandlePointerAxisDiscrete implements wl.PointerAxisDiscreteHandler (seats 5-7): wheel notches, counted as 120 units each like axis_value120.

func (*Session) HandlePointerAxisSource

func (s *Session) HandlePointerAxisSource(ev wl.PointerAxisSourceEvent)

HandlePointerAxisSource implements wl.PointerAxisSourceHandler: what the frame's scroll comes from.

func (*Session) HandlePointerAxisStop

func (s *Session) HandlePointerAxisStop(wl.PointerAxisStopEvent)

HandlePointerAxisStop implements wl.PointerAxisStopHandler. The stop lands in the next frame (seats 5+); an older seat has no frames and no stop.

func (*Session) HandlePointerAxisValue120

func (s *Session) HandlePointerAxisValue120(ev wl.PointerAxisValue120Event)

HandlePointerAxisValue120 implements wl.PointerAxisValue120Handler (seats 8+): wheel clicks per axis, one click 120 units, signed as the axis is (positive down or right).

func (*Session) HandlePointerButton

func (s *Session) HandlePointerButton(ev wl.PointerButtonEvent)

HandlePointerButton implements wl.PointerButtonHandler: routed like motion, and a press opens the client-side implicit grab so drags keep feeding the pressed surface after the pointer leaves it. A release ends the grab.

func (*Session) HandlePointerEnter

func (s *Session) HandlePointerEnter(ev wl.PointerEnterEvent)

HandlePointerEnter implements wl.PointerEnterHandler: the pointer gained focus on ev.Surface. The enter is routed to that surface's handler and becomes the motion target until a leave or grab says otherwise.

func (*Session) HandlePointerFrame

func (s *Session) HandlePointerFrame(wl.PointerFrameEvent)

HandlePointerFrame implements wl.PointerFrameHandler: routes the frame's scroll. Wheel notches (axis_discrete, or axis_value120) go out as whole steps, several in one frame being the wheel's acceleration; finger and continuous scrolling goes out as exact pixels to a handler that takes them (SurfacePreciseScroller), the rest as plain axis motion.

func (*Session) HandlePointerLeave

func (s *Session) HandlePointerLeave(ev wl.PointerLeaveEvent)

HandlePointerLeave implements wl.PointerLeaveHandler: pointer focus left ev.Surface. A leave always ends the client-side grab: the compositor only strips focus when the pointer truly left or the grabbing input device went away.

func (*Session) HandlePointerMotion

func (s *Session) HandlePointerMotion(ev wl.PointerMotionEvent)

HandlePointerMotion implements wl.PointerMotionHandler: routed to the grabbed surface during a drag, else the focused surface.

func (*Session) HandleRegistryGlobal

func (s *Session) HandleRegistryGlobal(ev wl.RegistryGlobalEvent)

HandleRegistryGlobal implements wl.RegistryGlobalHandler: record the global and bind what we need immediately.

func (*Session) HandleRegistryGlobalRemove

func (s *Session) HandleRegistryGlobalRemove(ev wl.RegistryGlobalRemoveEvent)

HandleRegistryGlobalRemove implements wl.RegistryGlobalRemoveHandler: drop the global and, for outputs, run the hotplug hook so hosts on that output can tear themselves down.

func (*Session) HandleSeatCapabilities

func (s *Session) HandleSeatCapabilities(ev wl.SeatCapabilitiesEvent)

HandleSeatCapabilities implements wl.SeatCapabilitiesHandler. The set arrives at bind time and again whenever it changes — a USB mouse unplugged, a keyboard switched, libinput re-probing. The pointer and keyboard objects track it: when a capability disappears the compositor destroys the matching object, so the stale proxy is released and dropped, and a fresh one is created on the next gain, or input goes silent after an unplug-replug.

func (*Session) HandleSeatName

func (s *Session) HandleSeatName(wl.SeatNameEvent)

HandleSeatName implements wl.SeatNameHandler.

func (*Session) HandleShmFormat

func (s *Session) HandleShmFormat(ev wl.ShmFormatEvent)

HandleShmFormat implements wl.ShmFormatHandler.

func (*Session) HandleTouchCancel

func (s *Session) HandleTouchCancel(wl.TouchCancelEvent)

HandleTouchCancel implements wl.TouchCancelHandler.

func (*Session) HandleTouchDown

func (s *Session) HandleTouchDown(ev wl.TouchDownEvent)

HandleTouchDown implements wl.TouchDownHandler: the contact belongs to the surface it landed on until it lifts.

func (*Session) HandleTouchFrame

func (s *Session) HandleTouchFrame(wl.TouchFrameEvent)

HandleTouchFrame implements wl.TouchFrameHandler: contacts are handled as their events arrive.

func (*Session) HandleTouchMotion

func (s *Session) HandleTouchMotion(ev wl.TouchMotionEvent)

HandleTouchMotion implements wl.TouchMotionHandler.

func (*Session) HandleTouchOrientation

func (s *Session) HandleTouchOrientation(wl.TouchOrientationEvent)

HandleTouchOrientation implements wl.TouchOrientationHandler.

func (*Session) HandleTouchShape

func (s *Session) HandleTouchShape(wl.TouchShapeEvent)

HandleTouchShape implements wl.TouchShapeHandler.

func (*Session) HandleTouchUp

func (s *Session) HandleTouchUp(ev wl.TouchUpEvent)

HandleTouchUp implements wl.TouchUpHandler.

func (*Session) HandleWmBasePing

func (s *Session) HandleWmBasePing(ev xdg.WmBasePingEvent)

HandleWmBasePing implements xdg.WmBasePingHandler: the compositor is asking whether the client is alive, and a client that does not pong is treated as hung (Hyprland raises its not-responding dialog over it). The answer goes out from the dispatch itself, so it only fails to arrive when the loop really is stuck.

func (*Session) HandleZwlrForeignToplevelManagerV1Finished

func (s *Session) HandleZwlrForeignToplevelManagerV1Finished(wlr.ZwlrForeignToplevelManagerV1FinishedEvent)

HandleZwlrForeignToplevelManagerV1Finished implements wlr.ZwlrForeignToplevelManagerV1FinishedHandler: the compositor stopped the stream (only after our own stop request), so no further toplevels will arrive.

func (*Session) HandleZwlrForeignToplevelManagerV1Toplevel

func (s *Session) HandleZwlrForeignToplevelManagerV1Toplevel(ev wlr.ZwlrForeignToplevelManagerV1ToplevelEvent)

HandleZwlrForeignToplevelManagerV1Toplevel implements wlr.ZwlrForeignToplevelManagerV1ToplevelHandler: a toplevel exists; start tracking it.

func (*Session) HandleZwpInputV3CommitString

func (s *Session) HandleZwpInputV3CommitString(ev text.ZwpInputV3CommitStringEvent)

HandleZwpInputV3CommitString implements text.ZwpInputV3CommitStringHandler.

func (*Session) HandleZwpInputV3DeleteSurroundingText

func (s *Session) HandleZwpInputV3DeleteSurroundingText(ev text.ZwpInputV3DeleteSurroundingTextEvent)

HandleZwpInputV3DeleteSurroundingText implements text.ZwpInputV3DeleteSurroundingTextHandler.

func (*Session) HandleZwpInputV3Done

func (s *Session) HandleZwpInputV3Done(ev text.ZwpInputV3DoneEvent)

HandleZwpInputV3Done implements text.ZwpInputV3DoneHandler: the pending batch is now current; hand it to the host in application order and report whether the serial matched our commits.

func (*Session) HandleZwpInputV3Enter

func (s *Session) HandleZwpInputV3Enter(text.ZwpInputV3EnterEvent)

HandleZwpInputV3Enter implements text.ZwpInputV3EnterHandler: the surface gained text-input focus. Enter (like leave) invalidates all committed state, so the host must re-push it for the new surface.

func (*Session) HandleZwpInputV3Leave

func (s *Session) HandleZwpInputV3Leave(text.ZwpInputV3LeaveEvent)

HandleZwpInputV3Leave implements text.ZwpInputV3LeaveHandler.

func (*Session) HandleZwpInputV3PreeditString

func (s *Session) HandleZwpInputV3PreeditString(ev text.ZwpInputV3PreeditStringEvent)

HandleZwpInputV3PreeditString implements text.ZwpInputV3PreeditStringHandler: buffer the composing text until done applies it.

func (*Session) HandleZwpRelativePointerV1Motion

func (s *Session) HandleZwpRelativePointerV1Motion(ev wlr.ZwpRelativePointerV1MotionEvent)

HandleZwpRelativePointerV1Motion routes relative motion to the pointer's surface.

func (*Session) HandleZwpTabletSeatV2ToolAdded

func (s *Session) HandleZwpTabletSeatV2ToolAdded(ev wlr.ZwpTabletSeatV2ToolAddedEvent)

HandleZwpTabletSeatV2ToolAdded wires a new tool's events.

func (*Session) IconSizesReported

func (s *Session) IconSizesReported() bool

IconSizesReported reports whether the manager's size list completed.

func (*Session) IdleInhibitAvailable

func (s *Session) IdleInhibitAvailable() bool

IdleInhibitAvailable reports whether the compositor advertised zwp_idle_inhibit_manager_v1.

func (*Session) IdleNotify

func (s *Session) IdleNotify(timeout time.Duration, inputOnly bool) (*IdleNotification, error)

IdleNotify watches the seat for timeout of idleness. inputOnly (the protocol's v2) counts only real input, ignoring idle inhibitors - a presence indicator wants that; a dim-the-screen policy wants the default, which honors them. Fails when the protocol is unavailable.

func (*Session) IdleNotifyAvailable

func (s *Session) IdleNotifyAvailable() bool

IdleNotifyAvailable reports whether the compositor offers idle notification.

func (*Session) InhibitIdle

func (s *Session) InhibitIdle(surface *wl.Surface) (*IdleInhibitor, error)

InhibitIdle creates an inhibitor for surface: while the surface is visible, the compositor will not idle or suspend. The handle must be destroyed when the activity ends. Fails with ErrIdleInhibitUnavailable when the compositor lacks the protocol.

func (*Session) InhibitShortcuts

func (s *Session) InhibitShortcuts(surface *wl.Surface, seat *wl.Seat) (*ShortcutsInhibitor, error)

InhibitShortcuts creates an inhibitor that suppresses the compositor's shortcuts for surface while the seat's keyboard focus is on it. Fails with ErrShortcutsInhibitUnavailable when the compositor lacks the protocol.

func (*Session) InputSerial

func (s *Session) InputSerial() uint32

InputSerial returns the serial of the latest user input event the seat delivered to this client: a pointer button press, key press, touch down, or tablet tool down or button press, on any surface. It is the serial requests anchored to a user action carry (popup grabs, interactive move and resize, set_selection, activation tokens), and 0 before any such event.

func (*Session) Inspect

func (s *Session) Inspect() InspectInfo

Inspect snapshots the session for diagnostics.

func (*Session) KeySym

func (s *Session) KeySym(code uint32) xkb.Keysym

KeySym translates an evdev keycode to its primary keysym under the current state; KeyNoSymbol when there is no keymap.

func (*Session) KeyUTF8

func (s *Session) KeyUTF8(code uint32) string

KeyUTF8 translates an evdev keycode through the compositor's keymap and returns the text it produces with the current modifiers (shift, AltGr, layout). Empty when no keymap arrived or the key types nothing, which holds for Return, Tab, Backspace, Escape and Ctrl chords: their control characters are actions, handled through KeySym. Keycodes need the +8 evdev-to-xkb offset.

func (*Session) KeyboardFocus

func (s *Session) KeyboardFocus() *wl.Surface

KeyboardFocus returns the surface currently holding keyboard input, or nil when the compositor gives the seat no keyboard focus.

func (*Session) KeymapPending added in v0.2.5

func (s *Session) KeymapPending() bool

KeymapPending reports whether a keymap the compositor sent is still on its way: keys read now would go through the one it replaces.

func (*Session) LayerShell

func (s *Session) LayerShell() *wlr.ZwlrLayerShellV1

LayerShell returns the bound zwlr_layer_shell_v1.

func (*Session) LayerShellVersion

func (s *Session) LayerShellVersion() uint32

LayerShellVersion is the bound zwlr_layer_shell_v1 version, 0 when the compositor has none.

func (*Session) LockPointer

func (s *Session) LockPointer(surf *wl.Surface, persistent bool) (*PointerConstraint, error)

LockPointer locks the pointer in place while it is in surf; motion then arrives only as relative motion. persistent keeps the lock for every return of the pointer; otherwise it ends with its first deactivation.

func (*Session) Locks

func (s *Session) Locks() Locks

Locks returns which lock keys are on. It reads all off until the compositor has sent a keymap and a modifiers event.

func (*Session) Mods

func (s *Session) Mods() Mods

Mods returns the currently held modifiers (shift, ctrl, alt, super); locks such as Caps and Num Lock are not held keys.

func (*Session) Outputs

func (s *Session) Outputs() []*Output

Outputs returns the bound outputs in registry order.

func (*Session) PointerConstraintsAvailable

func (s *Session) PointerConstraintsAvailable() bool

PointerConstraintsAvailable reports whether the compositor offers pointer constraints.

func (*Session) PreferredIconSizes

func (s *Session) PreferredIconSizes() []int

PreferredIconSizes returns the sizes the compositor asked window icons to be rasterized at (its icon_size events, sorted), complete once IconSizesReported is true. Without the protocol the list is empty and callers pick their own sizes.

func (*Session) Presentation

func (s *Session) Presentation() *wlr.WpPresentation

Presentation returns the bound wp_presentation, or nil when the compositor does not provide it.

func (*Session) PrimarySelectionAvailable

func (s *Session) PrimarySelectionAvailable() bool

PrimarySelectionAvailable reports whether the compositor advertised zwp_primary_selection_device_manager_v1 and the seat's device is bound. When false, every primary-selection call on the session is a no-op and the clipboard runs exactly as without the protocol.

func (*Session) PrimarySelectionDevice

func (s *Session) PrimarySelectionDevice() *wlr.ZwpPrimarySelectionDeviceV1

PrimarySelectionDevice returns the seat's primary selection device, nil without the protocol.

func (*Session) PrimarySelectionManager

func (s *Session) PrimarySelectionManager() *wlr.ZwpPrimarySelectionDeviceManagerV1

PrimarySelectionManager returns the bound primary selection device manager, or nil when the compositor does not provide it; primary selection support needs it.

func (*Session) RelativePointerAvailable

func (s *Session) RelativePointerAvailable() bool

RelativePointerAvailable reports whether the compositor offers relative pointer motion.

func (*Session) RepeatInfo

func (s *Session) RepeatInfo() (rate, delayMs uint32)

RepeatInfo returns the compositor's key repeat rate in keys per second and the initial delay in milliseconds. Zeros mean the compositor sent no repeat info; callers fall back to their own defaults.

func (*Session) RequestActivationToken

func (s *Session) RequestActivationToken(surface *wl.Surface, serial uint32, done func(token string, err error))

RequestActivationToken begins a token request anchored to the user-interaction serial of a pointer press or keyboard event (0 means unanchored, which compositors may refuse to honor with focus). done always runs once: with the issued token - each request its own, so concurrent requests (a launch, an attention request) never trade tokens - or with ErrActivationUnavailable without the protocol, or the request's failure.

func (*Session) Roundtrip

func (s *Session) Roundtrip() error

Roundtrip issues a display sync and dispatches until it completes. It waits on its own callback's done handler, so a handler it dispatches may roundtrip too (a popup opened from a press that arrived while another popup awaited its configure): the nested roundtrip dispatching this one's done still ends this wait. Each dispatch is a Step, so destroyed proxies and dead connections are handled as Step handles them.

func (*Session) Seat

func (s *Session) Seat() *wl.Seat

Seat returns the bound wl_seat, or nil when the compositor has none.

func (*Session) SessionLockManager

func (s *Session) SessionLockManager() *wlr.SessionLockManagerV1

SessionLockManager returns the bound ext_session_lock_manager_v1, nil when the compositor does not offer it.

func (*Session) SetBlurRegion

func (s *Session) SetBlurRegion(surf *wl.Surface, rects []render.Rect) error

SetBlurRegion asks the compositor to blur what is behind rects (surface-local, logical pixels) of surf; no rects removes the effect. It applies on the surface's next commit.

func (*Session) SetContentType

func (s *Session) SetContentType(surf *wl.Surface, ct ContentType) error

SetContentType hints surf's content kind; it applies on the surface's next commit.

func (*Session) SetCursor

func (s *Session) SetCursor(name string) error

SetCursor shows the named xcursor shape (CursorLeftPtr, "xterm", "grabbing", ...) on the pointer. Window-edge interactions can use the toolkit aliases - "resize_e", "resize_nw", the CSS spellings ("ns-resize", "e-resize", ...) - which resolve to the shapes the loaded theme actually carries and degrade to the arrow when it has none. Animated shapes (watch, left_ptr_watch) advance their frames on a timer for as long as they show. CursorHidden ("none") hides the pointer. The choice sticks across pointer enters; "" or an unknown name falls back to the arrow. It is a no-op before the pointer or the compositor surfaces exist.

func (*Session) SetDeadline added in v0.2.5

func (s *Session) SetDeadline(at time.Time)

SetDeadline is the loop's one timer: a loop parked in Step returns at at, replacing whatever at the last call named, and a zero at means none. Setting the same instant again costs nothing.

func (*Session) SetSurfaceAlpha

func (s *Session) SetSurfaceAlpha(surf *wl.Surface, alpha float64) error

SetSurfaceAlpha sets the opacity the compositor applies to surf (0..1) without the client repainting; it applies on the surface's next commit.

func (*Session) SetSurfaceDrop

func (s *Session) SetSurfaceDrop(surf *wl.Surface, h SurfaceDropHandler)

SetSurfaceDrop registers h as the receiver of drag-and-drop events targeting surf; h == nil unregisters. It mirrors SetSurfaceInput for the wl_data_device half of the input model.

func (*Session) SetSurfaceInput

func (s *Session) SetSurfaceInput(surf *wl.Surface, h SurfacePointerHandler)

SetSurfaceInput registers h as the receiver of pointer events targeting surf; h == nil unregisters. Handlers must be registered before the surface can receive input and removed when the surface is destroyed.

func (*Session) Shm

func (s *Session) Shm() *wl.Shm

Shm returns the bound wl_shm.

func (*Session) ShortcutsInhibitAvailable

func (s *Session) ShortcutsInhibitAvailable() bool

ShortcutsInhibitAvailable reports whether the compositor advertised zwp_keyboard_shortcuts_inhibit_manager_v1.

func (*Session) Stalled added in v0.2.5

func (s *Session) Stalled() (bool, error)

Stalled reports whether the compositor has left requests of an earlier pass unread, trying once more to write them: a frame committed now would only queue behind them. It never blocks, and a loop parked in Step wakes when the socket takes writes again.

func (*Session) Step

func (s *Session) Step() error

Step dispatches one event, blocking until one arrives, then every event already pending: those its read buffered and those one more non-blocking read brings in. It is the park point of an event-driven loop: with nothing to do, a loop calling Step holds no CPU and wakes only when the compositor sends something or a WakeAfter kick fires, and a burst of events costs the loop one pass, not one per event.

func (*Session) Subcompositor

func (s *Session) Subcompositor() *wl.Subcompositor

Subcompositor returns the bound wl_subcompositor, or nil.

func (*Session) SyncobjManager added in v0.2.5

func (s *Session) SyncobjManager() *wlr.WpDrmSyncobjManagerV1

SyncobjManager returns the bound wp_linux_drm_syncobj_manager_v1, or nil when the compositor takes no explicit synchronization.

func (*Session) TextInputAvailable

func (s *Session) TextInputAvailable() bool

TextInputAvailable reports whether the compositor advertised zwp_text_input_manager_v3 and the seat's text input is bound. When false, every text-input call on the session is a no-op and the keyboard path runs exactly as without IME support.

func (*Session) ToplevelIconManager

func (s *Session) ToplevelIconManager() *wlr.ToplevelIconManagerV1

ToplevelIconManager returns the bound xdg_toplevel_icon_manager_v1, or nil when the compositor does not advertise the protocol; a nil manager makes every window-icon request a no-op and the icon stays the compositor's default.

func (*Session) Toplevels

func (s *Session) Toplevels() []*Toplevel

Toplevels returns the windows the compositor currently advertises, in arrival order. The slice is the session's live view: entries disappear on closed, and their contents update on the dispatch goroutine.

func (*Session) UpdateIME

func (s *Session) UpdateIME(st IMEState)

UpdateIME pushes one atomic state update: enable or disable plus the surrounding text and caret rectangle, applied atomically by a commit request. No-op without the protocol.

func (*Session) Viewporter

func (s *Session) Viewporter() *wlr.WpViewporter

Viewporter returns the bound wp_viewporter, or nil when the compositor does not provide it; fractional scaling degrades to integer set_buffer_scale without it.

func (*Session) WakeAfter

func (s *Session) WakeAfter(d time.Duration)

WakeAfter arranges for a loop parked in Step to return by waiting d, through the socket's read deadline: no request reaches the compositor, no goroutine waits, and Step returning is the whole cost. Safe from any goroutine; after Close it does nothing.

func (*Session) WatchDmabufFeedback added in v0.2.12

func (s *Session) WatchDmabufFeedback(surface *wl.Surface, update func(dmabufwl.Feedback, error)) (*dmabufwl.SurfaceFeedback, error)

WatchDmabufFeedback follows surface's linux-dmabuf feedback, calling update on the loop with the first feedback and each one the compositor sends after it. It is nil, with no error, where the compositor sends no feedback (linux-dmabuf before v4, or none).

func (*Session) WatchOutputIdentity

func (s *Session) WatchOutputIdentity(fn func(*Output)) (stop func())

WatchOutputIdentity subscribes to output identities alongside the OnOutputIdentity hook: fn runs when an output's xdg-output name arrives or changes. The returned stop unsubscribes; it is idempotent. Watchers run on the event-loop goroutine, after the hook.

func (*Session) WatchOutputs

func (s *Session) WatchOutputs(added, removed func(*Output)) (stop func())

WatchOutputs subscribes to output hotplug alongside the OnOutputAdded/OnOutputRemoved hooks: added runs when a wl_output global appears, removed when it goes away (either may be nil). The returned stop unsubscribes; it is idempotent. Watchers run on the event-loop goroutine, inside dispatch, after the hooks.

func (*Session) WlrDataControlManager

func (s *Session) WlrDataControlManager() (*wlr.ZwlrDataControlManagerV1, uint32)

WlrDataControlManager returns the bound zwlr_data_control_manager_v1 and its bound version, nil and 0 when the compositor lacks it.

func (*Session) WmBase

func (s *Session) WmBase() *xdg.WmBase

WmBase returns the bound xdg_wm_base, or nil when the compositor does not provide it; window support needs it.

func (*Session) WmBaseVersion

func (s *Session) WmBaseVersion() uint32

WmBaseVersion is the bound xdg_wm_base version (popup repositioning needs 3); 0 without one.

func (*Session) XdgOutputAvailable

func (s *Session) XdgOutputAvailable() bool

XdgOutputAvailable reports whether the compositor advertised zxdg_output_manager_v1 at a version that carries names (2+). Without it the outputs' Name fields stay empty.

type ShortcutsInhibitor

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

ShortcutsInhibitor suppresses the compositor's own shortcuts while its surface has keyboard focus. The compositor activates the inhibitor when focus arrives and deactivates it when focus leaves; Active reports which. Destroy when the pane closes; Destroy is nil-safe and idempotent.

func (*ShortcutsInhibitor) Active

func (i *ShortcutsInhibitor) Active() bool

Active reports whether the inhibitor currently suppresses the compositor's shortcuts (the surface holds keyboard focus).

func (*ShortcutsInhibitor) Destroy

func (i *ShortcutsInhibitor) Destroy()

Destroy releases the inhibitor.

func (*ShortcutsInhibitor) HandleZwpShortcutsInhibitorV1Active

func (i *ShortcutsInhibitor) HandleZwpShortcutsInhibitorV1Active(wlr.ZwpShortcutsInhibitorV1ActiveEvent)

HandleZwpShortcutsInhibitorV1Active implements wlr.ZwpShortcutsInhibitorV1ActiveHandler: the surface gained keyboard focus and the shortcuts are suppressed.

func (*ShortcutsInhibitor) HandleZwpShortcutsInhibitorV1Inactive

func (i *ShortcutsInhibitor) HandleZwpShortcutsInhibitorV1Inactive(wlr.ZwpShortcutsInhibitorV1InactiveEvent)

HandleZwpShortcutsInhibitorV1Inactive implements wlr.ZwpShortcutsInhibitorV1InactiveHandler.

type SurfaceDropHandler

type SurfaceDropHandler interface {
	// HandleDragEnter reports a drag entering the surface: position in
	// surface coordinates, the enter serial (the one accept replies
	// with), and the offered data; a nil offer means no transfer.
	HandleDragEnter(x, y float64, serial uint32, offer *wl.DataOffer)
	// HandleDragMotion reports drag movement within the surface.
	HandleDragMotion(x, y float64)
	// HandleDragLeave reports the drag leaving without a drop.
	HandleDragLeave()
	// HandleDrop reports the drop; the payload transfers on request
	// through the offer afterward.
	HandleDrop()
}

SurfaceDropHandler receives the wl_data_device drag-and-drop events targeting one registered surface, with coordinates in that surface's logical space. The offer travels with the enter event; its advertised mime types are collected by whoever tracks the offer object (internal/dragdrop), leaving the selection bookkeeping of internal/clipboard untouched.

type SurfaceGestureHandler

type SurfaceGestureHandler interface {
	HandlePointerGesture(g PointerGesture)
}

SurfaceGestureHandler is a SurfacePointerHandler that takes touchpad gestures.

type SurfacePointerHandler

type SurfacePointerHandler interface {
	// HandlePointerEnter reports the pointer entering the surface.
	HandlePointerEnter(x, y float64)
	// HandlePointerMotion reports movement within the surface; while
	// a grab is active it may carry coordinates outside the surface.
	HandlePointerMotion(x, y float64)
	// HandlePointerButton reports a press or release: the wayland
	// button code, 1 pressed / 0 released, and the event serial.
	HandlePointerButton(button, state, serial uint32)
	// HandlePointerAxis reports scroll motion: dx from the horizontal
	// axis (tilt wheels, trackpads), dy from the vertical, both
	// positive right/down.
	HandlePointerAxis(dx, dy float64)
	// HandlePointerLeave reports the pointer leaving the surface.
	HandlePointerLeave()
}

SurfacePointerHandler receives the pointer events whose compositor focus belongs to one registered surface, with coordinates in that surface's logical space. Hosts and popup surfaces register one handler each, so multiple surfaces never fight over one callback.

type SurfacePreciseScroller

type SurfacePreciseScroller interface {
	HandlePointerScrollPixels(dx, dy float64)
}

SurfacePreciseScroller is a SurfacePointerHandler that takes finger and continuous scrolling as exact surface pixels (positive right/down) instead of axis motion: a touchpad scrolls by what the fingers moved, not in wheel steps.

type SurfaceRelativeHandler

type SurfaceRelativeHandler interface {
	HandleRelativeMotion(dx, dy, rawDX, rawDY float64)
}

SurfaceRelativeHandler is a SurfacePointerHandler that takes the device's relative motion: accelerated deltas, and the raw ones before pointer acceleration.

type SurfaceScrollEnder

type SurfaceScrollEnder interface {
	HandlePointerScrollEnd()
}

SurfaceScrollEnder is a SurfacePreciseScroller told when a finger scroll ends (wl_pointer.axis_stop): the fingers lifted, so a kinetic scroller may glide on from the gesture's velocity.

type SurfaceTabletHandler

type SurfaceTabletHandler interface {
	HandleTabletFrame(s TabletSample)
}

SurfaceTabletHandler is a SurfacePointerHandler that takes tablet tools.

type SurfaceTouchHandler

type SurfaceTouchHandler interface {
	HandleTouchDown(id int32, x, y float64, serial uint32)
	HandleTouchMotion(id int32, x, y float64)
	HandleTouchUp(id int32)
	// HandleTouchCancel ends every contact on the surface: the
	// compositor took the touch sequence over (a system gesture).
	HandleTouchCancel()
}

SurfaceTouchHandler is a SurfacePointerHandler that takes touch: contact id, surface-local logical coordinates.

type TabletSample

type TabletSample struct {
	Tool TabletTool
	X, Y float64
	// Pressure and Distance are normalized to 0..1; TiltX/TiltY and
	// Rotation are degrees.
	Pressure, Distance float64
	TiltX, TiltY       float64
	Rotation           float64
	// Down and Up mark the tip touching or leaving the surface this
	// frame; ProximityIn/Out the tool entering or leaving range.
	Down, Up                  bool
	ProximityIn, ProximityOut bool
	// Button is a stylus button that changed this frame (0: none),
	// Pressed its new state.
	Button  uint32
	Pressed bool
	// Serial is the frame's input serial (the down's, or proximity's).
	Serial uint32
}

TabletSample is one tool frame: where the tool is (surface-local logical coordinates) and its axes, plus what changed this frame.

type TabletTool

type TabletTool uint8

TabletTool is a tool's physical kind.

const (
	ToolPen TabletTool = iota
	ToolEraser
	ToolBrush
	ToolPencil
	ToolAirbrush
	ToolFinger
	ToolMouse
	ToolLens
)

Tablet tools, the protocol's types.

type Toplevel

type Toplevel struct {
	// Title and AppID are the window's current title and application
	// id.
	Title string
	AppID string

	// State flags from the latest state batch.
	Maximized, Minimized, Activated, Fullscreen bool
	// contains filtered or unexported fields
}

Toplevel is one remote window the compositor advertises through the foreign-toplevel protocol. Its fields track the latest batch the compositor sent (a done event applies title, app-id, and state together); requests go through the methods, which are no-ops when the compositor lacks the protocol.

func (*Toplevel) Activate

func (t *Toplevel) Activate()

Activate asks the compositor to focus the window, using the seat bound at request time. No-op without the protocol.

func (*Toplevel) Close

func (t *Toplevel) Close()

Close asks the compositor to close the window. No-op without the protocol.

func (*Toplevel) SetMaximized

func (t *Toplevel) SetMaximized()

SetMaximized asks the compositor to maximize the window. No-op without the protocol.

func (*Toplevel) SetMinimized

func (t *Toplevel) SetMinimized()

SetMinimized asks the compositor to minimize the window. No-op without the protocol.

func (*Toplevel) UnsetMaximized

func (t *Toplevel) UnsetMaximized()

UnsetMaximized asks the compositor to leave the maximized state. No-op without the protocol.

func (*Toplevel) UnsetMinimized

func (t *Toplevel) UnsetMinimized()

UnsetMinimized asks the compositor to leave the minimized state. No-op without the protocol.

Jump to

Keyboard shortcuts

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