Documentation
¶
Overview ¶
Package app owns the shared event loop: buffer pooling, input routing into the widget tree, frame-callback pacing, and idle dispatch. A Host abstracts over layer surfaces and toplevel windows so either can carry a widget tree.
Threading: all widget and callback work runs on the loop goroutine; other goroutines reach the loop only through Application.Invoke and Application.Every. The contract and the relm4 mapping are in docs/threading.md.
Application runs many windows — toplevels and layer surfaces — on one session and one parked event loop. It is lys-ui's counterpart of relm4's Application/Window model (see docs/application-model.md): the process owns one connection, windows are created declaratively, and every window joins the same parked loop with its own dirty state, frame pacing, and tooltip bookkeeping.
The application side of the AT-SPI bridge (#65, #114): the application is the bridge's Scene - window roots, the focused widget of the topmost window, AT-driven focus, and the loop queue - and Run starts serving the semantic model on the accessibility bus when the desktop asks for assistive technologies (A11yAuto, the default).
Data control: the clipboard-manager protocols, for apps that watch or own the seat's selections without a focused window — a clipboard history, a bar's clipboard indicator, a remote-desktop bridge. See internal/datacontrol for the protocol side.
Compositor disconnect policy. When the connection dies (compositor crash, reload, upgrade), the session surfaces one typed DisconnectError (internal/wlsession); this file turns that into the application's story: fire OnDisconnect exactly once, tear every child down — window pools, then the session's arena and display — and exit the loop with an error callers can match. The sanctioned default is a clean exit with the distinct DisconnectExitCode so a supervisor (systemd Restart=on-failure, a wayle supervisor) respawns on the restarted session; SetReconnect (reconnect.go) rebuilds on the new session instead.
Drag and drop glue: the press+motion gesture that turns a widget's declared content into a wl_data_device start_drag, the routing of data-device events into the widget tree, and the drag icon snapshot. The wire-level state machine lives in internal/dragdrop.
Global shortcuts over hyprland-global-shortcuts-v1 (#87: or the freedesktop GlobalShortcuts portal, whichever the desktop offers): actions the compositor binds to keys and reports back, for apps with no focused window (a push-to-talk daemon, a capture watcher).
Global shortcuts over the freedesktop GlobalShortcuts portal: the xdg-desktop-portal transport that works on every portal desktop, chosen when the compositor offers no hyprland_global_shortcuts_v1 manager. The portal's bind flow is interactive - the desktop shows its shortcut-binding dialog and the user confirms - so it runs on a worker and a portal registration answers after that confirmation (denial comes back as ErrGlobalShortcutDenied). Triggers arrive as Activated and Deactivated signals and dispatch onto the loop goroutine like every other event.
Input method bridge: the session's zwp_text_input_v3 batches feed the focused editable widget, and widget edits push surrounding text and the caret rectangle back. Everything is a no-op on compositors without the protocol.
The inspector hookup: key chords, application state, and per-window overlay application. The overlay itself lives in internal/inspect; this file decides when it paints and what the chords do. The chords fire only while the inspector is armed - LYS_UI_INSPECT=1 at startup or an explicit SetInspect/ToggleInspect - so an app that never asks for the inspector keeps ctrl+shift+i and ctrl+shift+d to itself.
Primary selection behavior: middle-click paste at the caret and X11-style copy-on-select, layered on the clipboard's primary selection (zwp_primary_selection_unstable_v1 where the compositor offers it).
Reconnect-with-rebuild (#117): a compositor restart kills the connection and every object on it, but none of the application's own state - widget trees, Invoke/Every queues, accelerators, the windows' declarative configs. With SetReconnect, a lost connection tears down what was wire-owned, dials the compositor again, and rebuilds every window the application opened itself on the new session, keeping every *Window and *LayerWindow handle valid. A panel keeps its scroll positions, expanded sections, and typed text across a sway reload.
Interactive resize: edge hit-testing against the window's own bounds, the resize_* cursor shapes for edge hover, and the xdg_toplevel.resize grab on edge presses. Layer surfaces have no edges; server-decorated windows leave the edges to the compositor.
hostWindow is one hosted widget tree inside a running loop: the per-window bookkeeping (router, buffer pool, frame pacing, dirty state, tooltips) shared by the single-window Run convenience and the multi-window Application. It implements the wlsession pointer handler for its surface through surfaceInput.
Frames are damage-tracked: widgets invalidated since the last frame (widget.CollectDamage) define the repaint region, painting is clipped to it, and only that region goes out as wl_surface.damage_buffer. The pool's stale bookkeeping keeps partial repaints correct when the acquired buffer's content is older than the last frame; a fresh, resized, or rescaled buffer is fully stale and falls back to a full repaint.
Coordinates: the widget tree lives in logical (surface) pixels end to end - layout, input routing, popovers, IME rects. The device scale (frac120, 120-based; 240 is 2x, 150 is 1.25) appears only in buffer sizes, the paint canvas, and the damage rects sent on the wire.
Window icons through the optional xdg-toplevel-icon-v1 protocol (#70): SetWindowIcon posts a per-window icon, SetIcon an application-wide default, both rasterized into square shm buffers at the sizes the compositor asked for (its icon_size events; a fixed ladder when it expressed none). The icon goes to the compositor or taskbar through the protocol - there is no WM_HINTS analog - and a compositor without the global gets a Debug note and no behavior change, never a failure.
Index ¶
- Constants
- Variables
- func AnchorAt(x, y int) widget.Boundser
- func AnchorRect(r render.Rect) widget.Boundser
- func Connect() (*wlsession.Session, error)
- func ExportPDF(path string, job PrintJob) error
- func Font(family string, sizePx float64) (*render.Typeface, error)
- func FontFallback(face *render.Typeface) *render.Chain
- func FontFamilies() ([]string, error)
- func FontVariant(base *render.Typeface, bold, italic bool) (*render.Typeface, error)
- func FontVariants(base *render.Typeface) widget.VariantFunc
- func FontVariantsOf(face render.Font) widget.VariantFunc
- func FontWeighted(family string, sizePx float64, weight int, italic bool) (*render.Typeface, error)
- func SetLogger(l *slog.Logger)
- func Trace(category, format string, args ...any)
- func UIFont(sizePx float64) (*render.Typeface, error)
- func UIMonoFont(sizePx float64) (*render.Typeface, error)
- type A11YOptions
- type A11yMode
- type AboutConfig
- type AboutCredit
- type Accel
- type AccelInfo
- type AdaptiveDialog
- type AdaptiveDialogConfig
- type Anchor
- type Application
- func (a *Application) A11yGeneration() uint64
- func (a *Application) AboutDialog(parent *Window, cfg AboutConfig) (*Dialog, error)
- func (a *Application) Accels() []AccelInfo
- func (a *Application) Accent() appearance.Accent
- func (a *Application) AdaptiveDialog(parent *Window, cfg AdaptiveDialogConfig) (*AdaptiveDialog, error)
- func (a *Application) AddAccel(keys string, action widget.Activatable) error
- func (a *Application) AddScopedAccel(scope widget.Widget, keys string, action widget.Activatable) error
- func (a *Application) AttachFontButton(parent *Window, b *widget.FontButton)
- func (a *Application) AttachHeader(win *Window, bar *widget.HeaderBar)
- func (a *Application) AttachSplitButton(host Host, b *widget.SplitButton, items []widget.MenuItem)
- func (a *Application) AttachTabView(scope widget.Widget, v *widget.TabView) error
- func (a *Application) BackgroundBlurAvailable() bool
- func (a *Application) Bell(host Host) error
- func (a *Application) CalendarDialog(parent *Window, initial widget.Date, onSelect func(widget.Date)) (*Dialog, error)
- func (a *Application) CancelDrag() bool
- func (a *Application) Clipboard() *Clipboard
- func (a *Application) ColorChooserDialog(parent *Window, initial render.Color, onColor func(render.Color)) (*Dialog, error)
- func (a *Application) ColorScheme() appearance.ColorScheme
- func (a *Application) ConfinePointer(host Host, region []render.Rect, persistent bool) (*PointerConstraint, error)
- func (a *Application) Contrast() appearance.Contrast
- func (a *Application) DataControl() (*DataControl, error)
- func (a *Application) DescribeAction(action widget.Activatable, section, title string)
- func (a *Application) DesktopFontSize() float64
- func (a *Application) EmojiChooser(host Host, onPick func(emoji string)) (*Popover, error)
- func (a *Application) EmojiChooserForEntry(host Host, target EmojiInserter) (*Popover, error)
- func (a *Application) Every(d time.Duration, fn func()) (cancel func())
- func (a *Application) Focused() widget.Widget
- func (a *Application) FontChooserDialog(parent *Window, cfg FontChooserConfig) (*Dialog, error)
- func (a *Application) ForgetImage(id render.ImageID)
- func (a *Application) GlobalShortcutsAvailable(done func(bool))
- func (a *Application) HeldMods() Mods
- func (a *Application) Hold() (release func())
- func (a *Application) IdleInhibitAvailable() bool
- func (a *Application) IdleNotifyAvailable() bool
- func (a *Application) Inhibit(flags InhibitFlags, reason string, done func(release func(), err error))
- func (a *Application) InhibitIdle(host Host) (func(), error)
- func (a *Application) Inspect() bool
- func (a *Application) Invoke(fn func())
- func (a *Application) KeySym(code uint32) xkb.Keysym
- func (a *Application) LockPointer(host Host, persistent bool) (*PointerConstraint, error)
- func (a *Application) LockSession(cfg SessionLockConfig) (*SessionLock, error)
- func (a *Application) Locks() Locks
- func (a *Application) MessageBox(parent *Window, title, text string, buttons []DialogButton) (*Dialog, error)
- func (a *Application) NewBar(cfg BarConfig) (*BarWindow, error)
- func (a *Application) NewDialog(parent DialogParent, cfg DialogConfig) (*Dialog, error)
- func (a *Application) NewLayer(cfg LayerConfig) (*LayerWindow, error)
- func (a *Application) NewOpenButton(parent *Window, cfg OpenButtonConfig) (*OpenButton, error)
- func (a *Application) NewWindow(cfg WindowConfig) (*Window, error)
- func (a *Application) Notify(title, body string, opts NotifyOptions)
- func (a *Application) OnAccentChange(fn func(appearance.Accent)) (off func())
- func (a *Application) OnColorSchemeChange(fn func(appearance.ColorScheme)) (off func())
- func (a *Application) OnContrastChange(fn func(appearance.Contrast)) (off func())
- func (a *Application) OnDesktopFontSizeChange(fn func(px float64)) (off func())
- func (a *Application) OnDisconnect(fn func(DisconnectedEvent))
- func (a *Application) OnIdle(timeout time.Duration, idle, resume func()) (stop func(), err error)
- func (a *Application) OnKey(fn func(r *widget.Router, keycode uint32, mods wlsession.Mods))
- func (a *Application) OnLocks(fn func(Locks)) (stop func())
- func (a *Application) OnReducedMotionChange(fn func(bool)) (off func())
- func (a *Application) OnRelativeMotion(host Host, fn func(dx, dy, rawDX, rawDY float64))
- func (a *Application) OnSessionStateChange(fn func(state SessionState, screensaver bool), done func(error))
- func (a *Application) OnStop(fn func()) (cancel func())
- func (a *Application) OpenFileDialog(parent *Window, cfg FileDialogConfig) (*Dialog, error)
- func (a *Application) OpenFilesDialog(parent *Window, cfg FileDialogConfig) (*Dialog, error)
- func (a *Application) OpenFolderDialog(parent *Window, cfg FileDialogConfig) (*Dialog, error)
- func (a *Application) OpenMenuPopover(host Host, cfg MenuPopoverConfig) (*MenuPopover, error)
- func (a *Application) OpenPath(path string)
- func (a *Application) OpenPopover(host Host, cfg PopoverConfig) (*Popover, error)
- func (a *Application) OpenURL(uri string)
- func (a *Application) OpenURLFromLink(href string)
- func (a *Application) PointerConstraintsAvailable() bool
- func (a *Application) PreferencesDialog(parent *Window, title string, view *widget.PreferencesView) (*PreferencesDialog, error)
- func (a *Application) Print(parent *Window, job PrintJob, done func(error))
- func (a *Application) ProgressDialog(parent *Window, title, text string, pulsing bool, onCancel func()) (*Dialog, *Progress, error)
- func (a *Application) PromptDialog(parent *Window, title, message, initial string, allowEmpty bool, ...) (*Dialog, error)
- func (a *Application) Quit()
- func (a *Application) ReducedMotion() bool
- func (a *Application) RegisterGlobalShortcut(id, appID, description, trigger string, on func(pressed bool, unixSec uint64), ...)
- func (a *Application) RelativePointerAvailable() bool
- func (a *Application) RemoveAccel(keys string) error
- func (a *Application) RequestActivationToken(done func(token string, err error))
- func (a *Application) RequestBackground(req BackgroundRequest, done func(BackgroundResult, error))
- func (a *Application) Roots() []widget.Widget
- func (a *Application) Run() error
- func (a *Application) SaveFileDialog(parent *Window, cfg SaveDialogConfig) (*Dialog, error)
- func (a *Application) ServeAccessibility(opts A11YOptions, done func(error))
- func (a *Application) Session() *wlsession.Session
- func (a *Application) SessionLock() *SessionLock
- func (a *Application) SessionLockAvailable() bool
- func (a *Application) SetAccessibility(mode A11yMode)
- func (a *Application) SetBackgroundStatus(message string, done func(error))
- func (a *Application) SetClipboard(c *clipboard.Clipboard)
- func (a *Application) SetCopyOnSelect(on bool)
- func (a *Application) SetFocus(w widget.Widget) error
- func (a *Application) SetIcon(img image.Image)
- func (a *Application) SetInspect(on bool)
- func (a *Application) SetPopupErrorHandler(fn func(err error))
- func (a *Application) SetReconnect(opts *ReconnectOptions)
- func (a *Application) SetSurfaceMotion(on bool)
- func (a *Application) SetToastHost(h Host)
- func (a *Application) SetTooltipFace(f *render.Typeface)
- func (a *Application) SetTooltipOptions(o TooltipOptions)
- func (a *Application) SetTransferErrorHandler(fn func(err error))
- func (a *Application) SetWindowIcon(w *Window, img image.Image)
- func (a *Application) ShortcutsDialog(parent *Window) (*Dialog, error)
- func (a *Application) ShowToast(text string, timeout time.Duration, cfg *ToastConfig) (*widget.Toast, error)
- func (a *Application) ToggleInspect()
- func (a *Application) WatchFD(fd int, events int16, fn func(revents int16)) (stop func(), err error)
- func (a *Application) WatchFiles(paths []string, recursive bool, fn func()) (stop func(), err error)
- type BackgroundRequest
- type BackgroundResult
- type BarConfig
- type BarWindow
- type Clipboard
- type ContentType
- type DataControl
- type DataControlProtocol
- type Dialog
- type DialogButton
- type DialogButtonRole
- type DialogConfig
- type DialogParent
- type DialogPresentation
- type DisconnectReason
- type DisconnectedEvent
- type EmojiInserter
- type FileDialogConfig
- type FontChooserConfig
- type GlobalShortcut
- type Gravity
- type Host
- type InhibitFlags
- type Instance
- type InstanceConfig
- type Invocation
- type Key
- type KeyboardMode
- type Layer
- type LayerConfig
- type LayerSurfacer
- type LayerWindow
- func (l *LayerWindow) BackgroundBlurActive() bool
- func (l *LayerWindow) Close()
- func (l *LayerWindow) Closed() bool
- func (l *LayerWindow) EnsureUsable() error
- func (l *LayerWindow) HostSurface() *wl.Surface
- func (l *LayerWindow) KeyboardMode() KeyboardMode
- func (l *LayerWindow) LayerPopupSurface() *wlr.ZwlrLayerSurfaceV1
- func (l *LayerWindow) OnScaleChanged(fn func(num, denom int)) (cancel func())
- func (l *LayerWindow) Scale() (num, denom int)
- func (l *LayerWindow) SetAnchor(a layersurface.Anchor) error
- func (l *LayerWindow) SetBackgroundBlur(on bool)
- func (l *LayerWindow) SetContentType(ct ContentType) error
- func (l *LayerWindow) SetExclusiveZone(zone int32) error
- func (l *LayerWindow) SetFocus(w widget.Widget) error
- func (l *LayerWindow) SetKeyboardMode(mode KeyboardMode) error
- func (l *LayerWindow) SetLayer(layer layersurface.Layer) error
- func (l *LayerWindow) SetMargin(m layersurface.Margins) error
- func (l *LayerWindow) SetOpacity(alpha float64) error
- func (l *LayerWindow) SetSize(width, height uint32) error
- func (l *LayerWindow) Size() (int, int)
- type LockState
- type LockSurface
- type Locks
- type Margins
- type MenuPopover
- type MenuPopoverConfig
- type Mods
- type NotifyAction
- type NotifyOptions
- type OpenButton
- type OpenButtonConfig
- type Output
- type PageLayout
- type PageMargins
- type PageOrientation
- type PageSetup
- type Paper
- type PointerConstraint
- type Popover
- type PopoverConfig
- type PopoverDismissal
- type PreferencesDialog
- type PrintJob
- type Progress
- type ReconnectOptions
- type Reducer
- type ResizeEdge
- type ResponseAppearance
- type SaveDialogConfig
- type Selection
- type SelectionClaim
- type SelectionOffer
- type SelectionSource
- type SessionLock
- type SessionLockConfig
- type SessionState
- type Settings
- type SharedState
- type Shortcut
- type Stream
- type SubmenuSide
- type ToastConfig
- type ToastPosition
- type TooltipOptions
- type WMCapabilities
- type Window
- func (w *Window) Activate(token string)
- func (w *Window) BackgroundBlurActive() bool
- func (w *Window) BeginMove()
- func (w *Window) BeginResize(edge ResizeEdge)
- func (w *Window) Capabilities() WMCapabilities
- func (w *Window) Close()
- func (w *Window) Closed() bool
- func (w *Window) EnsureUsable() error
- func (w *Window) Fullscreen()
- func (w *Window) FullscreenOn(output *wlsession.Output)
- func (w *Window) HostSurface() *wl.Surface
- func (w *Window) Maximize()
- func (w *Window) Minimize()
- func (w *Window) OnCapabilities(fn func(WMCapabilities))
- func (w *Window) OnScaleChanged(fn func(num, denom int)) (cancel func())
- func (w *Window) RequestActivationToken(done func(token string, err error))
- func (w *Window) RequestAttention()
- func (w *Window) Scale() (num, denom int)
- func (w *Window) SetBackgroundBlur(on bool)
- func (w *Window) SetCloseRequest(veto func() bool)
- func (w *Window) SetContentType(ct ContentType) error
- func (w *Window) SetFocus(target widget.Widget) error
- func (w *Window) SetMaxSize(width, height uint32)
- func (w *Window) SetMinSize(width, height uint32)
- func (w *Window) SetMinimized()
- func (w *Window) SetOpacity(alpha float64) error
- func (w *Window) SetTitle(title string)
- func (w *Window) SetTransientFor(parent *Window)
- func (w *Window) Size() (int, int)
- func (w *Window) State() WindowState
- func (w *Window) ToggleMaximize()
- func (w *Window) Unfullscreen()
- func (w *Window) Unmaximize()
- func (w *Window) WhenPresented(fn func()) error
- type WindowConfig
- type WindowState
Examples ¶
Constants ¶
const ( // SelectionClipboard is the regular ctrl+c / ctrl+v selection. SelectionClipboard = datacontrol.Clipboard // SelectionPrimary is the middle-click primary selection. SelectionPrimary = datacontrol.Primary )
The seat's selections.
const ( // DataControlExt is the staging ext-data-control-v1. DataControlExt = datacontrol.ProtocolExt // DataControlWlr is wlr-data-control-unstable-v1. DataControlWlr = datacontrol.ProtocolWlr )
The data-control protocols.
const ( // DisconnectConnectionLost means the compositor is gone without a // verdict — the restart case. DisconnectConnectionLost = wlsession.DisconnectConnectionLost // DisconnectProtocol means the compositor sent a fatal // wl_display.error before the connection ended. DisconnectProtocol = wlsession.DisconnectProtocol )
const ( LayerBackground = layersurface.LayerBackground LayerBottom = layersurface.LayerBottom LayerTop = layersurface.LayerTop LayerOverlay = layersurface.LayerOverlay )
Stack layers, background through overlay.
const ( AnchorTop = layersurface.AnchorTop AnchorBottom = layersurface.AnchorBottom AnchorLeft = layersurface.AnchorLeft AnchorRight = layersurface.AnchorRight )
Anchor edges.
const ( KeyboardNone = layersurface.KeyboardNone KeyboardExclusive = layersurface.KeyboardExclusive KeyboardOnDemand = layersurface.KeyboardOnDemand )
Keyboard interactivity modes.
const ( ModShift = wlsession.ModShift ModCtrl = wlsession.ModCtrl ModAlt = wlsession.ModAlt ModSuper = wlsession.ModSuper )
Modifier bits of Mods.
const ( GravityBottom = popup.GravityBottom GravityTop = popup.GravityTop GravityRight = popup.GravityRight GravityLeft = popup.GravityLeft )
Popover gravities; the compositor flips to the opposite side when there is no room on the asked-for one.
const ( LockPending = sessionlock.Pending LockLocked = sessionlock.Locked LockUnlocked = sessionlock.Unlocked LockCancelled = sessionlock.Cancelled LockFinished = sessionlock.Finished )
Session lock lifecycle states.
const ( ContentNone = wlsession.ContentNone ContentPhoto = wlsession.ContentPhoto ContentVideo = wlsession.ContentVideo ContentGame = wlsession.ContentGame )
Content types.
const DefaultPrintDPI = 300
DefaultPrintDPI is the raster resolution of a PrintJob that sets none.
const DisconnectExitCode = 75
DisconnectExitCode is the exit status of the clean-exit policy: a distinct, nonzero code (EX_TEMPFAIL) a supervisor's Restart=on-failure (or a wayle supervisor) watches to respawn the app on the new session, while keeping genuine crashes (which exit by panic) distinguishable.
Variables ¶
var ( // neither data-control protocol. ErrDataControlUnavailable = datacontrol.ErrUnavailable // bound protocol version cannot carry. ErrPrimaryUnavailable = datacontrol.ErrPrimaryUnavailable // ErrDataControlFinished reports a device the compositor retired. ErrDataControlFinished = datacontrol.ErrFinished // ErrStaleOffer reports a read on a replaced selection offer. ErrStaleOffer = datacontrol.ErrStaleOffer // ErrMimeNotOffered reports a read under an unadvertised mime. ErrMimeNotOffered = datacontrol.ErrMimeNotOffered // ErrTransferTooLarge reports a selection read that streamed past // its limit; the payload is refused whole. ErrTransferTooLarge = xfer.ErrTooLarge // ErrTransferTimeout reports a selection read or write cut off by // the transfer deadline. ErrTransferTimeout = xfer.ErrTimeout )
var ( // ErrNoSubsurfaces reports a compositor without wl_subcompositor, // where a GPUArea cannot have a surface of its own. ErrNoSubsurfaces = errors.New("app: the compositor has no wl_subcompositor") // ErrNoDmabuf reports a compositor without zwp_linux_dmabuf_v1 // (version 2 or later): GPUArea imports no dmabufs and presents CPU // images only. ErrNoDmabuf = errors.New("app: the compositor has no linux-dmabuf") // ErrDmabufLayout reports a format and modifier pair the compositor // did not advertise; importing it would be a fatal protocol error. ErrDmabufLayout = errors.New("app: the compositor does not import this dmabuf format and modifier") // ErrDmabufRejected reports a dmabuf the compositor failed to // import. ErrDmabufRejected = errors.New("app: the compositor rejected the dmabuf") // ErrGPUSurfaceGone reports a buffer imported for a surface that // has since closed (the area left the screen or the window closed): // import it again in the next OnFrame. ErrGPUSurfaceGone = errors.New("app: the GPUArea surface this buffer belonged to is gone") )
var ( // PaperA4 is ISO A4, 210 x 297 mm. PaperA4 = Paper{Name: "iso_a4", Width: 210, Height: 297} // PaperLetter is US Letter, 8.5 x 11 in. PaperLetter = Paper{Name: "na_letter", Width: 215.9, Height: 279.4} )
var ( // ErrNotLocked: Unlock before the compositor confirmed the lock. ErrNotLocked = sessionlock.ErrNotLocked // ErrLocked: Cancel after the compositor confirmed the lock; a // locked session only ends through Unlock. ErrLocked = sessionlock.ErrLocked // ErrLockEnded: the lock was already unlocked, cancelled, or // finished by the compositor. ErrLockEnded = sessionlock.ErrEnded )
Errors from SessionLock.Unlock and SessionLock.Cancel.
var ( ErrNoToastWindow = errors.New("app: toast dropped: no window to show it on") ErrNoToastFace = errors.New("app: toast dropped: no text face available") )
Toast errors: ShowToast had nowhere to show the toast.
ErrActivationUnavailable is a token request on a compositor without xdg-activation.
ErrClipboardUnavailable reports that the clipboard holds no content in a usable type, or that the compositor offers no data device.
var ErrClosed = errors.New("app: surface closed")
ErrClosed reports that the surface ended and the loop exited. Callers that treat a plain close as success can match it with errors.Is.
var ErrDisconnected = wlsession.ErrDisconnected
ErrDisconnected reports the compositor ended the connection. Run returns it (matching under errors.Is) after running OnDisconnect and tearing the loop down. Ordinary closes are ErrClosed; only a dead connection is this.
var ErrGlobalShortcutDenied = errors.New("app: global shortcut denied by the user")
ErrGlobalShortcutDenied reports the user refusing the portal's bind dialog, or the portal cancelling the request.
ErrGlobalShortcutsUnavailable reports a desktop with neither hyprland_global_shortcuts_v1 nor the GlobalShortcuts portal.
ErrLayerShellUnavailable reports a compositor without zwlr_layer_shell_v1, such as a kiosk: NewLayer and NewBar fail with it, and toplevels keep working.
var ErrLoopEnded = errors.New("app: the application loop has ended")
ErrLoopEnded refuses a watcher once the application loop is gone.
var ErrNoDialogFace = errors.New("app: dialog text face unavailable: no configured tooltip face and the system has no sans font")
ErrNoDialogFace reports a system with no usable text face - no configured tooltip face and no system sans font. Every dialog builder (message boxes, file dialogs, about) returns it.
var ErrPortalBusy = errors.New("app: the portal queue is full or stopped")
ErrPortalBusy reports a portal request refused without being sent: the portal has stopped answering and too much is queued behind it, or the application has stopped.
var ErrPortalDenied = errors.New("app: the portal request was denied")
ErrPortalDenied reports a portal request the user or the desktop refused.
ErrPortalUnavailable reports that no xdg-desktop-portal answered on the session bus, or that the running one has no backend for the interface asked for.
var ErrSessionLockActive = errors.New("app: a session lock is already active")
ErrSessionLockActive reports a LockSession while this application already holds a lock (pending or locked).
ErrSessionLockUnavailable reports a compositor without ext_session_lock_manager_v1: the session cannot be locked securely.
Functions ¶
func AnchorAt ¶
AnchorAt is an anchor at a point in the host's coordinates - a context menu at the pointer, a popover over a canvas position.
func AnchorRect ¶
AnchorRect is an anchor on a rect in the host's coordinates - a text range, a cell of a custom-drawn grid.
func Connect ¶
Connect opens the Wayland session for an Application. The session type is unexported on purpose (consumers hold it opaquely and pass it to NewApplication); this constructor is the public way in.
func ExportPDF ¶
ExportPDF renders job on job.Setup into a PDF at path, replacing it atomically. It runs Pages and Paint on the caller's goroutine.
func Font ¶
Font resolves a system font family by name at the given logical pixel size. Malformed family names fall back per fontconfig; an unresolvable name is an error.
func FontFallback ¶
FontFallback wraps a face in the glyph fallback chain, so glyphs the primary family lacks still render.
func FontFamilies ¶
FontFamilies lists the installed font families by display name (the name a family resolves back from through Font), sorted case-insensitively and deduped: what a font picker offers. The list resolves once per process (each display name is a face lookup); the result is shared, so callers must not modify it.
func FontVariant ¶
FontVariant resolves the bold/italic face of base's family, falling back to the closest face the family has.
func FontVariants ¶
func FontVariants(base *render.Typeface) widget.VariantFunc
FontVariants is the widget.VariantFunc of base's family: each bold/italic style resolved through FontVariant (the font cache keeps the faces), base itself where the family has none.
func FontVariantsOf ¶
func FontVariantsOf(face render.Font) widget.VariantFunc
FontVariantsOf is FontVariants for whatever face the app holds: a fallback chain resolves from its primary face, a bare typeface from itself. nil yields nil (a rich label without variants).
func FontWeighted ¶
FontWeighted resolves a system font family at a CSS numeric weight (400 regular, 700 bold, ...) and style. A family without that face resolves to its closest one, as a CSS font matcher does.
func SetLogger ¶
SetLogger installs the library-wide logger: lys-ui's internals (session protocol warnings, event-loop diagnostics, theme contrast warnings, the appearance monitor) emit through it. Nothing logs per-frame or per-keypress, and nothing logs at Info. A nil logger selects the default: discard all output, so an application that never calls this sees no library output on stdout or stderr. Call it before Connect; safe from any goroutine.
func Trace ¶
Trace writes one line to lys-ui's debug trace stream, the one the toolkit traces its wire, routing and frame decisions into: compiled in only with the lysdebug build tag, and printed only for the categories LYS_DEBUG admits (comma-separated names, "*" for all). Applications trace their own events beside the toolkit's in one timeline.
Types ¶
type A11YOptions ¶
A11YOptions configures the AT-SPI bridge (ServeAccessibility).
type A11yMode ¶
type A11yMode uint8
A11yMode chooses when the AT-SPI bridge serves.
const ( // A11yAuto serves while the desktop asks for assistive // technologies (org.a11y.Status IsEnabled or ScreenReaderEnabled - // a screen reader running, the accessibility setting on), starting // and stopping with it. A11yAuto A11yMode = iota // A11yOn serves from Run on, whatever the desktop says. A11yOn // A11yOff never serves (unless ServeAccessibility is called). A11yOff )
Accessibility modes. The LYS_UI_A11Y environment variable overrides the application's choice, like GTK_A11Y: "none" is A11yOff, "atspi" A11yOn.
type AboutConfig ¶
type AboutConfig struct {
// Name and Version head the dialog; Comments is the one-line
// tagline under them.
Name string
Version string
Comments string
// Logo paints above the name (image.Image; nil skips it). LogoPath
// loads asynchronously in its place, the widget.Image file source.
Logo image.Image
LogoPath string
// Website and IssueURL render as their URLs; opening them is the
// launcher ticket's (#86) job once it lands.
Website string
IssueURL string
// ReleaseNotes shows under a "What's New" heading; License under
// "Legal", both scrolled with the rest.
ReleaseNotes string
License string
// Credits group contributors by role ("Authors", "Artists", ...),
// in order, each group a heading and its names.
Credits []AboutCredit
}
AboutConfig declares an about dialog, the AdwAboutWindow content: who the app is, where it lives, who made it, and under what terms. Zero fields drop their sections - an about with only a name and version is a title card, one with credits and license is the full GNOME-class page.
type AboutCredit ¶
AboutCredit is one contributor group.
type Accel ¶
Accel identifies one accelerator: a keysym plus the modifiers that must be held. It is the key of the application's accelerator table. Letter keysyms are normalized to their lowercase form on both sides (parse and lookup), because shift changes the keysym a key produces and not just the modifier bits: that keeps shift+a text while letting "ctrl+P" and a ctrl+shift+p press name one binding.
func ParseAccel ¶
ParseAccel parses an accelerator string: modifier names and one key name joined with "+" ("ctrl+p", "Ctrl+Shift+Return", "F5"), or in GTK's angle-bracket form ("<Control>p", "<Control><Shift>p"). Modifiers (case-insensitive) are ctrl/control, shift, alt/mod1, and super/mod4/logo; any other modifier name is an error. Key names are XKB keysym names ("p", "Return", "Escape", "F5", "space") plus the aliases esc, enter, del, bksp, ins, pgup, and pgdn. widget.Menu paints Accel labels from the same strings, so Accel.String output feeds a menu item unchanged.
type AccelInfo ¶
type AccelInfo struct {
Shortcut Shortcut
Action widget.Activatable
Scope widget.Widget
}
AccelInfo is one registered shortcut: the action it activates and, for a scoped binding, the subtree it is limited to (nil for an app-wide one).
type AdaptiveDialog ¶
type AdaptiveDialog struct {
// contains filtered or unexported fields
}
AdaptiveDialog is libadwaita's adaptive AdwDialog: over a wide parent it is a regular window-modal dialog; over a narrow one it is a bottom sheet sliding up inside the parent window, closed by a response, Esc, a click on the scrim or a drag down. The presentation is decided when the dialog opens.
func (*AdaptiveDialog) Close ¶
func (d *AdaptiveDialog) Close()
Close closes the dialog without a response.
func (*AdaptiveDialog) Closed ¶
func (d *AdaptiveDialog) Closed() bool
Closed reports whether the dialog has closed or is closing.
func (*AdaptiveDialog) Presentation ¶
func (d *AdaptiveDialog) Presentation() DialogPresentation
Presentation reports how the dialog was presented.
func (*AdaptiveDialog) Respond ¶
func (d *AdaptiveDialog) Respond(response string)
Respond answers the dialog with response, as its buttons, Esc and Enter do: ValidateResponse may refuse, OnResponse hears it, and the dialog closes.
type AdaptiveDialogConfig ¶
type AdaptiveDialogConfig struct {
DialogConfig
// Presentation picks the presentation; PresentAuto by default.
Presentation DialogPresentation
// SheetBelow is the parent width (logical pixels) under which
// PresentAuto uses the bottom sheet; zero means 450, libadwaita's
// narrow breakpoint.
SheetBelow int
}
AdaptiveDialogConfig declares an AdaptiveDialog: a DialogConfig plus how to present it.
type Anchor ¶
type Anchor = layersurface.Anchor
Anchor selects the anchored edges of a layer surface.
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application is a set of windows sharing one session.
Example ¶
ExampleApplication is a minimal app on the lower-level path, public API only: one toplevel window with a button that counts clicks.
// Package app_test holds the godoc examples for the app package. The
// examples need a live Wayland compositor to actually run, so they
// carry no Output comment: go test compiles them against the real API
// without executing.
package main
import (
"errors"
"fmt"
"log"
"github.com/stubbedev/lys-ui/app"
"github.com/stubbedev/lys-ui/widget"
)
// ExampleApplication is a minimal app on the lower-level path, public API
// only: one toplevel window with a button that counts clicks.
func main() {
if err := run(); err != nil && !errors.Is(err, app.ErrClosed) {
log.Fatal(err)
}
}
func run() error {
sess, err := app.Connect()
if err != nil {
return err
}
defer sess.Close()
face, err := app.Font("sans", 15)
if err != nil {
return err
}
clicks := 0
count := widget.NewLabel(face, 15, "clicked 0 times", widget.Current().Text)
button := widget.NewButton(count, 10, 8)
button.OnClick = func() {
clicks++
count.SetText(fmt.Sprintf("clicked %d times", clicks))
}
application := app.NewApplication(sess)
if _, err := application.NewWindow(app.WindowConfig{
Title: "hello", AppID: "dev.stubbe.lys.ui.hello",
Width: 320, Height: 120,
Root: button, Background: widget.Current().Bg,
}); err != nil {
return err
}
return application.Run()
}
Output:
func NewApplication ¶
func NewApplication(sess *wlsession.Session) *Application
NewApplication binds an application to a connected session.
func (*Application) A11yGeneration ¶ added in v0.2.5
func (a *Application) A11yGeneration() uint64
A11yGeneration implements atspi.Scene.
func (*Application) AboutDialog ¶
func (a *Application) AboutDialog(parent *Window, cfg AboutConfig) (*Dialog, error)
AboutDialog opens the application's about page: identity at the top, release notes, credits, and license scrolled beneath, one Close button, Escape closes. It rides the standard Dialog machinery like every other dialog.
func (*Application) Accels ¶
func (a *Application) Accels() []AccelInfo
Accels lists every binding in registration order, read-only (a copy): the registry a shortcuts window or a settings page renders.
func (*Application) Accent ¶
func (a *Application) Accent() appearance.Accent
Accent returns the desktop's accent-color preference.
func (*Application) AdaptiveDialog ¶
func (a *Application) AdaptiveDialog(parent *Window, cfg AdaptiveDialogConfig) (*AdaptiveDialog, error)
AdaptiveDialog opens a dialog over parent, floating or as a bottom sheet per cfg.Presentation.
func (*Application) AddAccel ¶
func (a *Application) AddAccel(keys string, action widget.Activatable) error
AddAccel binds a shortcut - an accelerator ("ctrl+q") or a chord of them pressed in turn ("ctrl+x ctrl+s", "g g") - to a, app-wide. A disabled action lets the key through. The conflict rule is an error at registration: the first binding keeps its keys, and a second one in the same scope on the same shortcut, or on a prefix or extension of it, fails naming the incumbent instead of stealing the key.
func (*Application) AddScopedAccel ¶
func (a *Application) AddScopedAccel(scope widget.Widget, keys string, action widget.Activatable) error
AddScopedAccel binds keys to action within scope: the shortcut fires only while keyboard focus is on scope or inside it, and shadows bindings of wider scopes (a window's root, a pane, one entry). The innermost scope holding the keys, or a chord in progress, wins.
func (*Application) AttachFontButton ¶
func (a *Application) AttachFontButton(parent *Window, b *widget.FontButton)
AttachFontButton makes b open the font chooser dialog over parent on click and apply the pick.
func (*Application) AttachHeader ¶
func (a *Application) AttachHeader(win *Window, bar *widget.HeaderBar)
AttachHeader wires a HeaderBar to its window: close, minimize, and maximize controls hooked, the double-press mapped to maximize/restore. The press-to-move grab needs no wiring - the input pipeline routes any WindowMover press into xdg_toplevel.move. The minimize and maximize buttons follow the compositor's wm_capabilities: shown until it says otherwise (a compositor that never says - toplevel before v5 - offers everything), hidden, and the double-press inert, for what it declares it cannot do.
func (*Application) AttachSplitButton ¶
func (a *Application) AttachSplitButton(host Host, b *widget.SplitButton, items []widget.MenuItem)
AttachSplitButton wires a SplitButton's arrow half to items: the arrow opens the menu popover below itself.
func (*Application) AttachTabView ¶
AttachTabView binds libadwaita's tab shortcuts within scope (the subtree holding the view and its bar): ctrl+Tab and ctrl+PageDown select the next page, ctrl+shift+Tab and ctrl+PageUp the previous, and alt+1 through alt+9 the page at that position (alt+9 the last).
func (*Application) BackgroundBlurAvailable ¶
func (a *Application) BackgroundBlurAvailable() bool
BackgroundBlurAvailable reports whether the compositor offers background blur (ext_background_effect_v1 with its blur capability): what an app checks to pick a translucent or an opaque style. Hyprland has no client protocol for it; its users' window and layer rules decide instead.
func (*Application) Bell ¶
func (a *Application) Bell(host Host) error
Bell rings the system bell for host (nil: the application's).
func (*Application) CalendarDialog ¶
func (a *Application) CalendarDialog(parent *Window, initial widget.Date, onSelect func(widget.Date)) (*Dialog, error)
CalendarDialog opens a modal calendar picker: a widget.Calendar starting at initial, responding "select" with the chosen date through OnResponse when a day is picked (the dialog closes) and "cancel" on Esc. onSelect is the Calendar's own hook for apps that want every applied selection, not just the closing one.
func (*Application) CancelDrag ¶
func (a *Application) CancelDrag() bool
CancelDrag cancels the drag this application started, if one is running; its OnDone hears transfer.ActionNone. Reports whether a drag was running.
func (*Application) Clipboard ¶
func (a *Application) Clipboard() *Clipboard
Clipboard returns the clipboard SetClipboard installed, nil before. Its methods touch the Wayland connection: call them on the loop goroutine (inside Invoke from elsewhere).
func (*Application) ColorChooserDialog ¶
func (a *Application) ColorChooserDialog(parent *Window, initial render.Color, onColor func(render.Color)) (*Dialog, error)
ColorChooserDialog opens a modal color picker (#72): an SV square, hue and alpha strips, a hex entry, theme-derived presets, and this application's custom palette. Confirming responds "ok" and fires onColor with the exact picked color (and the pick joins the palette); Esc responds "cancel".
func (*Application) ColorScheme ¶
func (a *Application) ColorScheme() appearance.ColorScheme
ColorScheme returns the desktop's current dark/light preference, appearance.Unknown without a portal. It is valid from NewApplication on, so the first frame can be themed from it.
func (*Application) ConfinePointer ¶
func (a *Application) ConfinePointer(host Host, region []render.Rect, persistent bool) (*PointerConstraint, error)
ConfinePointer keeps the pointer inside region (logical rects of the host; nil confines to the whole host) while it is over host.
func (*Application) Contrast ¶
func (a *Application) Contrast() appearance.Contrast
Contrast returns the desktop's contrast preference.
func (*Application) DataControl ¶
func (a *Application) DataControl() (*DataControl, error)
DataControl returns the seat's data-control device, creating it on first use; later calls return the same device. The compositor announces the current selections right after creation, so register OnSelection before the loop next dispatches. Fails with ErrDataControlUnavailable when the compositor lacks both protocols.
func (*Application) DescribeAction ¶
func (a *Application) DescribeAction(action widget.Activatable, section, title string)
DescribeAction sets how the shortcuts overview presents an action: the section it is listed under and its human title (the action's name when empty).
func (*Application) DesktopFontSize ¶
func (a *Application) DesktopFontSize() float64
DesktopFontSize is the default font size, in logical pixels, a GTK app on this desktop uses - what 1rem is there: the desktop font's size (the portal's font-name, else settings.ini's gtk-font-name, else GTK's "Sans 10") at its text DPI (the portal's text-scaling-factor, else gtk-xft-dpi, else 96). lys-ui keeps its own 16px rem unless the app applies this with widget.SetRootFontSize.
func (*Application) EmojiChooser ¶
func (a *Application) EmojiChooser(host Host, onPick func(emoji string)) (*Popover, error)
EmojiChooser opens the emoji picker over host: categories in a scrollable grid, a search field, and OnPick receiving the chosen emoji string exactly once (the popover closes with the pick).
func (*Application) EmojiChooserForEntry ¶
func (a *Application) EmojiChooserForEntry(host Host, target EmojiInserter) (*Popover, error)
EmojiChooserForEntry opens the picker over host and inserts the chosen emoji into target at its caret - the ctrl+period flow. The binding itself stays the app's (an accel); this is the handler.
func (*Application) Every ¶
func (a *Application) Every(d time.Duration, fn func()) (cancel func())
Every schedules fn to run on the event-loop goroutine once per d, first fire after d - the shape of a poller (a wayle refresh loop, a clock, a status sampler). The timer rides the loop's wake computation: while one is pending the parked loop wakes exactly at its deadline and holds no CPU in between, the same way animation and key-repeat deadlines do. Ticks anchor at fire time, so a slow frame delays the next tick instead of bursting to catch up.
Every is safe to call from any goroutine; fn runs on the loop and must follow the loop's rules. The returned cancel stops the timer (idempotent, safe from any goroutine); the timer also stops on its own when Run returns. A non-positive d panics: a zero interval would spin the loop.
func (*Application) Focused ¶
func (a *Application) Focused() widget.Widget
Focused implements atspi.Scene: the focused widget of the topmost window (the most recently created one holds input focus), nil when nothing does.
func (*Application) FontChooserDialog ¶
func (a *Application) FontChooserDialog(parent *Window, cfg FontChooserConfig) (*Dialog, error)
FontChooserDialog opens a modal font picker (#74): a searchable, virtualized family list (each row lazily rendered in its own family's face), a size entry with a synced slider, a monospace filter toggle, and a live preview line shaped through the same fallback chain production text uses; cfg drops the size row or locks the list to monospace families. Confirming responds "ok" and fires OnFont; Esc responds "cancel". The monospace filter classifies families by their fixed-width flag on first use (cached; face parses ride the shared face cache).
func (*Application) ForgetImage ¶
func (a *Application) ForgetImage(id render.ImageID)
ForgetImage drops the GPU's copy of the raster id names once the frame drawing it is done, instead of after it idles out: an owner that frees a raster's pixels (render.Retire), or stops showing a large one for good, calls it so the texture goes with them. Drawing on the CPU there is no copy to drop. Call it on the event-loop goroutine. A zero id, no identity, panics: such a raster is the garbage collector's to free.
func (*Application) GlobalShortcutsAvailable ¶
func (a *Application) GlobalShortcutsAvailable(done func(bool))
GlobalShortcutsAvailable reports through done, on the loop, whether a transport exists: the compositor's protocol manager, or the desktop's GlobalShortcuts portal. It returns at once; asking the bus runs on the portal worker.
func (*Application) HeldMods ¶
func (a *Application) HeldMods() Mods
HeldMods is the modifiers held right now (shift, ctrl, alt): what a pointer binding reads, since pointer events carry no modifier state of their own (a launcher's Ctrl+double-click).
func (*Application) Hold ¶
func (a *Application) Hold() (release func())
Hold keeps Run going with no window mapped, for an application whose work is not on screen: a portal serving the clipboard over the data-control device, a daemon that maps surfaces only on request. The returned release ends the hold (once; later calls do nothing), and Run returns at its next check when nothing else keeps it alive. Call both on the loop goroutine, or before Run.
func (*Application) IdleInhibitAvailable ¶
func (a *Application) IdleInhibitAvailable() bool
IdleInhibitAvailable reports whether the compositor supports the idle-inhibit protocol; false on compositors without it.
func (*Application) IdleNotifyAvailable ¶
func (a *Application) IdleNotifyAvailable() bool
IdleNotifyAvailable reports whether the compositor can tell the application when the user goes idle (ext-idle-notify-v1).
func (*Application) Inhibit ¶
func (a *Application) Inhibit(flags InhibitFlags, reason string, done func(release func(), err error))
Inhibit holds off the session actions in flags, with reason shown to the user, through the xdg-desktop-portal Inhibit portal (GTK's gtk_application_inhibit). It returns at once, and done runs on the loop with the portal's answer: a release that ends the inhibition, or ErrPortalDenied, ErrPortalUnavailable or the failure. Calling release again does nothing, and a failure to release is logged, since the inhibition ends with the connection anyway.
func (*Application) InhibitIdle ¶
func (a *Application) InhibitIdle(host Host) (func(), error)
InhibitIdle holds the compositor's idle and suspend for as long as the returned release function goes uncalled: while a media player runs or a download is in flight, the screen stays on. The inhibitor binds to the host's surface. Fails when the protocol is unavailable.
func (*Application) Inspect ¶
func (a *Application) Inspect() bool
Inspect reports whether the overlay currently paints.
func (*Application) Invoke ¶
func (a *Application) Invoke(fn func())
Invoke schedules fn to run on the event-loop goroutine: the only sanctioned way for another goroutine to touch widgets or any other loop-owned state (docs/threading.md). The call itself is safe from any goroutine; it queues fn and wakes the parked loop, which runs it at the top of its next pass with the same guarantees as an event callback.
The wake coalesces: under a storm of Invokes the loop still wakes once per pass, not once per call. After Run returns, Invoke drops fn - there is no loop left to run it on - so shutdown sequences should signal workers through channels, not widget state.
func (*Application) KeySym ¶
func (a *Application) KeySym(code uint32) xkb.Keysym
KeySym translates a key code through the current session's keymap - what OnKey handlers use, so a handler never holds a session a reconnect replaced.
func (*Application) LockPointer ¶
func (a *Application) LockPointer(host Host, persistent bool) (*PointerConstraint, error)
LockPointer locks the pointer in place while it is over host - an FPS-style view, a whiteboard pan - after which motion arrives only through OnRelativeMotion. persistent keeps the lock for every return of the pointer; otherwise it ends with its first deactivation. One constraint per host at a time.
func (*Application) LockSession ¶
func (a *Application) LockSession(cfg SessionLockConfig) (*SessionLock, error)
LockSession asks the compositor to lock the session and creates a lock surface on every output (and on every output plugged in later, until the lock ends). The compositor answers asynchronously: OnLocked once the lock holds, OnFinished if it refused. One lock at a time: a second LockSession while one is active fails with ErrSessionLockActive.
func (*Application) Locks ¶
func (a *Application) Locks() Locks
Locks returns which lock keys are on.
func (*Application) MessageBox ¶
func (a *Application) MessageBox(parent *Window, title, text string, buttons []DialogButton) (*Dialog, error)
MessageBox opens the standard preset, an alert dialog: the title over the muted text, wrapped, above the buttons, the dialog as tall as they need.
func (*Application) NewBar ¶
func (a *Application) NewBar(cfg BarConfig) (*BarWindow, error)
NewBar shows cfg.Bar along its edge: anchored to that edge and stretched along it, as thick as the bar's content.
func (*Application) NewDialog ¶
func (a *Application) NewDialog(parent DialogParent, cfg DialogConfig) (*Dialog, error)
NewDialog opens a dialog parented to a window of this application. A nil parent makes an application-level dialog that blocks every other window while open (when Modal).
func (*Application) NewLayer ¶
func (a *Application) NewLayer(cfg LayerConfig) (*LayerWindow, error)
NewLayer creates a layer surface from a declarative config — the bar/panel/launcher shape: anchors, margins, exclusive zone, and keyboard interactivity declared up front. It fails with ErrLayerShellUnavailable on a compositor without layer shell.
func (*Application) NewOpenButton ¶
func (a *Application) NewOpenButton(parent *Window, cfg OpenButtonConfig) (*OpenButton, error)
NewOpenButton returns an open button parented to parent. It needs a resolved face; when the application has none it returns ErrNoDialogFace.
func (*Application) NewWindow ¶
func (a *Application) NewWindow(cfg WindowConfig) (*Window, error)
NewWindow creates a toplevel window from a declarative config and adds it to the application. The window joins the loop on the next Run iteration (or immediately when Run is already running).
func (*Application) Notify ¶
func (a *Application) Notify(title, body string, opts NotifyOptions)
Notify sends a desktop notification and forgets it: the dial and the bus call run on the notifier's worker, action and close callbacks come back onto the loop, and a desktop without a notification surface drops the notification silently. The lys-ui-side id the transport works with is generated here and stays internal.
func (*Application) OnAccentChange ¶
func (a *Application) OnAccentChange(fn func(appearance.Accent)) (off func())
OnAccentChange registers fn for every accent-color change, on the loop goroutine like OnColorSchemeChange.
func (*Application) OnColorSchemeChange ¶
func (a *Application) OnColorSchemeChange(fn func(appearance.ColorScheme)) (off func())
OnColorSchemeChange registers fn for every color-scheme change. fn runs on the loop goroutine, so it may call widget.SetTheme directly. The returned function unregisters it; a change already queued when it runs is dropped.
func (*Application) OnContrastChange ¶
func (a *Application) OnContrastChange(fn func(appearance.Contrast)) (off func())
OnContrastChange registers fn for every contrast change, on the loop goroutine like OnColorSchemeChange.
func (*Application) OnDesktopFontSizeChange ¶
func (a *Application) OnDesktopFontSizeChange(fn func(px float64)) (off func())
OnDesktopFontSizeChange registers fn for every change of DesktopFontSize (a portal font-name or text-scaling-factor change that moves it), on the loop goroutine like OnColorSchemeChange.
func (*Application) OnDisconnect ¶
func (a *Application) OnDisconnect(fn func(DisconnectedEvent))
OnDisconnect installs the disconnect policy hook. It fires at most once per connection, SetReconnect's rebuilt session re-arming it, on the loop goroutine, before any teardown: the callback may flush state, but must not block indefinitely and must not route work back through the loop (Invoke already drops once Run is unwinding). After it returns, Run releases every window's pool and closes the session (shared arena: memfd, mapping, fd — and the display), so the exiting process leaves nothing mapped. Without a hook the same teardown runs; the hook is optional observation, not permission.
func (*Application) OnIdle ¶
func (a *Application) OnIdle(timeout time.Duration, idle, resume func()) (stop func(), err error)
OnIdle watches for timeout of user inactivity: idle runs once the user has been idle that long, resume when they are active again, both on the loop goroutine, until the returned stop. Idle inhibitors (a video playing) hold the timer like they hold the compositor's own. Fails when the protocol is unavailable - an absent protocol leaves the application with no idle signal rather than a guess.
func (*Application) OnKey ¶
OnKey observes every key press on the focused window, after widget routing and accelerators, for app-level keybindings. It still sees keys an accelerator consumed; accelerators only suppress text routing and widget actions.
func (*Application) OnLocks ¶
func (a *Application) OnLocks(fn func(Locks)) (stop func())
OnLocks calls fn with the lock keys' state now and on the loop at each change, so a Caps Lock warning needs no timer and shows for a Caps Lock already on at startup, which arrives with the first keyboard focus. The returned stop ends the calls.
func (*Application) OnReducedMotionChange ¶ added in v0.2.1
func (a *Application) OnReducedMotionChange(fn func(bool)) (off func())
OnReducedMotionChange registers fn for every change of ReducedMotion, on the loop goroutine like OnColorSchemeChange, after the toolkit has applied it.
func (*Application) OnRelativeMotion ¶
func (a *Application) OnRelativeMotion(host Host, fn func(dx, dy, rawDX, rawDY float64))
OnRelativeMotion registers fn to receive the pointer's relative motion while it is over host (locked or not): the accelerated deltas and the raw ones before acceleration - what a remote desktop client forwards. Nil unregisters.
func (*Application) OnSessionStateChange ¶
func (a *Application) OnSessionStateChange(fn func(state SessionState, screensaver bool), done func(error))
OnSessionStateChange watches the login session's state through the Inhibit portal's monitor. It returns at once, and done (nil logs a failure instead) runs on the loop once the monitor stands or failed. fn runs on the loop goroutine with the state and whether the screensaver is active. When the state is SessionQueryEnd, lys-ui answers the portal's query after fn returns and after every Inhibit made inside fn reached the portal, so an Inhibit(InhibitLogout, ...) made inside fn objects to the logout.
func (*Application) OnStop ¶
func (a *Application) OnStop(fn func()) (cancel func())
OnStop registers fn to run when Run returns, after the loop's last pass. Hooks run in reverse registration order, like deferred calls. After the loop already ended, fn runs at once. The returned cancel unregisters fn without running it.
func (*Application) OpenFileDialog ¶
func (a *Application) OpenFileDialog(parent *Window, cfg FileDialogConfig) (*Dialog, error)
OpenFileDialog opens the file picker for one existing file.
func (*Application) OpenFilesDialog ¶
func (a *Application) OpenFilesDialog(parent *Window, cfg FileDialogConfig) (*Dialog, error)
OpenFilesDialog opens the file picker for any set of existing files.
func (*Application) OpenFolderDialog ¶
func (a *Application) OpenFolderDialog(parent *Window, cfg FileDialogConfig) (*Dialog, error)
OpenFolderDialog opens the picker for one directory.
func (*Application) OpenMenuPopover ¶
func (a *Application) OpenMenuPopover(host Host, cfg MenuPopoverConfig) (*MenuPopover, error)
OpenMenuPopover opens the root level over host.
func (*Application) OpenPath ¶
func (a *Application) OpenPath(path string)
OpenPath opens a file or directory in the user's handler for it, the FileLauncher shape.
func (*Application) OpenPopover ¶
func (a *Application) OpenPopover(host Host, cfg PopoverConfig) (*Popover, error)
OpenPopover opens content beside anchor on the given host, on the side gravity asks for, flipping inside the host when the anchor sits near an edge. Opening a second popover on the same host re-anchors: the previous popover closes first. The popover's own key router dismisses on Esc and forwards everything else to the content. A grabbing popover anchors its grab to the latest input event, the click or key that opened it; opened before any input event it fails.
func (*Application) OpenURL ¶
func (a *Application) OpenURL(uri string)
OpenURL opens url in the user's handler for its scheme. Safe from any goroutine; the transport work happens off the caller. The compositor decides focus, guided by an activation token when the session's xdg-activation support issued one.
func (*Application) OpenURLFromLink ¶
func (a *Application) OpenURLFromLink(href string)
OpenURLFromLink wires a RichLabel's (or any link-emitting widget's) OnLinkClick to OpenURL - the sanctioned one-liner links have been missing:
label.OnLinkClick = application.OpenURLFromLink
func (*Application) PointerConstraintsAvailable ¶
func (a *Application) PointerConstraintsAvailable() bool
PointerConstraintsAvailable reports whether the compositor supports pointer locking and confinement.
func (*Application) PreferencesDialog ¶
func (a *Application) PreferencesDialog(parent *Window, title string, view *widget.PreferencesView) (*PreferencesDialog, error)
PreferencesDialog opens view in a dialog over parent titled title, closed by its Close button or Esc.
func (*Application) Print ¶
func (a *Application) Print(parent *Window, job PrintJob, done func(error))
Print prints job through the xdg-desktop-portal Print portal (GTK's GtkPrintDialog): the portal's dialog picks the printer and page setup, lys-ui renders the pages on the loop into a PDF at that setup, and the portal sends it to the printer. parent (nil for none) is the window the dialog belongs to. done runs on the loop with nil once the job is queued, ErrPortalDenied when the user cancels, ErrPortalUnavailable without a print portal, or the failure. The next Print starts from the settings the user chose.
func (*Application) ProgressDialog ¶
func (a *Application) ProgressDialog(parent *Window, title, text string, pulsing bool, onCancel func()) (*Dialog, *Progress, error)
ProgressDialog opens a modal progress dialog: a text line over a determinate bar the caller drives through the returned Progress (or a busy spinner, with pulsing true). Cancelling - the button, or Escape - responds "cancel" through OnCancel and leaves closing to the caller: long work keeps the dialog up by holding the returned Dialog open until it Responds.
func (*Application) PromptDialog ¶
func (a *Application) PromptDialog(parent *Window, title, message, initial string, allowEmpty bool, onText func(string)) (*Dialog, error)
PromptDialog opens a one-entry question dialog - the rename-prompt shape: message, a single text entry prefilled with initial, Enter confirms with the entry's text (onText, exactly once, on the loop), Escape cancels. Empty text refuses to close the dialog - prompts answer with something - unless allowEmpty opts that policy off.
func (*Application) Quit ¶
func (a *Application) Quit()
Quit ends Run at the next loop check, regardless of open windows.
func (*Application) ReducedMotion ¶ added in v0.2.1
func (a *Application) ReducedMotion() bool
ReducedMotion reports whether the desktop asks for reduced motion: the portal's reduced-motion setting, else settings.ini's gtk-enable-animations. An application needs nothing more than being one to honour it: motion stops and surfaces fade from NewApplication on, following changes live.
func (*Application) RegisterGlobalShortcut ¶
func (a *Application) RegisterGlobalShortcut(id, appID, description, trigger string, on func(pressed bool, unixSec uint64), done func(*GlobalShortcut, error))
RegisterGlobalShortcut registers id for appID; the desktop shows description and binds trigger (a user-readable hint; the compositor's config or the portal's dialog decides the keys). on runs on the loop goroutine for every press (true) and release, with the event's Unix seconds. The app_id + id pair must be unique for the connection. Call on the loop goroutine. It returns at once, and done runs on the loop with the shortcut or the failure.
Transport: the compositor's hyprland_global_shortcuts_v1 when offered, else the freedesktop GlobalShortcuts portal. The portal's bind flow shows the desktop's binding dialog, so done may come long after, once the user answered; denial is ErrGlobalShortcutDenied, and ErrPortalBusy says too much is queued behind a portal that stopped answering.
func (*Application) RelativePointerAvailable ¶
func (a *Application) RelativePointerAvailable() bool
RelativePointerAvailable reports whether the compositor delivers relative pointer motion.
func (*Application) RemoveAccel ¶
func (a *Application) RemoveAccel(keys string) error
RemoveAccel unbinds keys whatever their scope. Unbinding keys that are not bound errors.
func (*Application) RequestActivationToken ¶
func (a *Application) RequestActivationToken(done func(token string, err error))
RequestActivationToken mints an xdg-activation token for a launch or an activation the application performs itself: a notification daemon handing the app whose action was pressed a token (org.freedesktop.Notifications.ActivationToken), a portal passing one in platform_data. It is anchored to the focused window and the latest input event, as a launch is, so it vouches for a real interaction. done runs once, on the event loop, with the token, or with ErrActivationUnavailable on a compositor without xdg-activation, or the request's failure.
func (*Application) RequestBackground ¶
func (a *Application) RequestBackground(req BackgroundRequest, done func(BackgroundResult, error))
RequestBackground asks the Background portal for permission to run without windows (and to autostart). The desktop may ask the user, so the answer arrives later: done runs on the loop goroutine with the result, or with ErrPortalDenied or the failure.
func (*Application) Roots ¶
func (a *Application) Roots() []widget.Widget
Roots implements atspi.Scene: the window roots in window order. Only ever called on the loop goroutine (from inside Invoke), where the window list and the routers are consistent.
func (*Application) Run ¶
func (a *Application) Run() error
Run drives every window until the application quits (Quit) or every window has closed with no session lock held (a lock keeps the loop alive with nothing mapped). It returns ErrClosed in both cases. Run's goroutine is the event-loop goroutine of the threading contract (docs/threading.md): widget and callback work happens here, and other goroutines reach it only through Invoke and Every. Run marks the goroutine for the off-loop debug hook, pumps the queued work at the top of every pass, and folds the periodic-timer deadlines into the wake computation, so a pending poller wakes the park exactly once per tick.
func (*Application) SaveFileDialog ¶
func (a *Application) SaveFileDialog(parent *Window, cfg SaveDialogConfig) (*Dialog, error)
SaveFileDialog opens the picker for naming a file to write, with overwrite confirmation unless turned off.
func (*Application) ServeAccessibility ¶
func (a *Application) ServeAccessibility(opts A11YOptions, done func(error))
ServeAccessibility starts the in-process AT-SPI bridge: the accessibility bus is discovered through org.a11y.Bus (opts overrides), the window trees are exported at the AT-SPI root, and the registry handshake runs. It returns at once and waits on no bus: done (nil logs a failure instead) runs on the loop once the bridge serves or failed to. Idempotent. Call before Run (the same window SetRoot et al. honor) or from any goroutine; the bridge stops with Run. The first sample queues through Invoke and drains once Run starts. Run calls it itself under A11yOn, and under A11yAuto when the desktop asks for assistive technologies.
func (*Application) Session ¶
func (a *Application) Session() *wlsession.Session
Session is the application's current Wayland session - a new one after each reconnect.
func (*Application) SessionLock ¶
func (a *Application) SessionLock() *SessionLock
SessionLock returns the lock this application holds, nil when none is pending or locked.
func (*Application) SessionLockAvailable ¶
func (a *Application) SessionLockAvailable() bool
SessionLockAvailable reports whether the compositor offers ext-session-lock-v1.
func (*Application) SetAccessibility ¶
func (a *Application) SetAccessibility(mode A11yMode)
SetAccessibility chooses when Run serves the bridge; call before Run.
func (*Application) SetBackgroundStatus ¶
func (a *Application) SetBackgroundStatus(message string, done func(error))
SetBackgroundStatus sets the one-line status the desktop shows for the application while it runs in the background. It returns at once, and done (nil logs a failure instead) runs on the loop with the result.
func (*Application) SetClipboard ¶
func (a *Application) SetClipboard(c *clipboard.Clipboard)
SetClipboard enables ctrl+c/x/v on every window's focused widget, plus the primary-selection behavior (middle-click paste, and copy-on-select once SetCopyOnSelect turns it on), and gives the clipboard the application's loop: its reads deliver there, it expires claims there (Clipboard.WriteExpiring), and its transfers end with it.
func (*Application) SetCopyOnSelect ¶
func (a *Application) SetCopyOnSelect(on bool)
SetCopyOnSelect turns X11-style copy-on-select on or off; a finished selection claims the primary selection, so a middle click pastes it. Default off. Needs a configured clipboard.
func (*Application) SetFocus ¶
func (a *Application) SetFocus(w widget.Widget) error
SetFocus implements atspi.Scene: focus moves to w in the window whose tree holds it, through that window's router (the path a click takes), and the window repaints.
func (*Application) SetIcon ¶
func (a *Application) SetIcon(img image.Image)
SetIcon posts a default window icon for every window of this application: windows without their own SetWindowIcon pick it up at their next apply, new windows at creation. A nil image clears the default. No-op (Debug) without the protocol.
func (*Application) SetInspect ¶
func (a *Application) SetInspect(on bool)
SetInspect arms the inspector and shows or hides the widget-tree overlay on every window. Arming enables the chords (ctrl+shift+i toggles, ctrl+shift+d dumps the tree to stdout); apps binding those chords themselves while armed lose out - the inspector consumes them first, exactly like the GTK inspector's own binding.
func (*Application) SetPopupErrorHandler ¶
func (a *Application) SetPopupErrorHandler(fn func(err error))
SetPopupErrorHandler installs fn to hear popups a widget asked for (widget.OpenMenu, widget.OpenPopover) that could not open, so the app can show a toast. fn runs on the loop goroutine.
func (*Application) SetReconnect ¶
func (a *Application) SetReconnect(opts *ReconnectOptions)
SetReconnect enables reconnect-with-rebuild (nil disables it, the default: the clean exit with DisconnectExitCode). It applies to a connection lost without a protocol verdict (a compositor that killed the client for a protocol error would do so again) and to applications whose every window came from NewWindow, NewLayer, or a dialog - a host built outside the application cannot be rebuilt, and its loop exits as before.
What survives: widget trees and everything in them (text, scroll, selection, focus within each window), window handles, titles, sizes, limits, maximized and fullscreen requests, transient parents, dialog modality, layer anchors/margins/zones/layers, the output a layer was pinned to (re-resolved by name), content types, opacity, queues, timers, accelerators, and the clipboard handle. What does not: the compositor's own state - clipboard contents, drags, open popovers and tooltips (closed, OnClosed firing), session locks, idle inhibitors and idle watches, pointer constraints, and pending configure serials. Code that holds the *wlsession.Session itself must read the current one from Application.Session after a reconnect.
func (*Application) SetSurfaceMotion ¶
func (a *Application) SetSurfaceMotion(on bool)
SetSurfaceMotion turns lys-ui's own surface tweens on or off app-wide: the fade and slide every layer surface, dialog, popover and tooltip plays as it maps and closes. An application that animates its surfaces' content itself (through a widget.Revealer) turns them off so the two do not stack; surfaces then map and close at once, with the same callbacks in the same order.
func (*Application) SetToastHost ¶
func (a *Application) SetToastHost(h Host)
SetToastHost names the window toasts go to when their config names none (nil: the focused window, then the first) - a main window that collects every dialog's feedback.
func (*Application) SetTooltipFace ¶
func (a *Application) SetTooltipFace(f *render.Typeface)
SetTooltipFace sets the face hover tooltips render with; nil is the system UI face.
func (*Application) SetTooltipOptions ¶
func (a *Application) SetTooltipOptions(o TooltipOptions)
SetTooltipOptions tunes every window's tooltips.
func (*Application) SetTransferErrorHandler ¶
func (a *Application) SetTransferErrorHandler(fn func(err error))
SetTransferErrorHandler installs fn to hear clipboard and drag transfers that failed - a paste (ctrl+v or middle-click) or a drop whose peer sent more than xfer.MaxPayload, stalled past the transfer deadline, or broke the pipe - so the app can show a toast. An empty clipboard is not an error. fn runs on the loop goroutine.
func (*Application) SetWindowIcon ¶
func (a *Application) SetWindowIcon(w *Window, img image.Image)
SetWindowIcon posts icon as w's toplevel icon, overriding the application default: rasterized at the compositor's preferred sizes into square shm buffers, applied on the window's next commit (the repaint this schedules). A nil img clears the window's icon back to the default. No-op (Debug) without the protocol; never a failure.
func (*Application) ShortcutsDialog ¶
func (a *Application) ShortcutsDialog(parent *Window) (*Dialog, error)
ShortcutsDialog opens the shortcuts overview (GTK ShortcutsWindow): every app-wide binding of the registry, grouped by the sections DescribeAction gave their actions, keys drawn as keycaps. Esc closes it.
func (*Application) ShowToast ¶
func (a *Application) ShowToast(text string, timeout time.Duration, cfg *ToastConfig) (*widget.Toast, error)
ShowToast shows a transient feedback card over a window: bottom- centered by default (ToastConfig moves it), auto-dismissed after timeout, hover-pausable, optionally actionable through the returned toast (widget.Toast.SetAction). Toasts stack on the host window up to the cap, the oldest dropping first; when the last one goes, the window's tree is back to exactly what it was. A host window that closes hands its live toasts to the window toasts go to next, so a toast outlives the dialog it was raised from. A nil config uses the defaults. With no window or no font to show it, the toast is dropped and the error says why.
func (*Application) ToggleInspect ¶
func (a *Application) ToggleInspect()
ToggleInspect flips the overlay, arming the inspector on the way.
func (*Application) WatchFD ¶
func (a *Application) WatchFD(fd int, events int16, fn func(revents int16)) (stop func(), err error)
WatchFD calls fn on the loop goroutine each time fd is ready for the poll events (unix.POLLIN, say), with the revents seen. fn should consume what made the fd ready: the next wait starts only after fn returned. The fd stays the caller's; stop (or the loop ending) ends the watch, after which fn is not called again.
func (*Application) WatchFiles ¶
func (a *Application) WatchFiles(paths []string, recursive bool, fn func()) (stop func(), err error)
WatchFiles calls fn on the loop goroutine when anything under paths changes: a watched file written, created, removed, renamed or its metadata changed, or the same for the entries of a watched directory. With recursive, directories are watched with their whole trees, including directories created later. A burst of changes read in one pass is one call. A path that does not exist yet is skipped.
type BackgroundRequest ¶
type BackgroundRequest struct {
// Reason is shown to the user.
Reason string
// Autostart asks to start the application at login.
Autostart bool
// Commandline is what autostart runs; empty uses the desktop
// file's Exec.
Commandline []string
// DBusActivatable autostarts through D-Bus activation.
DBusActivatable bool
}
BackgroundRequest asks to keep running without windows and, optionally, to start at login.
type BackgroundResult ¶
type BackgroundResult struct {
// Background reports whether the app may run in the background.
Background bool
// Autostart reports whether the app starts at login.
Autostart bool
}
BackgroundResult is the desktop's answer.
type BarConfig ¶
type BarConfig struct {
// Output pins the bar to one output; nil lets the compositor
// choose.
Output *Output
// Bar is the bar shown; its edge picks the anchors.
Bar *widget.Bar
// Layer is the stack layer, LayerTop for a usual bar.
Layer Layer
// Margin is the gap between the bar and its screen edge, and the
// screen ends it runs to.
Margin int32
// Exclusive reserves the bar's thickness, and the margin, so
// maximized windows stop at it.
Exclusive bool
// Namespace tags the surface for compositor rules.
Namespace string
// OnPresented mirrors LayerConfig.OnPresented.
OnPresented func()
}
BarConfig shows a widget.Bar as a layer surface along a screen edge.
type BarWindow ¶
type BarWindow struct {
*LayerWindow
// contains filtered or unexported fields
}
BarWindow is a bar's layer surface. Its thickness is the bar's natural size across its edge, and its exclusive zone follows that thickness as the bar's content changes.
func (*BarWindow) SetEdge ¶
SetEdge moves the bar to edge: re-anchored, its margins and zone following, and its content turned to the new orientation.
func (*BarWindow) SetExclusive ¶
SetExclusive starts or stops reserving the bar's edge: on, the exclusive zone takes the bar's current thickness and follows it as the bar resizes; off, it drops to 0 and maximized windows reach the edge again. The change applies with the next commit.
type Clipboard ¶
Clipboard is the seat's regular and primary selections: ReadText and WriteText for ctrl+c/v content, ReadPrimary and WritePrimary for the middle-click selection, ReadImageBytes and WriteImage for pictures, and Write and Read for any transfer.Content (uri lists, HTML). It is the alias external consumers name the clipboard by; hand it to Application.SetClipboard (or Config.Clipboard) to wire the built-in copy and paste keys, and keep it to put content on the clipboard from application code - a launcher copying a calculator result, say. Reads take a callback: a peer may never answer, so the payload arrives on the loop goroutine when the transfer ends.
func NewClipboard ¶
NewClipboard wires a clipboard to the session's data device (and its primary-selection device where the compositor has one). A compositor without either still yields a Clipboard; its reads and writes then fail with ErrClipboardUnavailable instead of panicking.
type ContentType ¶
type ContentType = wlsession.ContentType
ContentType hints what a surface shows (wp_content_type_v1), so the compositor may tune for it: a photo viewer, a video, a game.
type DataControl ¶
type DataControl = datacontrol.Device
DataControl is the seat's data-control device, over ext-data-control-v1 or wlr-data-control-unstable-v1. Get it from Application.DataControl; call it from the loop goroutine.
type DataControlProtocol ¶
type DataControlProtocol = datacontrol.Protocol
DataControlProtocol names the protocol a DataControl speaks.
type Dialog ¶
type Dialog struct {
// contains filtered or unexported fields
}
Dialog is a modal child window with a response callback. While it is open every other window's input is blocked at the application level, and — when the compositor offers xdg-dialog-v1 and the dialog has a parent — at the window level too: the compositor blocks input to the parent itself. Respond fires OnResponse exactly once and closes the dialog.
func (*Dialog) Close ¶
func (d *Dialog) Close()
Close closes the dialog without a response; OnResponse does not run.
func (*Dialog) Closed ¶
Closed reports whether the dialog already produced a response or was closed.
type DialogButton ¶
type DialogButton struct {
Label string
Response string
Role DialogButtonRole
// Appearance styles the button (libadwaita's AdwResponseAppearance);
// the zero value styles the default response suggested and the
// others plain.
Appearance ResponseAppearance
}
DialogButton is one button in a dialog's button row. Role, when set, decides the keyboard mapping explicitly: ButtonRoleDefault binds Enter, ButtonRoleCancel binds Escape. Without roles the positional fallbacks apply - first button default, last cancel.
type DialogButtonRole ¶
type DialogButtonRole uint8
DialogButtonRole is the keyboard role a dialog button opts into.
const ( // ButtonRoleNormal is a plain button: no key bound. ButtonRoleNormal DialogButtonRole = iota // ButtonRoleDefault binds Enter. ButtonRoleDefault // ButtonRoleCancel binds Escape. ButtonRoleCancel )
Button roles.
type DialogConfig ¶
type DialogConfig struct {
Title string
// Description is muted text under the title, 8px below it: the
// header's second line. A dialog with one may have no Content.
Description string
// Width and Height size the window; a zero Height fits the dialog's
// content at Width.
Width, Height uint32
Content widget.Widget
Buttons []DialogButton
DefaultResponse string
CancelResponse string
// ValidateResponse, when set, vetoes a response: returning false
// keeps the dialog open (nothing responded, nothing closed), so a
// dialog can refuse to close until its content is valid - the file
// picker refusing an empty selection, say. It runs before
// OnResponse on every Respond, including the Esc and Enter keys.
ValidateResponse func(response string) bool
OnResponse func(response string)
// OnClosed runs once the dialog window closed, after OnResponse when
// a response closed it, and also when it closed without one (the
// compositor's close, Close).
OnClosed func()
// Modal blocks every other window's input while the dialog is
// open (and, with an xdg parent, asks the compositor to block the
// parent itself). False - the GTK default - leaves the
// application fully interactive under the dialog; the preset
// dialogs set it themselves.
Modal bool
// Focus, when set, takes the keyboard focus as the dialog opens: a
// widget of Content, its first field.
Focus widget.Widget
// Bare makes Content the whole window: no button row, no card,
// Background as the window's clear color. The content carries its
// own buttons (styled by the application's stylesheet) and answers
// through Dialog.Respond; Esc and Enter still map to the cancel and
// default responses.
Bare bool
Background render.Color
}
DialogConfig declares a dialog: content widget plus a button row. Esc responds with CancelResponse, Enter with DefaultResponse (either may be empty to disable that key). Width and Height are the dialog's initial size in logical pixels, like every size in the toolkit; zero lets the compositor pick.
type DialogParent ¶
type DialogParent interface {
// contains filtered or unexported methods
}
DialogParent is what a dialog can be parented to: a toplevel Window carries the xdg parent link and the modality hint, a LayerWindow parents at the application level only (layer surfaces have no xdg parent), and nil makes an application-level dialog.
type DialogPresentation ¶
type DialogPresentation uint8
DialogPresentation is how an AdaptiveDialog shows.
const ( // PresentAuto floats the dialog when the parent is wide enough and // shows it as a bottom sheet inside the parent otherwise. PresentAuto DialogPresentation = iota // PresentFloating always shows a parented dialog window. PresentFloating // PresentBottomSheet always shows a sheet inside the parent window. PresentBottomSheet )
type DisconnectReason ¶
type DisconnectReason = wlsession.DisconnectReason
DisconnectReason classifies why the connection ended: the compositor went away (crash/reload/upgrade), or it raised a fatal protocol error against this client first.
type DisconnectedEvent ¶
type DisconnectedEvent struct {
Reason DisconnectReason
// Err is the *wlsession.DisconnectError the loop failed with.
Err error
// Reconnecting reports that Run will dial the compositor again and
// rebuild the windows (SetReconnect) rather than return.
Reconnecting bool
}
DisconnectedEvent is what OnDisconnect receives: the classified reason and the underlying wire error.
type EmojiInserter ¶
type EmojiInserter interface {
Insert(s string)
}
EmojiInserter is the insertion half an emoji target offers: Entry and TextArea both implement it (Insert at the caret).
type FileDialogConfig ¶
type FileDialogConfig struct {
// Title names the dialog window; empty gets a mode default.
Title string
// StartDir opens the picker here (home when empty); StartName
// pre-fills the save name row.
StartDir string
StartName string
// Filters offers file name patterns; nil accepts everything.
Filters []widget.FileFilter
// Recents adds the Recent place and records chosen files in the
// desktop's recently-used list.
Recents bool
// OnOpen receives the chosen absolute paths exactly once, on the
// loop goroutine, after the dialog closed.
OnOpen func(paths []string)
}
FileDialogConfig declares an open dialog: where it starts, what it accepts, and where the choice lands. The OpenFileDialog family (#82) wraps widget.FileChooser - the pure-Go picker - in the standard Dialog, with the recent-files list (XDG recently-used.xbel, shared with the desktop) and a validating ok button that keeps the dialog open until the choice is valid; the picker is portal-free by design, a portal backend can later ride the same DirSource seam, and the decision is recorded in docs/application-model.md.
type FontChooserConfig ¶
type FontChooserConfig struct {
// Family and Size preselect the family and size; a zero Size is
// 13px.
Family string
Size float64
// FamilyOnly drops the size row, for a setting that names a family
// alone; OnFont then reports Size unchanged.
FamilyOnly bool
// MonospaceOnly lists only fixed-width families, the filter locked
// on.
MonospaceOnly bool
// OnFont runs on confirmation with the family as the font lists it
// ("JetBrains Mono", the name config files and fontconfig show,
// which sysfont.Best accepts) and the size in pixels.
OnFont func(family string, size float64)
}
FontChooserConfig declares a font chooser dialog.
type GlobalShortcut ¶
type GlobalShortcut struct {
// contains filtered or unexported fields
}
GlobalShortcut is one registered shortcut, over either transport.
func (*GlobalShortcut) Destroy ¶
func (s *GlobalShortcut) Destroy()
Destroy unregisters the shortcut. Call on the loop goroutine.
func (*GlobalShortcut) HandleGlobalShortcutV1Pressed ¶
func (s *GlobalShortcut) HandleGlobalShortcutV1Pressed(ev wlr.GlobalShortcutV1PressedEvent)
HandleGlobalShortcutV1Pressed implements the protocol listener.
func (*GlobalShortcut) HandleGlobalShortcutV1Released ¶
func (s *GlobalShortcut) HandleGlobalShortcutV1Released(ev wlr.GlobalShortcutV1ReleasedEvent)
HandleGlobalShortcutV1Released implements the protocol listener.
type Gravity ¶
Gravity is the side of its anchor a popover opens on.
func GravityOf ¶
func GravityOf(s widget.PopoverSide) Gravity
GravityOf is the popup gravity a widget popover side opens on, for a PopoverConfig opened directly: a bar's popover away from its edge is GravityOf(bar.Edge().PopoverSide()).
type Host ¶
type Host interface {
// EnsureUsable gates drawing until the first configure completed.
EnsureUsable() error
// Closed reports whether the compositor or user ended the surface.
Closed() bool
// Size returns the current size in surface (logical) pixels.
Size() (int, int)
// HostSurface returns the underlying wl_surface.
HostSurface() *wl.Surface
}
Host is the piece of the shell a widget tree is hosted on: a layer surface or a toplevel window. Both types implement it.
type InhibitFlags ¶
type InhibitFlags uint32
InhibitFlags are the session actions Inhibit holds off.
const ( // InhibitLogout holds off logging out. InhibitLogout InhibitFlags = 1 << iota // InhibitUserSwitch holds off switching users. InhibitUserSwitch // InhibitSuspend holds off suspending. InhibitSuspend // InhibitIdle holds off the session going idle. InhibitIdle )
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is a claimed single-instance guard: the primary's listener, or an inert holder when multiple instances are allowed. The zero value is not usable; ClaimInstance builds one.
func ClaimInstance ¶
func ClaimInstance(cfg InstanceConfig, inv Invocation) (*Instance, bool, error)
ClaimInstance runs the single-instance protocol for cfg, forwarding inv when a primary already holds the AppID. It reports the Instance and true for the primary, nil and false for a secondary that has forwarded and should exit cleanly - the GApplication remote exit, conventionally status 0. A non-nil error means the claim itself failed (empty AppID, or the runtime directory accepts no socket); callers that prefer availability over uniqueness may treat it as primary.
Claim before connecting the session: a secondary never touches the compositor. Forwarded invocations buffer until Bind wires the hooks onto a live application.
func (*Instance) Bind ¶
func (ins *Instance) Bind(a *Application)
Bind wires the forwarded invocations onto an application's loop goroutine: every hook runs with event-callback guarantees, and anything buffered between the claim and Bind flushes through. The listener dies with the loop, like every other loop-owned resource.
type InstanceConfig ¶
type InstanceConfig struct {
// AppID keys the instance: one primary per AppID per runtime
// directory. The window AppID is the natural key.
AppID string
// AllowMultipleInstances skips the guard: every process runs as its
// own primary, relm4's allow_multiple_instances. The socket, the
// forwarding, and the hooks are all inert.
AllowMultipleInstances bool
// OnCommandLine receives a secondary's argv and working directory
// on the loop goroutine; empty argv is the plain-activate case (the
// secondary ran with no arguments). It fires once per forwarded
// invocation.
OnCommandLine func(args []string, cwd string)
// OnOpen receives the paths a secondary asked to open, in its
// stead, on the loop goroutine. When it is set and the invocation
// carries paths, it replaces OnCommandLine for that invocation -
// GApplication's open signal replacing command-line.
OnOpen func(paths []string, cwd string)
}
InstanceConfig declares the single-instance contract. The zero config guards nothing; an empty AppID is an error, because every un-keyed app would collide on one socket.
type Invocation ¶
Invocation is what one process run forwards to the primary: the command-line arguments, the paths it asks to open, the working directory they came from, and the XDG activation token the launcher provided, if any.
func OSInvocation ¶
func OSInvocation(args []string) Invocation
OSInvocation builds the Invocation of this process from args (os.Args without the program): "--open PATH" pairs move into Open, and a token in XDG_ACTIVATION_TOKEN rides along - lys-ui's launch convention, so every single-instance app understands --open without parsing it twice.
type Key ¶
Key declares one typed settings entry: a name in the persisted file and the default used before anything was ever written. Keys are values, declared once next to the code that owns them:
var darkMode = app.Key[bool]{Name: "dark-mode", Default: false}
func (Key[T]) Binding ¶
Binding returns the key as a loop-owned Binding wired two-way: widget edits Set and persist the key, key changes update every widget bound to it, and the equal-value no-ops on both sides keep the wiring echo-free. Call it once per key per application and bind widgets to the returned Binding:
entry.BindText(nameKey.Binding(settings))
func (Key[T]) Get ¶
Get returns the key's current value: the cached Set value, else the file's, else the default. Safe from any goroutine.
type KeyboardMode ¶
type KeyboardMode = layersurface.KeyboardMode
KeyboardMode selects how the compositor gives a surface keyboard focus.
type Layer ¶
type Layer = layersurface.Layer
Layer selects the stack layer a layer surface renders in.
type LayerConfig ¶
type LayerConfig struct {
// Output pins the surface to one output; nil lets the compositor
// choose.
Output *wlsession.Output
// Layer selects the stack layer (background through overlay).
Layer layersurface.Layer
// Anchor selects the anchored edges.
Anchor layersurface.Anchor
// Margin distances the surface from the anchored edges.
Margin layersurface.Margins
// Width and Height: the surface size in logical pixels (the device
// scale is applied once at the buffer boundary). A zero axis is
// automatic, as in gtk4-layer-shell: anchored on both of its edges
// it stretches across the output, otherwise it takes Root's natural
// size and follows it as the content changes.
Width, Height uint32
// ExclusiveZone reserves space along anchored edges; negative
// values distance instead.
ExclusiveZone int32
// Keyboard selects keyboard interactivity (none, exclusive,
// on-demand) — a launcher overlay grabs with exclusive.
Keyboard layersurface.KeyboardMode
// Namespace tags the surface for compositor-side rules.
Namespace string
// Scale is the initial integer output scale; zero derives it from
// Output, then 1. With the fractional-scale protocol the
// compositor's preferred scale overrides this live.
Scale int
// Root is the window's widget tree.
Root widget.Widget
// Background fills the frame before the tree paints. An alpha of
// 255 sets wl_surface.set_opaque_region automatically; an alpha
// below 255 leaves the surface translucent for compositor blur
// (panels: alpha 200-235 - docs/architecture.md, rule 13).
Background render.Color
// Opaque forces the opaque region even though Background is
// translucent; see app.Config.Opaque.
Opaque bool
// ContentType and BackgroundBlur mirror WindowConfig.
ContentType ContentType
BackgroundBlur bool
// OnPress, OnPointerMove, OnResize, OnKey, KeyCapture mirror
// WindowConfig.
OnPress func(button uint32, over widget.Widget)
OnPointerMove func(x, y float64)
OnResize func(width, height int)
OnKey func(r *widget.Router, keycode uint32, mods wlsession.Mods)
KeyCapture func(Accel) bool
// OnPresented mirrors WindowConfig.OnPresented.
OnPresented func()
// OwnMotion is a surface that plays its own enter and exit, so the
// toolkit adds none: it would scale the whole buffer in software on
// every frame, far too dear for one that covers an output, and Close
// then closes at once.
OwnMotion bool
// OnClosed runs when the surface closed or its output went away.
OnClosed func()
}
LayerConfig declares a layer surface: the bar/panel/launcher shape. Anchors, margins, exclusive zone, and keyboard interactivity are declarative — set once at creation, per gtk4-layer-shell's model.
type LayerSurfacer ¶
type LayerSurfacer interface {
// LayerPopupSurface returns the layer surface popups attach to.
LayerPopupSurface() *wlr.ZwlrLayerSurfaceV1
}
LayerSurfacer is implemented by layer-shell hosts so popovers can parent to the layer surface, which has no xdg_surface of its own.
type LayerWindow ¶
type LayerWindow struct {
// contains filtered or unexported fields
}
LayerWindow is the application's handle on one layer surface.
func (*LayerWindow) BackgroundBlurActive ¶
func (l *LayerWindow) BackgroundBlurActive() bool
BackgroundBlurActive reports whether the compositor blurs behind the layer surface now.
func (*LayerWindow) Close ¶
func (l *LayerWindow) Close()
Close closes the layer surface from the client side: the exit tween runs first — the launcher/panel-reveal fade-out — with the loop kept alive and event-driven until it lands, then the real destroy.
func (*LayerWindow) Closed ¶
func (l *LayerWindow) Closed() bool
Closed reports whether the compositor or client closed the surface. A surface running its exit tween reads closed here (the logical state flipped at Close) while its last frames still paint.
func (*LayerWindow) EnsureUsable ¶
func (l *LayerWindow) EnsureUsable() error
EnsureUsable implements Host for the layer handle.
func (*LayerWindow) HostSurface ¶
func (l *LayerWindow) HostSurface() *wl.Surface
HostSurface implements Host for the layer handle.
func (*LayerWindow) KeyboardMode ¶
func (l *LayerWindow) KeyboardMode() KeyboardMode
KeyboardMode is the surface's keyboard interactivity.
func (*LayerWindow) LayerPopupSurface ¶
func (l *LayerWindow) LayerPopupSurface() *wlr.ZwlrLayerSurfaceV1
LayerPopupSurface implements LayerSurfacer for the layer handle.
func (*LayerWindow) OnScaleChanged ¶ added in v0.2.5
func (l *LayerWindow) OnScaleChanged(fn func(num, denom int)) (cancel func())
OnScaleChanged runs fn on the loop each time the layer surface's device scale changes, as Window.OnScaleChanged does.
func (*LayerWindow) Scale ¶ added in v0.2.5
func (l *LayerWindow) Scale() (num, denom int)
Scale returns the device scale the layer surface presents at, as Window.Scale does.
func (*LayerWindow) SetAnchor ¶
func (l *LayerWindow) SetAnchor(a layersurface.Anchor) error
SetAnchor re-anchors the surface (a bar moving edges); an automatic axis re-resolves against the new anchors. Lands with the next commit.
func (*LayerWindow) SetBackgroundBlur ¶
func (l *LayerWindow) SetBackgroundBlur(on bool)
SetBackgroundBlur turns the compositor blur behind the layer surface on or off (LayerConfig.BackgroundBlur); it applies with the next frame.
func (*LayerWindow) SetContentType ¶
func (l *LayerWindow) SetContentType(ct ContentType) error
SetContentType hints the layer surface's content kind.
func (*LayerWindow) SetExclusiveZone ¶
func (l *LayerWindow) SetExclusiveZone(zone int32) error
SetExclusiveZone changes the reserved space along the anchored edge - an auto-hiding bar handing its zone back.
func (*LayerWindow) SetFocus ¶
func (l *LayerWindow) SetFocus(w widget.Widget) error
SetFocus moves the surface's keyboard focus to w, a widget of its tree; it fails as widget.Router.SetFocus does, and with ErrClosed once the surface is gone. The compositor still decides whether the surface itself holds the keyboard.
func (*LayerWindow) SetKeyboardMode ¶
func (l *LayerWindow) SetKeyboardMode(mode KeyboardMode) error
SetKeyboardMode changes the keyboard interactivity: None, Exclusive, or OnDemand. Popovers opened on a None surface switch it to OnDemand while they are open, so their grab can take the keyboard.
func (*LayerWindow) SetLayer ¶
func (l *LayerWindow) SetLayer(layer layersurface.Layer) error
SetLayer moves the surface to another stack layer (a panel rising to overlay while shown); needs layer shell v2.
func (*LayerWindow) SetMargin ¶
func (l *LayerWindow) SetMargin(m layersurface.Margins) error
SetMargin changes the distances from the anchored edges.
func (*LayerWindow) SetOpacity ¶
func (l *LayerWindow) SetOpacity(alpha float64) error
SetOpacity sets the opacity the compositor applies to the layer surface (a panel fading out, no repaint).
func (*LayerWindow) SetSize ¶
func (l *LayerWindow) SetSize(width, height uint32) error
SetSize requests a new surface size in logical pixels. A zero axis is automatic, as at creation (LayerConfig.Width): stretched when anchored on both edges, the content's natural size otherwise. The size applies with the next commit, and the compositor's configure answer resizes the buffers.
func (*LayerWindow) Size ¶
func (l *LayerWindow) Size() (int, int)
Size implements Host for the layer handle.
type LockSurface ¶
type LockSurface struct {
// Root is the surface's widget tree; build a fresh one per call.
Root widget.Widget
// Background fills the frame before the tree paints. Keep it
// opaque (alpha 255): the lock surface is what hides the session.
Background render.Color
// OnPress, OnPointerMove, and OnKey mirror LayerConfig.
OnPress func(button uint32, over widget.Widget)
OnPointerMove func(x, y float64)
OnKey func(r *widget.Router, keycode uint32, mods wlsession.Mods)
// OnClosed runs when this surface went away: the lock ended, or
// its output was unplugged.
OnClosed func()
// Focus, when set, takes keyboard focus as the surface is created
// (the password entry), so typing lands without a click.
Focus widget.Widget
}
LockSurface is the content of one output's lock surface.
type Margins ¶
type Margins = layersurface.Margins
Margins is the space between a surface and the edges it anchors to, in logical pixels.
type MenuPopover ¶
type MenuPopover struct {
// contains filtered or unexported fields
}
MenuPopover is a menu tree presented as nested popovers: GTK's PopoverMenu with the NESTED flag, where each submenu is its own popover beside its row instead of sliding in place (MenuStack). A submenu opens when its row is hovered, clicked, or entered with Right or Enter; hovering a sibling row closes it; Esc or Left closes the innermost level only; a leaf row closes the whole chain before its action runs.
func (*MenuPopover) Closed ¶
func (m *MenuPopover) Closed() bool
Closed reports whether the menu has gone away.
func (*MenuPopover) Depth ¶
func (m *MenuPopover) Depth() int
Depth is the number of open levels: 1 with no submenu open, 0 once closed.
func (*MenuPopover) Level ¶
func (m *MenuPopover) Level(depth int) *widget.Menu
Level returns the open menu at depth (0 is the root), nil past the chain.
func (*MenuPopover) SetItems ¶
func (m *MenuPopover) SetItems(items ...widget.MenuItem)
SetItems updates the tree while it is open, in place - the shape a live model update takes (a tray application re-publishing its menu): every open level takes its new rows, and an open submenu stays open while its row still leads to one; where the path broke, the levels below close.
type MenuPopoverConfig ¶
type MenuPopoverConfig struct {
// Anchor is the widget the root menu opens beside.
Anchor widget.Boundser
// Gravity picks the root menu's side.
Gravity Gravity
// Gap is the distance between the anchor and the root menu.
Gap int
// the row in its reading direction by default (right; left in a
// right-to-left menu). The compositor flips it when there is no
// room.
SubmenuSide SubmenuSide
// AccelLabel formats every row's Accel for display at every level
// (widget.Menu.AccelLabel); nil writes it the canonical way,
// "<Control>r" as Ctrl+R.
AccelLabel func(accel string) string
// Face and SizePx paint every level.
Face render.Font
SizePx float64
// Items is the root level; a row with Items opens a submenu.
Items []widget.MenuItem
// OnClosed runs once when the whole menu goes away.
OnClosed func()
// Parent, when set, nests the root menu under that open popover: a
// menu opened from a popover's content.
Parent *Popover
}
MenuPopoverConfig declares a menu tree opened as nested popovers.
type NotifyAction ¶
NotifyAction is one desktop-notification action.
type NotifyOptions ¶
type NotifyOptions struct {
// Icon is an icon-theme name or a file path; whoever shows the
// notification resolves it, the same themed pipeline as SetIcon.
Icon string
// Timeout is the expiry hint: zero means the server default,
// negative means never expire.
Timeout time.Duration
// Urgency raises the priority; see notify.Priority.
Urgency notify.Priority
// Actions become the notification's buttons; activating one fires
// OnAction with its key, on the loop.
Actions []NotifyAction
// DefaultAction makes the notification body itself activatable.
DefaultAction NotifyAction
// OnAction fires when an action (or the default) activated.
OnAction func(key string)
// OnClosed fires when the notification closed, with the reason
// when the transport reports one.
OnClosed func(reason notify.CloseReason)
}
NotifyOptions carries the optional halves of a notification. The callbacks - like every app callback - run on the loop goroutine, bridged from the notifier's signal goroutine through Invoke.
type OpenButton ¶
OpenButton is a button that opens a file dialog and a dropdown of recent files; choosing either fires OnOpen with the path. It embeds the composite Widget (button plus recents dropdown).
func (*OpenButton) Recents ¶
func (ob *OpenButton) Recents() []string
Recents returns a copy of the recent file paths the dropdown shows.
func (*OpenButton) RefreshRecents ¶
func (ob *OpenButton) RefreshRecents()
RefreshRecents rebuilds the recents dropdown from the recent-files manager, keeping at most cfg.Recents entries that still exist on disk. It looks at the disk off the loop, and the dropdown follows on the loop once it knows.
type OpenButtonConfig ¶
type OpenButtonConfig struct {
Label string
StartDir string
Filters []widget.FileFilter
Folder bool
Recents int
OnOpen func(path string)
}
OpenButtonConfig declares an open button: the label, the starting directory, file filters, whether it picks folders, how many recent files to show, and the OnOpen callback for the chosen path.
type Output ¶
Output is a connected display (xdg-output identity plus the wayland global). LayerConfig pins surfaces to one; Session.Outputs lists them.
type PageLayout ¶
type PageLayout struct {
Setup PageSetup
// DPI is the raster resolution, device pixels per inch.
DPI int
// Size is the whole page.
Size widget.Size
// Printable is the area inside the margins.
Printable render.Rect
}
PageLayout is what a PrintJob paints against: sizes in logical pixels, 1/96 inch as in CSS, so a widget tree laid out at Size prints at its on-screen size.
type PageMargins ¶
type PageMargins struct{ Top, Bottom, Left, Right float64 }
PageMargins are a page's margins in millimetres, on the page as oriented.
type PageOrientation ¶
type PageOrientation uint8
PageOrientation is how the page sits on the paper.
const ( // Portrait is the paper upright. Portrait PageOrientation = iota // Landscape turns the paper a quarter counterclockwise. Landscape // ReversePortrait is portrait upside down. ReversePortrait // ReverseLandscape is landscape upside down. ReverseLandscape )
func (PageOrientation) String ¶
func (o PageOrientation) String() string
type PageSetup ¶
type PageSetup struct {
Paper Paper
Orientation PageOrientation
Margins PageMargins
}
PageSetup is the paper, orientation and margins pages are laid out on.
type Paper ¶
type Paper struct {
// Name is the PWG 5101.1 name, such as "iso_a4"; the print dialog
// preselects it.
Name string
Width, Height float64
}
Paper is a paper size in portrait, in millimetres.
type PointerConstraint ¶
type PointerConstraint struct {
// contains filtered or unexported fields
}
PointerConstraint is a pointer lock or confinement on one host (Application.LockPointer, ConfinePointer). The compositor activates it while the pointer is over the host; OnActive hears that. The compositor never force-releases a constraint on a key of its own, so an application that locks the pointer must offer the way out - the convention is an accelerator (Escape, say) that calls Release.
func (*PointerConstraint) Active ¶
func (p *PointerConstraint) Active() bool
Active reports whether the constraint is in effect.
func (*PointerConstraint) OnActive ¶
func (p *PointerConstraint) OnActive(fn func(active bool))
OnActive registers fn to hear each activation and deactivation, on the loop goroutine.
func (*PointerConstraint) Release ¶
func (p *PointerConstraint) Release()
Release ends the constraint. Closing the host releases it too.
func (*PointerConstraint) SetCursorHint ¶
func (p *PointerConstraint) SetCursorHint(x, y float64)
SetCursorHint asks for the cursor to reappear at (x, y) in the host's surface when a lock ends; it applies with the next frame.
type Popover ¶
type Popover struct {
// contains filtered or unexported fields
}
Popover is a widget-anchored transient popup. It closes on a click away (PopoverDismissal), Esc, or Dismiss; OnClosed fires exactly once.
func (*Popover) Close ¶ added in v0.1.2
func (p *Popover) Close()
Close closes the popover at once, skipping any exit: its content is needed elsewhere this instant. OnClosed still fires exactly once.
func (*Popover) Dismiss ¶
func (p *Popover) Dismiss()
Dismiss closes the popover programmatically, through its Exit if it has one; OnClosed still fires exactly once.
func (*Popover) Scale ¶ added in v0.2.5
Scale returns the device scale the popover presents at: its host's, when it opened.
type PopoverConfig ¶
type PopoverConfig struct {
// Anchor is the widget to open beside; its Bounds must be current
// (any arranged widget qualifies). AnchorAt and AnchorRect anchor
// to a point or a rect instead - a context menu at the pointer.
Anchor widget.Boundser
// Gravity picks the side; zero opens below the anchor.
Gravity Gravity
// Gap is the distance between the anchor and the popover, kept
// on whichever side the compositor places it.
Gap int
// Content is the popover's widget tree (a Menu is the common
// case). Content that sets no layout motion of its own gets a
// smooth one, so when it grows while open the popover springs to
// the new size: the surface grows at once, the visible box follows.
Content widget.Widget
// OnClosed runs exactly once when the popover goes away, whatever
// the cause.
OnClosed func()
// Focus, when set, is the widget inside Content that takes keyboard
// focus as the popover opens (a form's first Entry, as GTK focuses
// a popover's first input): typing then reaches it without a click.
Focus widget.Widget
// Parent, when set, nests the popover under that open popover (an
// xdg_popup child of its surface, GTK's nested PopoverMenu): Anchor
// is a widget inside the parent, the host argument is ignored, and
// the popover closes with its parent. A parent holds one child at a
// time: opening another closes the one before.
Parent *Popover
// Dismissal is how a click elsewhere treats the popover. A nested
// popover grabs exactly when its parent does.
Dismissal PopoverDismissal
// Exit, when set, plays the popover's way out whatever closes it
// (Esc, a click away, Dismiss): its input and keyboard go at once,
// and the surface stays up until Exit calls done. Nil closes through
// the popup's own exit tween.
Exit func(done func())
// MaxWidth and MaxHeight cap the content when measured, in place
// of the default ceiling, the largest output's size - a list held
// shorter than the output; a wide one wrapping its text. Zero keeps
// the default.
MaxWidth, MaxHeight int
// BackgroundBlur asks the compositor to blur what is behind the
// popover's content, its translucent background showing the desktop
// behind it, which a backdrop-filter in the content cannot see. Where
// no blur is in effect Content carries the blur-unavailable class, so
// its style can turn opaque; the region and class are out by the
// popover's first paint.
BackgroundBlur bool
}
PopoverConfig declares a popover anchored to a widget.
type PopoverDismissal ¶ added in v0.1.2
type PopoverDismissal uint8
PopoverDismissal is how a popover treats a click elsewhere, and with it who holds the keyboard while it is open.
const ( // PopoverGrabs takes the seat grab: a click elsewhere closes the // popover, which holds the keyboard until it closes. For menus. PopoverGrabs PopoverDismissal = iota // PopoverClickAway closes on a click elsewhere with no seat grab: // keys stay with the focused window until a press into the popover // takes them, or from the start if Focus names a widget. Esc reaches // it while it holds them, and beside them on a compositor offering // lys_escape_v1 (lys-wm). It needs layer shell and wp_viewporter. PopoverClickAway // PopoverSticky is GTK's autohide=false: no seat grab, and only // Dismiss closes it (a re-click on its button, a click in its own // empty area). PopoverSticky )
type PreferencesDialog ¶
type PreferencesDialog struct {
*Dialog
View *widget.PreferencesView
}
PreferencesDialog is libadwaita's AdwPreferencesDialog: a dialog around a widget.PreferencesView whose toasts show inside it.
type PrintJob ¶
type PrintJob struct {
// Title names the document in the print dialog, the queue and the
// PDF.
Title string
// Setup is the page setup ExportPDF uses and the print dialog
// starts from; Print uses the setup the user confirms.
Setup PageSetup
// DPI is the raster resolution; zero is DefaultPrintDPI.
DPI int
// Pages returns how many pages the document has on layout. It runs
// on the caller's goroutine (the loop for Print).
Pages func(layout PageLayout) int
// Paint draws page (from 0) on cv, which starts transparent and
// prints as white. cv is in logical pixels: layout.Size covers the
// page. It runs where Pages runs.
Paint func(cv *render.Canvas, page int, layout PageLayout)
}
PrintJob describes a document for Print or ExportPDF.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress reports a ProgressDialog's progress to its caller: the fraction path drives a determinate bar, Pulse switches to the busy spinner.
func (*Progress) SetFraction ¶
SetFraction moves the determinate bar to f (clamped to [0, 1]); building on a pulsing dialog is a no-op.
type ReconnectOptions ¶
type ReconnectOptions struct {
// Timeout is how long to keep dialing while the compositor comes
// back; zero is ten seconds. Past it, Run returns the disconnect
// error as without reconnect.
Timeout time.Duration
// Connect dials the new session; nil is wlsession.Connect (the
// WAYLAND_DISPLAY the process started with).
Connect func() (*wlsession.Session, error)
// OnReconnected, optional, runs on the loop goroutine once every
// window is rebuilt on the new session.
OnReconnected func()
}
ReconnectOptions turn a lost compositor connection into a rebuild instead of the clean exit.
type Reducer ¶
type Reducer[S, M any] struct { // contains filtered or unexported fields }
Reducer is shared state changed only through typed messages, relm4's Reducer: Emit sends a message from any goroutine, reduce applies it to the state on the loop in emit order, and subscribers hear the new state only when reduce reports a change. The set of transitions is the message type, and nothing else writes the state.
func NewReducer ¶
func NewReducer[S, M any](a *Application, initial S, reduce func(state *S, msg M) (changed bool)) *Reducer[S, M]
NewReducer creates a Reducer at initial, reducing with reduce on the application's loop. After the loop ends it comes back stopped.
func (*Reducer[S, M]) Close ¶
func (r *Reducer[S, M]) Close()
Close stops the reducer: queued messages are dropped and later Emits do nothing.
func (*Reducer[S, M]) Emit ¶
func (r *Reducer[S, M]) Emit(msg M)
Emit queues msg for reduction on the loop. Safe from any goroutine.
type ResizeEdge ¶
type ResizeEdge uint32
ResizeEdge is the edge or corner an interactive resize drags.
const ( EdgeTop ResizeEdge = xdg.ToplevelResizeEdgeTop EdgeBottom ResizeEdge = xdg.ToplevelResizeEdgeBottom EdgeLeft ResizeEdge = xdg.ToplevelResizeEdgeLeft EdgeTopLeft ResizeEdge = xdg.ToplevelResizeEdgeTopLeft EdgeBottomLeft ResizeEdge = xdg.ToplevelResizeEdgeBottomLeft EdgeRight ResizeEdge = xdg.ToplevelResizeEdgeRight EdgeTopRight ResizeEdge = xdg.ToplevelResizeEdgeTopRight EdgeBottomRight ResizeEdge = xdg.ToplevelResizeEdgeBottomRight )
Resize edges, the xdg_toplevel resize_edge values.
type ResponseAppearance ¶
type ResponseAppearance uint8
ResponseAppearance is a dialog button's look.
const ( // AppearanceAuto styles the default response suggested and the // others plain. AppearanceAuto ResponseAppearance = iota // AppearancePlain is the outlined button. AppearancePlain // AppearanceSuggested is the primary fill. AppearanceSuggested // AppearanceDestructive is the destructive fill, for a response that // deletes or resets. AppearanceDestructive )
Response appearances.
type SaveDialogConfig ¶
type SaveDialogConfig struct {
Title string
StartDir string
StartName string
Filters []widget.FileFilter
Recents bool
// SkipOverwriteConfirm returns a path that already exists without
// asking. By default the picker asks, and declining returns to it.
SkipOverwriteConfirm bool
// OnSave receives the chosen absolute path exactly once, on the
// loop goroutine, after any replace question was accepted and the
// dialog closed.
OnSave func(path string)
}
SaveDialogConfig is FileDialogConfig for naming a file to write.
type Selection ¶
type Selection = datacontrol.Selection
Selection names one of the seat's two selections.
type SelectionClaim ¶
type SelectionClaim = datacontrol.Claim
SelectionClaim is our ownership of one selection.
type SelectionOffer ¶
type SelectionOffer = datacontrol.Offer
SelectionOffer is one selection's content as its owner advertised it: the mime types in the owner's order, readable until the compositor replaces the selection.
type SelectionSource ¶
type SelectionSource = datacontrol.Source
SelectionSource is what a SetSelection claim offers: mime types in preference order, and the payload for each.
type SessionLock ¶
type SessionLock struct {
// contains filtered or unexported fields
}
SessionLock is the application's handle on one session lock.
func (*SessionLock) Cancel ¶
func (l *SessionLock) Cancel() error
Cancel withdraws a lock the compositor has not confirmed yet. It fails with ErrLocked once the lock holds: a locked session only ends through Unlock.
func (*SessionLock) Locked ¶
func (l *SessionLock) Locked() bool
Locked reports whether the compositor confirmed the lock and it has not ended.
func (*SessionLock) Outputs ¶
func (l *SessionLock) Outputs() []*Output
Outputs returns the outputs currently covered by a lock surface.
func (*SessionLock) SetFocus ¶
func (l *SessionLock) SetFocus(w widget.Widget) error
SetFocus moves keyboard focus to w in the lock surface whose tree holds it (a password entry, after a failed attempt re-enabled it); it fails as widget.Router.SetFocus does. The compositor still decides which lock surface holds the keyboard.
func (*SessionLock) State ¶
func (l *SessionLock) State() LockState
State returns the lock's lifecycle state.
func (*SessionLock) Unlock ¶
func (l *SessionLock) Unlock() error
Unlock ends a locked session: the compositor unlocks and every lock surface is destroyed. It fails with ErrNotLocked while the lock is still pending — only a confirmed lock can be unlocked — and with ErrLockEnded once the lock is over. A process that exits right after unlocking must call Session.Roundtrip first (outside the event loop), or the compositor may never see the request.
type SessionLockConfig ¶
type SessionLockConfig struct {
// Surface builds the lock surface for one output. It runs for
// every output present at LockSession and again for each output
// plugged in while the lock lives — a reconnected monitor without
// a lock surface would show the compositor's fallback color. Must
// not be nil.
Surface func(out *Output) LockSurface
// OnLocked fires once the compositor confirmed the lock: every
// output shows lock content and nothing unlocked is visible. Safe
// to suspend from here.
OnLocked func()
// OnFinished fires when the compositor ended the lock instead:
// it denied it (another client holds the session lock) or ended a
// locked session by its own policy. Every surface is gone and the
// lock handle is spent.
OnFinished func()
}
SessionLockConfig declares a session lock.
type SessionState ¶
type SessionState uint32
SessionState is the login session's state the Inhibit portal reports.
const ( // SessionRunning is the normal state. SessionRunning SessionState = 1 // SessionQueryEnd asks applications whether the session may end; // an application inhibits logout to object. SessionQueryEnd SessionState = 2 // SessionEnding means the session is ending. SessionEnding SessionState = 3 )
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
Settings is the persisted settings bag, GSettings/relm4's Settings chapter (#80): schema-declared typed keys with defaults, a JSON file under the user config directory, atomic writes, and change notifications delivered on the loop goroutine through the same Stream shape every other messenger uses. The file is <UserConfigDir>/<AppID>/settings.json; a missing file, a corrupt file, or a value whose type drifted all fall back to the key's default, and the next write replaces the file with a clean one.
Reads snapshot from any goroutine; Set mutates memory and notifies from any goroutine (notification crosses onto the loop). The file follows off the caller's goroutine, a burst of Sets coalesced into one write, and Run's exit flushes whatever is still unwritten; Flush does it on demand.
A key has one type for the life of the application - two Key values with the same Name and different types are a programming error and fail loudly at the type assert.
func NewSettings ¶
func NewSettings(a *Application, appID string) *Settings
NewSettings loads the settings file for appID, falling back to defaults per key. The application wires the notifications onto its loop; settings outlive it harmlessly (later Sets stop notifying and write at once, there being no loop left to stall or exit to flush).
type SharedState ¶
type SharedState[T any] struct { // contains filtered or unexported fields }
SharedState is a loop-owned observable value: Update mutates it from any goroutine and delivers the new value to every subscriber on the loop goroutine - relm4's SharedState, with the change stream being the same Stream shape every other messenger uses. One state shared across windows updates every window's widgets from the one subscription point, which is what makes cross-window sharing correct by construction: there is no per-window copy to fall out of sync.
func NewSharedState ¶
func NewSharedState[T any](a *Application, initial T) *SharedState[T]
NewSharedState creates a SharedState holding initial, notifying on the application's loop.
func (*SharedState[T]) Close ¶
func (s *SharedState[T]) Close()
Close stops change notifications; later Updates still mutate the value.
func (*SharedState[T]) Get ¶
func (s *SharedState[T]) Get() T
Get returns a snapshot of the value, safe from any goroutine: the read guard. Copying is the guard - a snapshot cannot be raced by a later Update.
func (*SharedState[T]) Subscribe ¶
func (s *SharedState[T]) Subscribe(fn func(T)) (cancel func())
Subscribe registers fn to receive the value after every Update, on the loop goroutine. The returned cancel removes the subscription.
func (*SharedState[T]) Update ¶
func (s *SharedState[T]) Update(f func(*T))
Update applies f to the value and notifies subscribers with the new value on the loop goroutine. Notification is unconditional, like relm4's set: f already knows whether it changed anything, and callers that need change detection compare against Get inside f.
type Shortcut ¶
type Shortcut []Accel
Shortcut is a key sequence: one Accel, or a chord of several pressed in turn ("ctrl+x ctrl+s", "g g").
func ParseShortcut ¶
ParseShortcut parses a shortcut: accelerators (ParseAccel's forms) separated by spaces, each step pressed after the last.
type Stream ¶
type Stream[Msg any] struct { // contains filtered or unexported fields }
Stream is a typed publish/subscribe messenger onto the loop goroutine: Send publishes from any goroutine, Subscribe registers a callback that receives every message in Send order. It is the one shape behind the relm4 concepts that are all fan-out under different names: a message broker (a Stream held in a package variable, so any nesting depth reaches it without threading senders) and SharedState change notifications.
Delivery is deferred and non-reentrant: a Send from inside a subscriber (or from the loop itself) lands at the top of the loop's next pass.
func NewStream ¶
func NewStream[Msg any](a *Application) *Stream[Msg]
NewStream creates a Stream on the application's loop. After the loop ends it comes back stopped: Sends are dropped, subscriptions never fire.
func (*Stream[Msg]) Close ¶
func (s *Stream[Msg]) Close()
Close stops the stream: queued messages are dropped, later Sends are no-ops, and subscriptions stop firing. The loop's end closes it too.
func (*Stream[Msg]) Send ¶
func (s *Stream[Msg]) Send(msg Msg)
Send publishes msg to every subscriber on the loop goroutine. Safe from any goroutine; a burst of Sends drains as one batch per loop pass.
func (*Stream[Msg]) Subscribe ¶
func (s *Stream[Msg]) Subscribe(fn func(Msg)) (cancel func())
Subscribe registers fn to receive every message on the loop goroutine. The returned cancel removes the subscription (idempotent, safe from any goroutine); it takes effect at the next message, so a cancel racing a pending batch never rewinds deliveries already made.
type SubmenuSide ¶
type SubmenuSide uint8
SubmenuSide is the side of its row a submenu opens on.
const ( )
Submenu sides, relative to the menu's reading direction.
type ToastConfig ¶
type ToastConfig struct {
// Host picks the window; nil shows the toast on the focused
// window, or the first one.
Host Host
// Position picks the edge; zero is the bottom.
Position ToastPosition
// Margin keeps the stack off the edge; zero uses the default.
Margin int
// MaxStack caps simultaneous toasts, oldest dropping first; zero
// uses the default.
MaxStack int
// Face renders the text; nil falls back to the tooltip face, then
// the default sans face.
Face *render.Typeface
}
ToastConfig declares a toast's placement: which window hosts it, the edge the stack hugs, the stack cap, and the text face.
type ToastPosition ¶
type ToastPosition uint8
ToastPosition picks the window edge a toast stack hugs.
const ( // ToastBottom stacks toasts above the bottom edge; zero, the // default. ToastBottom ToastPosition = iota // ToastTop stacks toasts below the top edge. ToastTop )
type TooltipOptions ¶
type TooltipOptions struct {
// Delay is how long the pointer rests on a widget before its
// tooltip opens.
Delay time.Duration
// Gap is the distance between the card and what it describes.
Gap int
// MaxWidth and MaxHeight cap the card; longer text wraps or clips.
MaxWidth, MaxHeight int
}
TooltipOptions tune hover tooltips; zero fields keep the defaults (a 500ms dwell, the card centered 4px below what it describes, at most 400x200).
type WMCapabilities ¶
type WMCapabilities = window.Capabilities
WMCapabilities is what the compositor's window management offers a window; Known is false until it said, and until then everything counts as available.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is the application's handle on one toplevel window.
func (*Window) Activate ¶
Activate asks the compositor to raise and focus the window with a token another client minted for it - the one in XDG_ACTIVATION_TOKEN, a notification action's ActivationToken, a portal's platform_data. The compositor decides. Nothing happens without xdg-activation, for an empty token, or on a closed window.
func (*Window) BackgroundBlurActive ¶
BackgroundBlurActive reports whether the compositor blurs behind the window now: asked for, offered, and its region sent.
func (*Window) BeginMove ¶
func (w *Window) BeginMove()
BeginMove starts the compositor's interactive move from the press that is under way (gtk_window_begin_move_drag): call it from a press handler - a custom title area, a drag handle - and the window follows the pointer until release. The protocol anchors the grab to the serial of the latest input event, which the session supplies; without one the compositor ignores the request.
func (*Window) BeginResize ¶
func (w *Window) BeginResize(edge ResizeEdge)
BeginResize starts an interactive resize from edge, like BeginMove (gtk_window_begin_resize_drag) - for app-drawn resize handles; the window's own edges already resize.
func (*Window) Capabilities ¶
func (w *Window) Capabilities() WMCapabilities
Capabilities reports the compositor's window-management offer.
func (*Window) Close ¶
func (w *Window) Close()
Close closes the window from the client side; the close-request veto does not apply to explicit closes. Animated kinds (dialogs) run the exit tween first: Closed flips immediately, input seals, and the real destroy waits for the tween to land. Plain toplevels close on the spot as before.
func (*Window) EnsureUsable ¶
EnsureUsable implements Host for the toplevel handle.
func (*Window) Fullscreen ¶
func (w *Window) Fullscreen()
Fullscreen asks the compositor to show the window fullscreen; the compositor picks the output (FullscreenOn names one). See Maximize.
func (*Window) FullscreenOn ¶
FullscreenOn asks for fullscreen on output (nil: the compositor's pick, as Fullscreen); a presentation on the projector, a video on the second monitor. See Maximize for the state-request contract.
func (*Window) HostSurface ¶
HostSurface implements Host for the toplevel handle.
func (*Window) Maximize ¶
func (w *Window) Maximize()
Maximize asks the compositor to maximize the window. Like every state request it is a hint: the compositor may refuse it, and the visible truth is whatever a later configure confirms - read that through State, never assume the request landed. The confirmed maximize usually arrives as an output-sized configure, which rides the same relayout path as any other resize.
func (*Window) Minimize ¶
func (w *Window) Minimize()
Minimize asks the compositor to minimize the window; a hint compositors without a minimized concept ignore. See Maximize for the state-request contract.
func (*Window) OnCapabilities ¶
func (w *Window) OnCapabilities(fn func(WMCapabilities))
OnCapabilities adds fn to what hears the compositor's window-management offer change (each wm_capabilities event); the window repaints after.
func (*Window) OnScaleChanged ¶ added in v0.2.5
OnScaleChanged runs fn on the loop each time the window's device scale changes, with the new one as Scale reports it, until cancel.
func (*Window) RequestActivationToken ¶
RequestActivationToken is Application.RequestActivationToken anchored to this window - a press on it rather than on the focused window. A closed window reports ErrClosed.
func (*Window) RequestAttention ¶
func (w *Window) RequestAttention()
RequestAttention asks the compositor to draw the user to the window (GTK's urgency hint) - background work finished, a message arrived. Wayland has no urgency flag: the request is xdg-activation without a user interaction behind it, which compositors answer by marking the window urgent or demanding attention instead of raising it (focus stealing prevention). A no-op without xdg-activation or once the window closed.
func (*Window) Scale ¶ added in v0.2.5
Scale returns the device scale the window presents at, num device pixels per denom logical ones; denom is 120. The compositor reports it before the window's first frame; until then it is the scale the window was created at.
func (*Window) SetBackgroundBlur ¶
SetBackgroundBlur turns the compositor blur behind the window on or off (WindowConfig.BackgroundBlur); it applies with the next frame.
func (*Window) SetCloseRequest ¶
SetCloseRequest installs a veto: return false to keep the window open when the compositor asks it to close.
func (*Window) SetContentType ¶
func (w *Window) SetContentType(ct ContentType) error
SetContentType hints the window's content kind; it applies with the next frame. Fails when the compositor lacks the protocol.
func (*Window) SetFocus ¶
SetFocus moves the window's keyboard focus to target, a widget of its tree; it fails as widget.Router.SetFocus does, and with ErrClosed once the window is gone.
func (*Window) SetMaxSize ¶
SetMaxSize constrains how far the compositor may resize the window up (set_max_size); zero axes are unconstrained.
func (*Window) SetMinSize ¶
SetMinSize constrains how far the compositor may resize the window down (set_min_size on the wire); zero axes are unconstrained. The limits also clamp layout client-side.
func (*Window) SetMinimized ¶
func (w *Window) SetMinimized()
SetMinimized asks the compositor to minimize the window. The protocol reports no state for a minimized window, so State keeps what was confirmed before; treat the window as invisible from here on.
func (*Window) SetOpacity ¶
SetOpacity sets the opacity the compositor applies to the whole window (0..1) - a fade with no repaint (wp_alpha_modifier_v1). It applies with the next frame; fails when the compositor lacks the protocol.
func (*Window) SetTitle ¶
SetTitle updates the compositor-visible window title at runtime - taskbars, alt-tab, wherever the environment shows it. The app's own HeaderBar text is separate and stays the app's to update.
func (*Window) SetTransientFor ¶
SetTransientFor keeps the window above parent and grouped with it - a toolbox, an inspector, a find bar window (xdg_toplevel.set_parent, the relation dialogs get by construction). nil releases it.
func (*Window) State ¶
func (w *Window) State() WindowState
State returns the compositor-confirmed window state: the state array of the last configure, not the set of requests the client sent. A refused request never shows up here.
func (*Window) ToggleMaximize ¶
func (w *Window) ToggleMaximize()
ToggleMaximize flips between maximized and restored by the last configure-confirmed state - the header double-press contract.
func (*Window) Unfullscreen ¶
func (w *Window) Unfullscreen()
Unfullscreen asks the compositor to leave fullscreen. See Maximize.
func (*Window) Unmaximize ¶
func (w *Window) Unmaximize()
Unmaximize asks the compositor to restore the window. See Maximize.
func (*Window) WhenPresented ¶
WhenPresented runs fn on the loop goroutine once the window's first commit after this call is presented.
type WindowConfig ¶
type WindowConfig struct {
// Title and AppID identify the window to the compositor.
Title, AppID string
// Width and Height request the initial size in logical pixels
// (surface coordinates; the device scale is applied once at the
// buffer boundary). A zero axis defaults to Root's natural size, as
// GTK's default size does: what the window takes when the
// compositor leaves the size to the client (a zero configure).
Width, Height uint32
// MinWidth and MinHeight constrain how far the compositor may
// resize the window down (set_min_size on the wire); zero axes are
// unconstrained. Layout clamps to the same limits client-side.
MinWidth, MinHeight uint32
// MaxWidth and MaxHeight constrain how far the compositor may
// resize the window up (set_max_size); zero axes are unconstrained,
// in logical pixels like every size in the toolkit.
MaxWidth, MaxHeight uint32
// Scale is the initial integer output scale the surface renders at;
// zero means 1. With the fractional-scale protocol the compositor's
// preferred scale (1.25 and friends) overrides this live.
Scale int
// Root is the window's widget tree.
Root widget.Widget
// Background fills the frame before the tree paints. An alpha of
// 255 sets wl_surface.set_opaque_region automatically; an alpha
// below 255 leaves the surface translucent for compositor blur
// (panels: alpha 200-235 - docs/architecture.md, rule 13).
Background render.Color
// Opaque forces the opaque region even though Background is
// translucent; see app.Config.Opaque.
Opaque bool
// ContentType hints what the window shows (a photo viewer, a video
// player, a game) so the compositor may tune for it; ignored where
// the compositor lacks wp_content_type_v1.
ContentType ContentType
// BackgroundBlur asks the compositor to blur what is behind the
// window, in Root's rounded shape, through ext_background_effect_v1
// - pair it with a translucent Background and a translucent root
// (the .glass class). Where no blur is in effect the root carries
// the blur-unavailable class, which turns .glass opaque.
BackgroundBlur bool
// Parent, when set, makes the window transient for it from the
// first commit (SetTransientFor): a toolbox above its owner.
Parent *Window
// OnPress fires after the router recorded a press (chrome drag,
// context menus).
OnPress func(button uint32, over widget.Widget)
// OnPointerMove receives raw pointer positions in surface pixels.
OnPointerMove func(x, y float64)
// OnResize runs on the loop goroutine whenever the window's logical
// size changes, the first configured size included, before that
// frame lays out.
OnResize func(width, height int)
// OnKey receives every key press routed to this window, after
// widget routing, for app-level keybindings.
OnKey func(r *widget.Router, keycode uint32, mods wlsession.Mods)
// KeyCapture sees every key press routed to this window (repeats
// included) before anything else does: built-in widget handling,
// accelerators, text routing, and OnKey. Returning true consumes
// the press. It is GTK's capture phase - a launcher's bound keys
// (Return, Tab, Up) act on its list while every other key still
// types into the focused entry. The Accel carries the keysym
// normalized as accelerators are and the held modifiers with caps
// lock masked out, so it compares equal to ParseAccel of a
// binding's name.
KeyCapture func(Accel) bool
// OnPresented runs on the loop goroutine once the compositor
// reports the window's first buffer presented through
// wp_presentation, retrying with the next commit when one is
// discarded; without wp_presentation, at the first frame callback
// after the first commit. That is the moment a replacement can
// take over from the surface it replaces. A reconnect rebuilds the
// window, and it runs again for the new one.
OnPresented func()
// OnClosed runs when the window closed (compositor request accepted,
// client Close, or output gone).
OnClosed func()
}
WindowConfig declares a toplevel window.
type WindowState ¶
WindowState is a toplevel's compositor-confirmed state: maximized, fullscreen, activated, tiled edges and so on (Window.State).
Source Files
¶
- about.go
- accel.go
- activation.go
- adaptivedialog.go
- app.go
- appearance.go
- application.go
- atspi.go
- bar.go
- chrome.go
- clickaway.go
- clipboard.go
- connect.go
- constraints.go
- datacontrol.go
- dialog.go
- disconnect.go
- dragdrop.go
- emojichooser.go
- explicitsync.go
- eyedropper.go
- filedialog.go
- fonts.go
- fontwarm.go
- globalshortcuts.go
- globalshortcuts_portal.go
- gpuarea.go
- gpurender.go
- ime.go
- inspect.go
- instance.go
- invoke.go
- launcher.go
- layerfit.go
- layersurface.go
- logger.go
- menupopover.go
- message.go
- notification.go
- openbutton.go
- popover.go
- portal.go
- portals.go
- primary.go
- print.go
- prompt.go
- reconnect.go
- resize.go
- scaleapi.go
- sessionlock.go
- settings.go
- stop.go
- style.go
- surfacehints.go
- surfacehost.go
- toast.go
- tooltip.go
- trace.go
- watch.go
- window.go
- windowctl.go
- windowicon.go