Documentation
¶
Overview ¶
Package wayland reaches the screen and the input of a Wayland desktop through the compositor's D-Bus API. A Wayland client cannot read the screen or send input to other clients the way an X11 client can; the compositor offers both itself, and hands the picture over as a PipeWire stream. See docs/design/wayland-host.md.
Only Linux has an implementation. The first one is GNOME's: Mutter's org.gnome.Mutter.ScreenCast and org.gnome.Mutter.RemoteDesktop, which is what GNOME's own portal backend and gnome-remote-desktop use.
Index ¶
- Constants
- Variables
- func HasMutter(c *dbus.Conn) bool
- func SessionBus() (*dbus.Conn, error)
- type Capture
- type Monitor
- type MutterSession
- func (s *MutterSession) Button(code int32, down bool) error
- func (s *MutterSession) Clipboard(ctx context.Context) (string, error)
- func (s *MutterSession) Close() error
- func (s *MutterSession) Done() <-chan struct{}
- func (s *MutterSession) Err() error
- func (s *MutterSession) Key(code uint32, down bool) error
- func (s *MutterSession) Keysym(sym uint32, down bool) error
- func (s *MutterSession) Pointer(x, y float64) error
- func (s *MutterSession) PointerBy(dx, dy float64) error
- func (s *MutterSession) SetClipboard(ctx context.Context, text string) (<-chan struct{}, error)
- func (s *MutterSession) Stream() Stream
- func (s *MutterSession) Wheel(axis uint32, steps int32) error
- type Stream
Constants ¶
const ( BtnLeft int32 = 0x110 BtnRight int32 = 0x111 BtnMiddle int32 = 0x112 BtnSide int32 = 0x113 // back BtnExtra int32 = 0x114 // forward AxisVert uint32 = 0 AxisHoriz uint32 = 1 )
Evdev pointer buttons, as Button takes them (linux/input-event-codes.h).
Variables ¶
var ErrEnded = errors.New("the screen sharing was stopped on the host")
ErrEnded is the error of a session the desktop ended: the user stopped the screen sharing from GNOME's indicator, or logged out.
Functions ¶
func HasMutter ¶
HasMutter reports whether GNOME's compositor offers its screen cast and remote desktop API on the bus.
func SessionBus ¶
SessionBus connects to the logged-in user's session bus: $DBUS_SESSION_BUS_ADDRESS, else the user bus socket in /run/user/<uid>/bus. A host started from ssh or a system unit often has no variable although the desktop's bus is there. The connection is the caller's own; Close ends it.
Types ¶
type Capture ¶
type Capture struct {
// Connector is the monitor to record; "" records the primary one.
// It is ignored when Area is set.
Connector string
// Area, when not empty, records that part of the desktop instead,
// in the layout's coordinates: several monitors in one picture.
Area image.Rectangle
// Cursor draws the pointer into the picture.
Cursor bool
}
Capture says what a Mutter session records.
type Monitor ¶
type Monitor struct {
// Connector names the monitor ("eDP-1", "HDMI-1"); a recording of one
// monitor asks for it by this name.
Connector string
// X and Y are the monitor's position in the desktop's layout.
X, Y int
// Width and Height are the monitor's current mode in pixels, turned
// as the monitor is (a portrait monitor is taller than wide).
Width, Height int
// Scale is the monitor's scale factor (1, 1.25, 2, ...).
Scale float64
Primary bool
}
Monitor is one of the desktop's monitors as the compositor lays them out.
type MutterSession ¶
type MutterSession struct {
// contains filtered or unexported fields
}
MutterSession is a running Mutter remote desktop session with one recorded stream. Input sent through it reaches the whole desktop.
func StartMutter ¶
StartMutter starts a remote desktop session that records what cap asks for, and waits until its PipeWire stream is there. GNOME shows its screen sharing indicator while the session runs.
Give each session a connection of its own and close it after the session: Mutter refuses to stop a session that never started, so what a failed start left behind in the compositor ends only with the connection.
func (*MutterSession) Button ¶
func (s *MutterSession) Button(code int32, down bool) error
Button presses or releases an evdev pointer button (BtnLeft, ...).
func (*MutterSession) Clipboard ¶
func (s *MutterSession) Clipboard(ctx context.Context) (string, error)
Clipboard reads the desktop's clipboard as text. It fails when the clipboard is empty or holds no text.
func (*MutterSession) Close ¶
func (s *MutterSession) Close() error
Close stops the session. It is safe to call more than once and after the desktop ended the session.
func (*MutterSession) Done ¶
func (s *MutterSession) Done() <-chan struct{}
Done is closed when the session ends; Err then says why (nil after Close).
func (*MutterSession) Err ¶
func (s *MutterSession) Err() error
Err is why the session ended, or nil while it runs or after Close.
func (*MutterSession) Key ¶
func (s *MutterSession) Key(code uint32, down bool) error
Key presses or releases a key by its evdev code; the desktop's keyboard layout decides what it types.
func (*MutterSession) Keysym ¶
func (s *MutterSession) Keysym(sym uint32, down bool) error
Keysym presses or releases the key that types sym in the desktop's layout. Mutter ignores a keysym the layout cannot type, without an error.
func (*MutterSession) Pointer ¶
func (s *MutterSession) Pointer(x, y float64) error
Pointer moves the pointer to x, y in the recorded stream's pixels (0, 0 is its top left corner).
func (*MutterSession) PointerBy ¶
func (s *MutterSession) PointerBy(dx, dy float64) error
PointerBy moves the pointer by dx, dy pixels (a pointer the viewer has locked).
func (*MutterSession) SetClipboard ¶
func (s *MutterSession) SetClipboard(ctx context.Context, text string) (<-chan struct{}, error)
SetClipboard makes text the desktop's clipboard, offered by this session until another program takes the clipboard or the session ends. The returned channel receives a value each time a program has read it.
func (*MutterSession) Stream ¶
func (s *MutterSession) Stream() Stream
Stream is the recorded stream.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package waylandtest starts a private headless GNOME desktop for tests: a session bus, PipeWire, WirePlumber and Mutter with one virtual monitor.
|
Package waylandtest starts a private headless GNOME desktop for tests: a session bus, PipeWire, WirePlumber and Mutter with one virtual monitor. |