portal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package portal provides consent-aware Wayland input through the freedesktop RemoteDesktop portal.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnavailable indicates that the RemoteDesktop portal cannot satisfy the request.
	ErrUnavailable = errors.New("remote desktop portal unavailable")
	// ErrCancelled indicates that the user cancelled the portal interaction.
	ErrCancelled = errors.New("remote desktop portal request cancelled")
	// ErrRejected indicates that the portal rejected or otherwise failed a request.
	ErrRejected = errors.New("remote desktop portal request rejected")
	// ErrClosed indicates that the portal session is no longer active.
	ErrClosed = errors.New("remote desktop portal session closed")
	// ErrDeviceNotGranted indicates that the portal did not grant a requested device.
	ErrDeviceNotGranted = errors.New("remote desktop portal device not granted")
	// ErrScreenCastRequired indicates that an operation needs a selected stream.
	ErrScreenCastRequired = errors.New("remote desktop portal ScreenCast source required")
	// ErrStreamNotFound indicates that a stream ID is not part of the session.
	ErrStreamNotFound = errors.New("remote desktop portal stream not found")
)

Functions

This section is empty.

Types

type Capability

type Capability struct {
	Version              uint32
	AvailableDevices     DeviceType
	ScreenCastVersion    uint32
	AvailableSources     SourceType
	AvailableCursorModes CursorMode
	// ScreenCastIssue describes an optional ScreenCast capability-probe failure.
	// RemoteDesktop keyboard and pointer support remains usable when this is set.
	ScreenCastIssue string
}

Capability describes the RemoteDesktop portal interface exposed at runtime.

func Probe

func Probe(ctx context.Context) (capability Capability, retErr error)

Probe queries the live RemoteDesktop interface without starting a session or presenting a consent dialog.

func (Capability) Supports

func (c Capability) Supports(devices DeviceType) bool

Supports reports whether all requested device types are available.

func (Capability) SupportsCursorMode

func (c Capability) SupportsCursorMode(mode CursorMode) bool

SupportsCursorMode reports whether a cursor representation is advertised.

func (Capability) SupportsSources

func (c Capability) SupportsSources(sources SourceType) bool

SupportsSources reports whether every requested ScreenCast source is advertised.

type CursorMode

type CursorMode uint32

CursorMode controls how the cursor is represented in a ScreenCast stream.

const (
	CursorHidden   CursorMode = 1
	CursorEmbedded CursorMode = 2
	CursorMetadata CursorMode = 4
)

type DeviceType

type DeviceType uint32

DeviceType is a bitmask of input device types requested from the portal.

const (
	// DeviceKeyboard requests keyboard injection.
	DeviceKeyboard DeviceType = 1
	// DevicePointer requests pointer injection.
	DevicePointer DeviceType = 2
	// DeviceTouchscreen requests touchscreen injection. It requires at least one
	// ScreenCast source in OpenOptions.
	DeviceTouchscreen DeviceType = 4
)

type OpenOptions

type OpenOptions struct {
	Devices      DeviceType
	Sources      SourceType
	Multiple     bool
	CursorMode   CursorMode
	PersistMode  PersistMode
	RestoreToken string
}

OpenOptions configures input devices and optional ScreenCast source mapping.

type PersistMode

type PersistMode uint32

PersistMode controls whether the portal may return a single-use restore token.

const (
	PersistNone        PersistMode = 0
	PersistApplication PersistMode = 1
	PersistExplicit    PersistMode = 2
)

type Point

type Point struct{ X, Y int32 }

Point is a logical compositor coordinate.

type PointerAxis

type PointerAxis uint32

PointerAxis identifies a discrete pointer scroll axis.

const (
	// PointerAxisVertical is the vertical scroll axis.
	PointerAxisVertical PointerAxis = 0
	// PointerAxisHorizontal is the horizontal scroll axis.
	PointerAxisHorizontal PointerAxis = 1
)

type Session

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

Session is an authorized RemoteDesktop portal input session.

func Open

