darwinwindow

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 10 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

Overview

Package darwinwindow provides RobotGo's Pure-Go macOS window backend.

Index

Constants

View Source
const AccessibilityBackend = "macos-accessibility"

Variables

View Source
var (
	// ErrPermission reports missing macOS Accessibility permission.
	ErrPermission = errors.New("Pure-Go macOS window control requires Accessibility permission")
	// ErrUnsupported reports a window operation without a trustworthy macOS equivalent.
	ErrUnsupported = errors.New("Pure-Go macOS window operation is unsupported")
)
View Source
var (
	ErrAccessibilityUnavailable = errors.New("macOS Accessibility inspection is unavailable")
	ErrAccessibilityStaleTarget = errors.New("macOS Accessibility target is stale")
	ErrAccessibilityInvalidTree = errors.New("macOS Accessibility returned an invalid tree")
)

Functions

This section is empty.

Types

type AccessibilityActionRequest

type AccessibilityActionRequest struct {
	Target          AccessibilityTarget
	Reference       []byte
	Expected        AccessibilityElementExpectation
	Action          string
	Value           []byte
	Postcondition   *AccessibilityElementCondition
	BeforeFinalGate func(context.Context) error
	BeforeDispatch  func(context.Context) error
}

type AccessibilityActionResult

type AccessibilityActionResult struct {
	Dispatched       bool
	AlreadySatisfied bool
	CleanupComplete  bool
}

type AccessibilityBounds

type AccessibilityBounds struct {
	X      int
	Y      int
	Width  int
	Height int
}

type AccessibilityConditionResult

type AccessibilityConditionResult struct {
	Satisfied       bool
	CleanupComplete bool
}

type AccessibilityElementCondition

type AccessibilityElementCondition struct {
	Kind  AccessibilityElementConditionKind
	State string
}

type AccessibilityElementConditionKind

type AccessibilityElementConditionKind string
const (
	AccessibilityElementConditionStatePresent           AccessibilityElementConditionKind = "state-present"
	AccessibilityElementConditionStateAbsent            AccessibilityElementConditionKind = "state-absent"
	AccessibilityElementConditionFocused                AccessibilityElementConditionKind = "focused"
	AccessibilityElementConditionNotFocused             AccessibilityElementConditionKind = "not-focused"
	AccessibilityElementConditionValueEqualsActionValue AccessibilityElementConditionKind = "value-equals-action-value"
)

type AccessibilityElementExpectation

type AccessibilityElementExpectation struct {
	Role      string
	Name      string
	Sensitive bool
	States    []string
	Bounds    *AccessibilityBounds
	Actions   []string
}

type AccessibilityLimits

type AccessibilityLimits struct {
	MaxElements            uint32
	MaxDepth               uint32
	MaxStringBytes         uint32
	MaxReferenceBytes      uint32
	MaxTotalReferenceBytes uint32
	AllowedRoles           map[string]bool
	ReadName               bool
	ReadDescription        bool
	ReadValue              bool
	ReadStates             bool
	ReadBounds             bool
	ReadFocus              bool
	ReadActions            bool
}

type AccessibilityNode

type AccessibilityNode struct {
	Reference   []byte
	Parent      int
	Depth       uint32
	Role        string
	Name        string
	Description string
	Value       string
	Sensitive   bool
	Hidden      bool
	Offscreen   bool
	States      []string
	Bounds      *AccessibilityBounds
	Focused     bool
	Actions     []string
}

type AccessibilitySnapshot

type AccessibilitySnapshot struct {
	Backend           string
	Nodes             []AccessibilityNode
	Truncated         bool
	IdentityTruncated bool
}

func InspectAccessibility

func InspectAccessibility(
	ctx context.Context,
	target AccessibilityTarget,
	limits AccessibilityLimits,
) (AccessibilitySnapshot, error)

type AccessibilityTarget

type AccessibilityTarget struct {
	ProcessID     int
	CGWindowID    int
	ExpectedTitle string
}

type Backend

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

Backend resolves macOS window targets and enforces RobotGo's public window contract.

func New

func New(system System) *Backend

New constructs a Backend around a macOS window system implementation.

func NewNative

func NewNative() *Backend

NewNative constructs a lazily initialized backend backed by macOS system frameworks.

func (*Backend) Activate

func (backend *Backend) Activate(handle windowbackend.Handle) error

Activate raises a valid window through macOS Accessibility.

func (*Backend) Active

func (backend *Backend) Active() (windowbackend.Handle, error)

Active returns the focused window of the frontmost application.

func (*Backend) Bounds

func (backend *Backend) Bounds(handle windowbackend.Handle, _ bool) (windowbackend.Rect, error)

Bounds returns AX window-frame geometry. macOS Accessibility does not expose a separate cross-application client rectangle, so client and outer requests intentionally return the same frame.

func (*Backend) Close

func (backend *Backend) Close(handle windowbackend.Handle) error

Close presses the Accessibility close button for a valid window.

func (*Backend) CloseSystem

func (backend *Backend) CloseSystem() error

CloseSystem releases dynamically loaded framework references. A later operation reopens them lazily.

func (*Backend) PID

func (backend *Backend) PID(handle windowbackend.Handle) (int, error)

PID returns the owning process ID for a valid window.

func (*Backend) Ready

func (backend *Backend) Ready() error

Ready resolves the required system symbols and performs a non-prompting Accessibility permission preflight.

func (*Backend) Resolve

func (backend *Backend) Resolve(target int, isHandle bool) (windowbackend.Handle, error)

Resolve maps either a PID or explicit CGWindowID to a valid AX window.

func (*Backend) Select

func (backend *Backend) Select(target int, isHandle bool) error

Select stores a successfully resolved compatibility handle.

func (*Backend) Selected

func (backend *Backend) Selected() windowbackend.Handle

Selected returns the compatibility handle stored by Select.

func (*Backend) SetState

func (backend *Backend) SetState(
	handle windowbackend.Handle,
	state windowbackend.State,
	enabled bool,
) error

SetState supports minimized state. macOS does not expose a stable cross-application maximized state equivalent to RobotGo's contract.

func (*Backend) SetTopMost

func (backend *Backend) SetTopMost(handle windowbackend.Handle, _ bool) error

SetTopMost returns an explicit unsupported error because macOS Accessibility does not expose a trustworthy global topmost mutation.

func (*Backend) State

func (backend *Backend) State(
	handle windowbackend.Handle,
	state windowbackend.State,
) (bool, error)

State supports minimized-state queries and explicitly rejects maximized state.

func (*Backend) Title

func (backend *Backend) Title(handle windowbackend.Handle) (string, error)

Title returns the Accessibility title for a valid window.

func (*Backend) TopMost

func (backend *Backend) TopMost(handle windowbackend.Handle) (bool, error)

TopMost returns an explicit unsupported error because macOS Accessibility does not expose a trustworthy global topmost state.

type System

type System interface {
	Ready() error
	ActiveWindow() (windowbackend.Handle, error)
	WindowExists(windowbackend.Handle) (bool, error)
	FindWindowByPID(int32) (windowbackend.Handle, error)
	WindowPID(windowbackend.Handle) (int32, error)
	WindowTitle(windowbackend.Handle) (string, error)
	WindowRect(windowbackend.Handle) (windowbackend.Rect, error)
	RaiseWindow(windowbackend.Handle) error
	SetMinimized(windowbackend.Handle, bool) error
	IsMinimized(windowbackend.Handle) (bool, error)
	CloseWindow(windowbackend.Handle) error
	Close() error
}

System abstracts the macOS Accessibility and CoreGraphics calls used by Backend.

Jump to

Keyboard shortcuts

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