darwinwindow

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: 5 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

This section is empty.

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")
)

Functions

This section is empty.

Types

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