x11input

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupported identifies X11/XTEST capabilities the core cannot provide.
	// The public adapter translates it to robotgo.ErrNotSupported.
	ErrUnsupported = errors.New("X11 input operation is not supported")
)

Functions

This section is empty.

Types

type Backend

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

Backend owns one lazily opened X connection. Its mutex covers whole high-level transactions, including the stable scratch-keymap pool.

func New

func New(config Config) *Backend

New creates an independently owned, lazily connected X11 input backend.

func (*Backend) Click

func (backend *Backend) Click(button Button, double bool) error

func (*Backend) Close

func (backend *Backend) Close() error

func (*Backend) DragSmooth

func (backend *Backend) DragSmooth(x, y int, lowDelay, highDelay float64) error

func (*Backend) Key

func (backend *Backend) Key(event KeyEvent) (err error)

func (*Backend) KeyboardReady

func (backend *Backend) KeyboardReady() error

func (*Backend) Location

func (backend *Backend) Location() (int, int, error)

func (*Backend) MouseReady

func (backend *Backend) MouseReady() error

func (*Backend) MoveAbsolute

func (backend *Backend) MoveAbsolute(x, y int, _ []int) error

func (*Backend) MoveRelative

func (backend *Backend) MoveRelative(x, y int) error

func (*Backend) MoveSmooth

func (backend *Backend) MoveSmooth(x, y int, relative bool, lowDelay, highDelay float64) error

func (*Backend) Scroll

func (backend *Backend) Scroll(x, y int) error

func (*Backend) Text

func (backend *Backend) Text(event TextEvent) (err error)

func (*Backend) Toggle

func (backend *Backend) Toggle(button Button, down bool) error

type Button

type Button = byte

Button is an X11 core pointer-button number.

const (
	ButtonLeft       Button = 1
	ButtonMiddle     Button = 2
	ButtonRight      Button = 3
	ButtonWheelUp    Button = 4
	ButtonWheelDown  Button = 5
	ButtonWheelLeft  Button = 6
	ButtonWheelRight Button = 7
)

type Config

type Config struct {
	ResolveDisplay func() (string, error)
	Dialer         Dialer
	KeyHoldDelay   time.Duration
	Sleep          func(time.Duration)
}

Config defines immutable dependencies and timings for one Backend.

type Connection

type Connection interface {
	Close() error
	WaitForEvent() (open bool, err error)
	Setup() (Setup, error)
	InitXTest() error
	XTestVersion(major byte, minor uint16) (XTestVersion, error)
	GrabServer() error
	UngrabServer() error
	KeyboardMapping(first xproto.Keycode, count byte) (KeyboardMapping, error)
	ModifierMapping() ([]xproto.Keycode, error)
	ChangeKeyboardMapping(first xproto.Keycode, perKeycode byte, keysyms []xproto.Keysym) error
	PressedKeys() ([]byte, error)
	QueryPointer(root xproto.Window) (PointerState, error)
	FakeInput(eventType, detail byte, root xproto.Window, x, y int16) error
}

Connection owns every X11 primitive used by Backend. The boundary is intentionally complete so another process can own the same transaction and lifecycle machinery without exposing *xgb.Conn to the stateful core. Close must synchronously finish verified transport cleanup and unblock WaitForEvent, even when it returns an error.

type Dialer

type Dialer interface {
	Dial(display string) (Connection, error)
}

Dialer creates one complete X11 connection owned by Backend.

func NewGuardianDialer

func NewGuardianDialer(options GuardianOptions) Dialer

NewGuardianDialer returns a Dialer whose X11 connections live in a re-executed guardian process. It never falls back to an in-process XGB connection when guardian startup or authentication fails.

type GuardianDialer

type GuardianDialer struct {
	Options GuardianOptions
}

GuardianDialer moves ownership of an X11 connection into a re-executed helper over a token-authenticated Linux abstract socket whose kernel peer credentials are verified by the parent. The helper survives a targeted SIGKILL of its parent and restores connection-owned input and keyboard mappings when the control socket closes.

func (GuardianDialer) Dial

func (dialer GuardianDialer) Dial(display string) (Connection, error)

Dial starts a guardian and opens the requested display inside that helper.

type GuardianOptions

type GuardianOptions struct {
	Executable     string
	StartupTimeout time.Duration
	RequestTimeout time.Duration
	CleanupTimeout time.Duration
	CrashSettle    time.Duration
}

GuardianOptions controls the bounded lifecycle of a Pure-Go X11 guardian. Zero values select conservative defaults. Executable is primarily a test seam; production callers should leave it empty to re-exec /proc/self/exe.

type KeyEvent

type KeyEvent struct {
	Keysym       uint32
	Modifiers    []uint32
	Down         bool
	Tap          bool
	AllowScratch bool
	ForceScratch bool
}

KeyEvent is a normalized X11 keysym transaction. Public key names and aliases are resolved by the caller before entering the stateful core.

type KeyboardMapping

type KeyboardMapping struct {
	KeysymsPerKeycode byte
	Keysyms           []xproto.Keysym
}

KeyboardMapping is a detached snapshot of one contiguous keyboard-map range.

type PointerState

type PointerState struct {
	RootX int16
	RootY int16
	Mask  uint16
}

PointerState is the root-relative position and core button mask.

type Setup

type Setup struct {
	Root       xproto.Window
	MinKeycode xproto.Keycode
	MaxKeycode xproto.Keycode
}

Setup is the immutable X11 connection information needed by the input core.

type TextEvent

type TextEvent struct {
	Keysyms []uint32
	Delay   time.Duration
}

TextEvent is one prevalidated text transaction expressed as X11 keysyms.

type XTestVersion

type XTestVersion struct {
	Major byte
	Minor uint16
	Valid bool
}

XTestVersion is the server's negotiated XTEST protocol version.

Jump to

Keyboard shortcuts

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