Documentation
¶
Overview ¶
Package portal provides consent-aware Wayland input through the freedesktop RemoteDesktop portal.
Index ¶
- Variables
- type Capability
- type CursorMode
- type DeviceType
- type OpenOptions
- type PersistMode
- type Point
- type PointerAxis
- type Session
- func (s *Session) Close() error
- func (s *Session) Closed() <-chan struct{}
- func (s *Session) Devices() DeviceType
- func (s *Session) KeyboardKeycode(ctx context.Context, keycode int32, pressed bool) error
- func (s *Session) KeyboardKeysym(ctx context.Context, keysym int32, pressed bool) error
- func (s *Session) PointerAxis(ctx context.Context, dx, dy float64, finish bool) error
- func (s *Session) PointerAxisDiscrete(ctx context.Context, axis PointerAxis, steps int32) error
- func (s *Session) PointerButton(ctx context.Context, button int32, pressed bool) error
- func (s *Session) PointerMotion(ctx context.Context, dx, dy float64) error
- func (s *Session) PointerMotionAbsolute(ctx context.Context, stream uint32, x, y float64) error
- func (s *Session) RestoreToken() string
- func (s *Session) Streams() []Stream
- func (s *Session) TouchDown(ctx context.Context, stream, slot uint32, x, y float64) error
- func (s *Session) TouchMotion(ctx context.Context, stream, slot uint32, x, y float64) error
- func (s *Session) TouchUp(ctx context.Context, slot uint32) error
- type Size
- type SourceType
- type Stream
Constants ¶
This section is empty.
Variables ¶
var ( 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 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 ¶
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 ¶
KeyboardKeycode sends a Linux evdev keycode transition.
func (*Session) KeyboardKeysym ¶
KeyboardKeysym sends an XKB keysym transition.
func (*Session) PointerAxis ¶
PointerAxis sends smooth pointer-axis motion.
func (*Session) PointerAxisDiscrete ¶
PointerAxisDiscrete sends discrete wheel steps.
func (*Session) PointerButton ¶
PointerButton sends a Linux evdev pointer button transition.
func (*Session) PointerMotion ¶
PointerMotion sends relative pointer motion.
func (*Session) PointerMotionAbsolute ¶
PointerMotionAbsolute moves the pointer within a selected ScreenCast stream's logical coordinate space.
func (*Session) RestoreToken ¶
RestoreToken returns the single-use token supplied by a persistent portal session, or an empty string when persistence was not granted.
func (*Session) TouchMotion ¶
TouchMotion moves an active touch contact in a selected ScreenCast stream.
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.