Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAppNotFound = fmt.Errorf("application not found")
ErrAppNotFound is returned by AppProvider methods when the requested application is not running. Callers should use errors.Is to distinguish "not found" from other errors.
var ErrNoAppProvider = fmt.Errorf("no application provider")
ErrNoAppProvider is returned when no application provider is available.
Functions ¶
func Register ¶
func Register(provider Provider)
Register adds a display server provider to the global registry This is typically called from init() functions in display-specific packages
func RegisterAppProvider ¶ added in v0.176.0
func RegisterAppProvider(ap AppProvider)
RegisterAppProvider adds an AppProvider to the global registry. Called from init() in platform-specific packages (macOS, X11, Wayland).
Types ¶
type AppProvider ¶ added in v0.176.0
type AppProvider interface {
// ListRunning returns all running applications visible to the windowing system.
// On macOS this includes every NSRunningApplication. On X11 this enumerates
// top-level windows via _NET_CLIENT_LIST and deduplicates by PID.
ListRunning(ctx context.Context) ([]domain.Application, error)
// Activate brings a running application to the foreground by its stable ID
// (as returned by ListRunning or GetFocused). Returns an error wrapping
// ErrAppNotFound when no such application is running, or a generic error
// when the OS refuses the activation.
Activate(ctx context.Context, id string) error
// GetFocused returns the currently focused (frontmost) application.
// Returns nil with a nil error when no application is focused (headless
// session with no windows).
GetFocused(ctx context.Context) (*domain.Application, error)
}
AppProvider is the cross-platform application focus management interface (macOS via NSWorkspace, X11 via EWMH; Wayland hides global window state from clients, so no provider registers there).
Providers registered via RegisterAppProvider are process-lifetime singletons: they own their platform resources and there is no Close.
func DetectAppProvider ¶ added in v0.176.0
func DetectAppProvider() (AppProvider, error)
DetectAppProvider returns the first registered AppProvider. Platform packages only register a provider when their display server is actually available, so registration order is the preference order. Returns ErrNoAppProvider when none is available (headless, or Wayland).
type DisplayController ¶
type DisplayController interface {
// Screen operations
CaptureScreenBytes(ctx context.Context, region *Region) ([]byte, error)
CaptureScreen(ctx context.Context, region *Region) (image.Image, error)
GetScreenDimensions(ctx context.Context) (width, height int, err error)
// Mouse operations
GetCursorPosition(ctx context.Context) (x, y int, err error)
MoveMouse(ctx context.Context, x, y int) error
ClickMouse(ctx context.Context, button MouseButton, clicks int) error
ScrollMouse(ctx context.Context, clicks int, direction string) error
// Keyboard operations
TypeText(ctx context.Context, text string, delayMs int) error
SendKeyCombo(ctx context.Context, combo string) error
// Lifecycle
Close() error
}
DisplayController abstracts display server-specific operations (X11, Wayland, macOS Quartz)
type DisplayInfo ¶
type DisplayInfo struct {
Name string // "x11", "wayland", "macos"
SupportsRegions bool
SupportsMouse bool
SupportsKeyboard bool
MaxTextLength int
RequiresElevation bool
}
DisplayInfo contains metadata about a display server or protocol
type MouseButton ¶
type MouseButton int
MouseButton represents a mouse button
const ( MouseButtonLeft MouseButton = iota MouseButtonMiddle MouseButtonRight )
func ParseMouseButton ¶
func ParseMouseButton(s string) MouseButton
ParseMouseButton parses a string into a MouseButton
func (MouseButton) String ¶
func (b MouseButton) String() string
String returns the string representation of a mouse button
type Provider ¶
type Provider interface {
// GetController creates a new DisplayController (display is auto-detected from environment)
GetController() (DisplayController, error)
// GetDisplayInfo returns information about the display server/protocol
GetDisplayInfo() DisplayInfo
// IsAvailable returns true if this display server is available on the current system
IsAvailable() bool
}
Provider creates DisplayController instances for a specific display server/protocol
func DetectDisplay ¶
DetectDisplay returns the first available display server provider Priority is determined by registration order (first registered has highest priority)
Directories
¶
| Path | Synopsis |
|---|---|
|
EventBridge is pure Go and used cross-platform (opentask extension bridge, control event forwarding), so unlike the rest of this package it carries no build tag.
|
EventBridge is pure Go and used cross-platform (opentask extension bridge, control event forwarding), so unlike the rest of this package it carries no build tag. |