func Open(ctx context.Context, devices DeviceType) (*Session, error)

Open requests the selected input devices and starts a consent-aware remote desktop session. The caller controls how long user interaction may take via ctx and must close the returned session.

func OpenWithOptions

func OpenWithOptions(ctx context.Context, options OpenOptions) (*Session, error)

OpenWithOptions starts a RemoteDesktop session and optionally attaches ScreenCast sources for absolute pointer and touch coordinates.

func (*Session) Close

func (s *Session) Close() error

Close ends the portal session and releases the D-Bus connection. It is safe to call more than once.

func (*Session) Closed

func (s *Session) Closed() <-chan struct{}

Closed is closed when either the caller or the portal terminates the session.

func (*Session) Devices

func (s *Session) Devices() DeviceType

Devices returns the device types granted by the user.

func (*Session) KeyboardKeycode

func (s *Session) KeyboardKeycode(ctx context.Context, keycode int32, pressed bool) error

KeyboardKeycode sends a Linux evdev keycode transition.

func (*Session) KeyboardKeysym

func (s *Session) KeyboardKeysym(ctx context.Context, keysym int32, pressed bool) error

KeyboardKeysym sends an XKB keysym transition.

func (*Session) PointerAxis

func (s *Session) PointerAxis(ctx context.Context, dx, dy float64, finish bool) error

PointerAxis sends smooth pointer-axis motion.

func (*Session) PointerAxisDiscrete

func (s *Session) PointerAxisDiscrete(ctx context.Context, axis PointerAxis, steps int32) error

PointerAxisDiscrete sends discrete wheel steps.

func (*Session) PointerButton

func (s *Session) PointerButton(ctx context.Context, button int32, pressed bool) error

PointerButton sends a Linux evdev pointer button transition.

func (*Session) PointerMotion

func (s *Session) PointerMotion(ctx context.Context, dx, dy float64) error

PointerMotion sends relative pointer motion.

func (*Session) PointerMotionAbsolute

func (s *Session) PointerMotionAbsolute(ctx context.Context, stream uint32, x, y float64) error

PointerMotionAbsolute moves the pointer within a selected ScreenCast stream's logical coordinate space.

func (*Session) RestoreToken

func (s *Session) RestoreToken() string

RestoreToken returns the single-use token supplied by a persistent portal session, or an empty string when persistence was not granted.

func (*Session) Streams

func (s *Session) Streams() []Stream

Streams returns a copy of the ScreenCast streams attached to the session.

func (*Session) TouchDown

func (s *Session) TouchDown(ctx context.Context, stream, slot uint32, x, y float64) error

TouchDown starts a touch contact in a selected ScreenCast stream.

func (*Session) TouchMotion

func (s *Session) TouchMotion(ctx context.Context, stream, slot uint32, x, y float64) error

TouchMotion moves an active touch contact in a selected ScreenCast stream.

func (*Session) TouchUp

func (s *Session) TouchUp(ctx context.Context, slot uint32) error

TouchUp ends an active touch contact.

type Size

type Size struct{ Width, Height int32 }

Size is a logical compositor size.

type SourceType

type SourceType uint32

SourceType is a bitmask of ScreenCast sources attached to a RemoteDesktop session.

const (
	// SourceMonitor allows the user to select an existing monitor.
	SourceMonitor SourceType = 1
	// SourceWindow allows the user to select an application window.
	SourceWindow SourceType = 2
	// SourceVirtual creates a virtual monitor when supported by the portal.
	SourceVirtual SourceType = 4
)

type Stream

type Stream struct {
	NodeID         uint32
	ID             string
	Position       Point
	HasPosition    bool
	Size           Size
	HasSize        bool
	SourceType     SourceType
	MappingID      string
	PipeWireSerial uint64
}

Stream describes a ScreenCast stream attached to the RemoteDesktop session. NodeID is required by the portal Notify*Absolute methods. PipeWireSerial is preferred later when connecting to PipeWire for frame capture.

Jump to

Keyboard shortcuts

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