windowswindow

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StateMinimized identifies the minimized/iconic state.
	StateMinimized = windowbackend.StateMinimized
	// StateMaximized identifies the maximized/zoomed state.
	StateMaximized = windowbackend.StateMaximized
)

Variables

View Source
var (
	// ErrWindowNotFound reports that no window matched the requested target.
	ErrWindowNotFound = errors.New("windows window not found")
	// ErrInvalidWindow reports a zero, stale, or otherwise invalid HWND.
	ErrInvalidWindow = errors.New("invalid Windows window handle")
	// ErrOperation reports a failed Win32 window operation.
	ErrOperation = errors.New("windows window operation failed")
)

Functions

This section is empty.

Types

type Backend

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

Backend resolves window targets and enforces the public operation contract.

func New

func New(system System) *Backend

New constructs a Backend around a Win32 system implementation.

func (*Backend) Activate

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

Activate requests foreground activation for a valid window.

func (*Backend) Active

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

Active returns the current valid foreground window.

func (*Backend) Bounds

func (backend *Backend) Bounds(handle Handle, client bool) (Rect, error)

Bounds returns outer or client geometry for a valid window.

func (*Backend) Close

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

Close posts WM_CLOSE to a valid window.

func (*Backend) PID

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

PID returns the owning process ID for a valid window.

func (*Backend) Resolve

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

Resolve maps either a PID or an explicit HWND to a valid 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() Handle

Selected returns the compatibility handle stored by Select.

func (*Backend) SetState

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

SetState changes a minimized or maximized window state.

func (*Backend) SetTopMost

func (backend *Backend) SetTopMost(handle Handle, enabled bool) error

SetTopMost changes a window's topmost state without moving or resizing it.

func (*Backend) State

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

State queries a minimized or maximized window state.

func (*Backend) Title

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

Title returns a non-empty title for a valid window.

func (*Backend) TopMost

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

TopMost reports whether a window has topmost extended style.

type Handle

type Handle = windowbackend.Handle

Handle is a platform-neutral representation of a Windows HWND.

type Rect

type Rect = windowbackend.Rect

Rect contains screen-relative window geometry.

type State

type State = windowbackend.State

State identifies a queryable and mutable Windows presentation state.

type System

type System interface {
	ForegroundWindow() Handle
	IsWindow(Handle) bool
	FindWindowByPID(uint32) (Handle, error)
	WindowProcessID(Handle) (uint32, error)
	WindowText(Handle) (string, error)
	WindowRect(Handle) (Rect, error)
	ClientRect(Handle) (Rect, error)
	SetForegroundWindow(Handle) error
	SetWindowState(Handle, State, bool) error
	WindowState(Handle, State) (bool, error)
	IsTopMost(Handle) (bool, error)
	SetTopMost(Handle, bool) error
	CloseWindow(Handle) error
}

System abstracts the Win32 calls used by Backend.

Jump to

Keyboard shortcuts

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